#cloud-config

---
write_files:
hostname: master
coreos:
  etcd2:
    name: master
    listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
    advertise-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
    initial-cluster-token: k8s_etcd
    listen-peer-urls: http://0.0.0.0:2380,http://0.0.0.0:7001
    initial-advertise-peer-urls: http://0.0.0.0:2380
    initial-cluster: master=http://0.0.0.0:2380"
    initial-cluster-state: new
  units:
    - name: etcd.service
      command: start
    - name: fleet.service
      command: start
    - name: flanneld.service
      command: start
      drop-ins:
        - name: 50-network-config.conf
          content: |
            [Unit]
            Requires=etcd2.service
            [Service]
            ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{"Network":"10.244.0.0/16", "Backend": {"Type": "vxlan"}}'
    - name: docker-cache.service
      command: start
      content: |
        [Unit]
        Description=Docker cache proxy
        Requires=early-docker.service
        After=early-docker.service
        Before=early-docker.target

        [Service]
        Restart=always
        TimeoutStartSec=0
        RestartSec=5
        Environment="TMPDIR=/var/tmp/"
        Environment="DOCKER_HOST=unix:///var/run/early-docker.sock"
        ExecStartPre=-/usr/bin/docker kill docker-registry
        ExecStartPre=-/usr/bin/docker rm docker-registry
        ExecStartPre=/usr/bin/docker pull quay.io/devops/docker-registry:latest
        # GUNICORN_OPTS is an workaround for
        # https://github.com/docker/docker-registry/issues/892
        ExecStart=/usr/bin/docker run --rm --net host --name docker-registry \
            -e STANDALONE=false \
            -e GUNICORN_OPTS=[--preload] \
            -e MIRROR_SOURCE=https://registry-1.docker.io \
            -e MIRROR_SOURCE_INDEX=https://index.docker.io \
            -e MIRROR_TAGS_CACHE_TTL=1800 \
            quay.io/devops/docker-registry:latest
    - name: docker.service
      command: start
      drop-ins:
        - name: 51-docker-mirror.conf
          content: |
            [Unit]
            # making sure that docker-cache is up and that flanneld finished
            # startup, otherwise containers won't land in flannel's network...
            Requires=docker-cache.service flanneld.service
            After=docker-cache.service flanneld.service
            [Service]
            Environment=DOCKER_OPTS='--registry-mirror=http://$private_ipv4:5000'
    - name: kube-apiserver.service
      command: start
      content: |
        [Unit]
        Description=Kubernetes API Server
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Requires=etcd2.service
        After=etcd2.service

        [Service]
        ExecStartPre=-/usr/bin/mkdir -p /opt/bin
        ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/kubernetes-release/release/v0.15.0/bin/linux/amd64/kube-apiserver
        ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-apiserver
        ExecStart=/opt/bin/kube-apiserver \
        --allow_privileged=true \
        --insecure_bind_address=0.0.0.0 \
        --insecure_port=8080 \
        --kubelet_https=true \
        --secure_port=6443 \
        --portal_net=10.100.0.0/16 \
        --etcd_servers=http://127.0.0.1:4001 \
        --public_address_override=127.0.0.1 \
        --logtostderr=true
        Restart=always
        RestartSec=10
    - name: kube-controller-manager.service 
      command: start
      content: |
        [Unit]
        Description=Kubernetes Controller Manager
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Requires=kube-apiserver.service
        After=kube-apiserver.service

        [Service]
        ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/kubernetes-release/release/v0.15.0/bin/linux/amd64/kube-controller-manager
        ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-controller-manager
        ExecStart=/opt/bin/kube-controller-manager \
        --machines=127.0.0.1 \
        --master=127.0.0.1:8080 \
        --logtostderr=true
        Restart=always
        RestartSec=10
    - name: kube-scheduler.service
      command: start
      content: |
        [Unit]
        Description=Kubernetes Scheduler
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Requires=kube-apiserver.service
        After=kube-apiserver.service

        [Service]
        ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/kubernetes-release/release/v0.15.0/bin/linux/amd64/kube-scheduler
        ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-scheduler
        ExecStart=/opt/bin/kube-scheduler --master=127.0.0.1:8080
        Restart=always
        RestartSec=10
    - name: kube-proxy.service
      command: start
      content: |
        [Unit]
        Description=Kubernetes Proxy
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Requires=etcd2.service
        After=etcd2.service

        [Service]
        ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/kubernetes-release/release/v0.15.0/bin/linux/amd64/kube-proxy
        ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-proxy
        ExecStart=/opt/bin/kube-proxy \
        --master=127.0.0.1:8080 \
        --logtostderr=true
        Restart=always
        RestartSec=10
    - name: kube-kubelet.service
      command: start
      content: |
        [Unit]
        Description=Kubernetes Kubelet
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Requires=etcd2.service
        After=etcd2.service

        [Service]
        ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/kubernetes-release/release/v0.15.0/bin/linux/amd64/kubelet
        ExecStartPre=/usr/bin/chmod +x /opt/bin/kubelet
        ExecStart=/opt/bin/kubelet \
        --address=0.0.0.0 \
        --port=10250 \
        --hostname_override=127.0.0.1 \
        --api_servers=127.0.0.1:8080 \
        --allow_privileged=true \
        --logtostderr=true \
        --healthz_bind_address=0.0.0.0 \
        --healthz_port=10248
        Restart=always
        RestartSec=10
  update:
    group: alpha
    reboot-strategy: off
