{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.kubeScheduler.enabled .Values.kubeScheduler.service.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "kube-prometheus.fullname" . }}-kube-scheduler
  namespace: {{ .Values.kubeScheduler.namespace }}
  {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.kubeScheduler.service.labels .Values.commonLabels ) "context" . ) }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: kube-scheduler
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http-metrics
      port: {{ .Values.kubeScheduler.service.ports.http }}
      protocol: TCP
      targetPort: {{ .Values.kubeScheduler.service.targetPorts.http }}
  {{- if not .Values.kubeScheduler.endpoints }}
  selector:
    {{- if .Values.kubeScheduler.service.selector }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.kubeScheduler.service.selector "context" $ ) | nindent 4 }}
    {{- else }}
    component: kube-scheduler
    {{- end }}
  {{- end }}
{{- end }}
