apiVersion: v1
kind: Service
metadata:
  name: {{ include "barycenter.fullname" . }}
  labels:
    {{- include "barycenter.labels" . | nindent 4 }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
  - port: {{ .Values.service.port }}
    targetPort: http
    protocol: TCP
    name: http
  {{- if .Values.config.authz.enabled }}
  - port: {{ .Values.config.authz.port | default (add .Values.config.server.port 2) }}
    targetPort: authz
    protocol: TCP
    name: authz
  {{- end }}
  selector:
    {{- include "barycenter.selectorLabels" . | nindent 4 }}
