{{- $service := .Values.keycloak.service -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "keycloak.fullname" . }}-http
{{- with $service.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
  labels:
    app: {{ template "keycloak.name" . }}
    chart: {{ template "keycloak.chart" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
{{- with $service.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
  type: {{ $service.type }}
  ports:
    - name: http
      port: {{ $service.port }}
      targetPort: http
    {{- if and (eq "NodePort" $service.type) $service.nodePort }}
      nodePort: {{ $service.nodePort }}
    {{- end }}
      protocol: TCP
  selector:
    app: {{ template "keycloak.name" . }}
    release: "{{ .Release.Name }}"
