#cloud-config
write_files:
  - path: /etc/systemd/system/enable-kube-scheduler.service
    owner: "root:root"
    permissions: "0644"
    content: |
      [Unit]
      Description=Enable Kubernetes Scheduler

      [Service]
      Type=oneshot
      ExecStart=/etc/sysconfig/enable-kube-scheduler.sh

      [Install]
      WantedBy=multi-user.target

  - path: /etc/sysconfig/enable-kube-scheduler.sh
    owner: "root:root"
    permissions: "0755"
    content: |
      #!/bin/sh

      . /etc/sysconfig/heat-params

      TEMPLATE=/etc/kubernetes/manifests/kube-scheduler.yaml
      mkdir -p $(dirname ${TEMPLATE})

      cat > ${TEMPLATE} <<EOF
      apiVersion: v1
      kind: Pod
      metadata:
        name: kube-scheduler
        namespace: kube-system
      spec:
        hostNetwork: true
        containers:
        - name: kube-scheduler
          image: gcr.io/google_containers/hyperkube:${KUBE_VERSION}
          command:
          - /hyperkube
          - scheduler
          - --master=http://127.0.0.1:8080
          - --leader-elect=true
          livenessProbe:
            httpGet:
              host: 127.0.0.1
              path: /healthz
              port: 10251
            initialDelaySeconds: ${SYSTEM_PODS_INITIAL_DELAY}
            timeoutSeconds: ${SYSTEM_PODS_TIMEOUT}
      EOF
