apiVersion: v1
kind: Service
metadata:
  name: {{ include "spark-history-server.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "spark-history-server.name" . }}
    helm.sh/chart: {{ include "spark-history-server.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
  {{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | trim | indent 4 }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
  - port: {{ .Values.service.port.number }}
    targetPort: historyport
    protocol: TCP
    name: {{ .Values.service.port.name }}
    {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
    nodePort: {{ .Values.service.nodePort }}
    {{- end }}
  selector:
    app.kubernetes.io/name: {{ include "spark-history-server.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
