# helm_charts_authenticate-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ template "pomerium.authenticate.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ template "pomerium.authenticate.name" . }}
    helm.sh/chart: {{ template "pomerium.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: authenticate
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
{{- if or .Values.authenticate.service.annotations .Values.service.annotations }}
  annotations:
  {{- if .Values.authenticate.service.annotations }}
    {{- range $key, $value := .Values.authenticate.service.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
  {{- else if .Values.service.annotations }}
    {{- range $key, $value := .Values.service.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
  {{- end }}
{{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.externalPort }}
      targetPort: https
      protocol: TCP
      name: https
    - name: metrics
      port: {{ .Values.metrics.port }}
      protocol: TCP
      targetPort: metrics
{{- if hasKey .Values.service "nodePort" }}
    nodePort: {{ .Values.service.nodePort }}
{{- end }}
  selector:
    app.kubernetes.io/name: {{ template "pomerium.authenticate.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}