# helm_charts_authorize-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ template "pomerium.authorize.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ template "pomerium.authorize.name" . }}
    helm.sh/chart: {{ template "pomerium.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: authorize
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
{{- if or .Values.authorize.service.annotations .Values.service.annotations }}
  annotations:
  {{- if .Values.authorize.service.annotations }}
    {{- range $key, $value := .Values.authorize.service.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
  {{- else if .Values.service.annotations }}
    {{- range $key, $value := .Values.service.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
  {{- end }}
{{- end }}
spec:
{{- if .Values.service.authorize.headless }}
  clusterIP: None
  type: ClusterIP
{{- else }}}
  type: {{ .Values.service.type }}
{{- end }}
  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.authorize.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}