apiVersion: v1
kind: Pod
metadata:
  name: openshift-kube-scheduler
  namespace: openshift-kube-scheduler
  annotations:
    kubectl.kubernetes.io/default-logs-container: kube-scheduler
  labels:
    app: openshift-kube-scheduler
    scheduler: "true"
    revision: "REVISION"
spec:
  initContainers:
  - name: wait-for-host-port
    image: ${IMAGE}
    imagePullPolicy: IfNotPresent
    terminationMessagePolicy: FallbackToLogsOnError
    command: ['/usr/bin/timeout', '30', '/bin/bash', '-c']
    args:
    - |
      echo -n "Waiting for port :10259 and :10251 to be released."
      while [ -n "$(lsof -ni :10251)" -o -n "$(lsof -i :10259)" ]; do
        echo -n "."
        sleep 1
      done
  containers:
  - name: kube-scheduler
    image: ${IMAGE}
    imagePullPolicy: IfNotPresent
    terminationMessagePolicy: FallbackToLogsOnError
    command: ["hyperkube", "kube-scheduler"]
    args:
    - --config=/etc/kubernetes/static-pod-resources/configmaps/config/config.yaml
    - --cert-dir=/var/run/kubernetes
    - --port=0
    - --authentication-kubeconfig=/etc/kubernetes/static-pod-resources/configmaps/scheduler-kubeconfig/kubeconfig
    - --authorization-kubeconfig=/etc/kubernetes/static-pod-resources/configmaps/scheduler-kubeconfig/kubeconfig
    resources:
      requests:
        memory: 50Mi
        cpu: 15m
    ports:
    - containerPort: 10259
    volumeMounts:
    - mountPath: /etc/kubernetes/static-pod-resources
      name: resource-dir
    - mountPath: /etc/kubernetes/static-pod-certs
      name: cert-dir
    livenessProbe:
      httpGet:
        scheme: HTTP
        port: 10251
        path: healthz
      initialDelaySeconds: 45
      timeOutSeconds: 10
    readinessProbe:
      httpGet:
        scheme: HTTP
        port: 10251
        path: healthz
      initialDelaySeconds: 45
      timeOutSeconds: 10
  - name: kube-scheduler-cert-syncer
    env:
    - name: POD_NAME
      valueFrom:
        fieldRef:
          fieldPath: metadata.name
    - name: POD_NAMESPACE
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    image: ${OPERATOR_IMAGE}
    imagePullPolicy: IfNotPresent
    terminationMessagePolicy: FallbackToLogsOnError
    command: ["cluster-kube-scheduler-operator", "cert-syncer"]
    args:
      - --kubeconfig=/etc/kubernetes/static-pod-resources/configmaps/kube-scheduler-cert-syncer-kubeconfig/kubeconfig
      - --namespace=$(POD_NAMESPACE)
      - --destination-dir=/etc/kubernetes/static-pod-certs
    resources:
      requests:
        memory: 50Mi
        cpu: 5m
    volumeMounts:
      - mountPath: /etc/kubernetes/static-pod-resources
        name: resource-dir
      - mountPath: /etc/kubernetes/static-pod-certs
        name: cert-dir
  - name: kube-scheduler-recovery-controller
    env:
    - name: POD_NAMESPACE
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    image: ${OPERATOR_IMAGE}
    imagePullPolicy: IfNotPresent
    terminationMessagePolicy: FallbackToLogsOnError
    command: ["/bin/bash", "-euxo", "pipefail", "-c"]
    args:
      - |
        timeout 3m /bin/bash -exuo pipefail -c 'while [ -n "$(ss -Htanop \( sport = 11443 \))" ]; do sleep 1; done'

        exec cluster-kube-scheduler-operator cert-recovery-controller --kubeconfig=/etc/kubernetes/static-pod-resources/configmaps/kube-scheduler-cert-syncer-kubeconfig/kubeconfig  --namespace=${POD_NAMESPACE} --listen=0.0.0.0:11443 -v=2
    resources:
      requests:
        memory: 50Mi
        cpu: 5m
    volumeMounts:
      - mountPath: /etc/kubernetes/static-pod-resources
        name: resource-dir
      - mountPath: /etc/kubernetes/static-pod-certs
        name: cert-dir
  hostNetwork: true
  priorityClassName: system-node-critical
  tolerations:
  - operator: "Exists"
  volumes:
  - hostPath:
      path: /etc/kubernetes/static-pod-resources/kube-scheduler-pod-REVISION
    name: resource-dir
  - hostPath:
      path: /etc/kubernetes/static-pod-resources/kube-scheduler-certs
    name: cert-dir
