{{- 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.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: kube-scheduler
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- 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 }}
