#cloud-config

hostname: node2
coreos:
  etcd:
    name: node2
    addr: 192.168.12.12:4001
    bind-addr: 0.0.0.0
    peer-addr: 192.168.12.12:7001
    peers: 192.168.12.10:7001,192.168.12.11:7001
    peer-heartbeat-interval: 250
    peer-election-timeout: 1000
  units:
    - name: static.network
      command: start
      content: |
        [Match]
        Name=ens33

        [Network]
        Address=192.168.12.12/24
        DNS=192.168.12.2
        Gateway=192.168.12.2
    - name: cbr0.netdev
      command: start
      content: |
        [NetDev]
        Kind=bridge
        Name=cbr0
    - name: cbr0.network
      command: start
      content: |
        [Match]
        Name=cbr0

        [Network]
        Address=10.244.2.1/24

        [Route]
        Destination=10.0.0.0/8
        Gateway=0.0.0.0
    - name: cbr0-interface.network
      command: start
      content: |
        [Match]
        Name=ens34

        [Network]
        Bridge=cbr0
    - name: nat.service
      command: start
      content: |
        [Unit]
        Description=NAT non container traffic

        [Service]
        ExecStart=/usr/sbin/iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE ! -d 10.0.0.0/8
        RemainAfterExit=yes
        Type=oneshot
    - name: etcd.service
      command: start
    - name: fleet.service
      command: start
    - name: docker.service
      command: start
      content: |
        [Unit]
        After=network.target
        Description=Docker Application Container Engine
        Documentation=http://docs.docker.io

        [Service]
        ExecStartPre=/bin/mount --make-rprivate /
        ExecStart=/usr/bin/docker -d -s=btrfs -H fd:// -b cbr0 --iptables=false

        [Install]
        WantedBy=multi-user.target
    - name: download-kubernetes.service
      command: start
      content: |
        [Unit]
        After=network-online.target
        Before=kubelet.service
        Before=proxy.service
        Description=Download Kubernetes Binaries
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Requires=network-online.target

        [Service]
        ExecStart=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/kubelet
        ExecStart=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/proxy
        ExecStart=/usr/bin/chmod +x /opt/bin/kubelet
        ExecStart=/usr/bin/chmod +x /opt/bin/proxy
        RemainAfterExit=yes
        Type=oneshot
    - name: kubelet.service
      command: start
      content: |
        [Unit]
        After=etcd.service
        After=download-kubernetes.service
        ConditionFileIsExecutable=/opt/bin/kubelet
        Description=Kubernetes Kubelet
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Wants=etcd.service
        Wants=download-kubernetes.service

        [Service]
        ExecStart=/opt/bin/kubelet \
        --address=0.0.0.0 \
        --port=10250 \
        --hostname_override=192.168.12.12 \
        --etcd_servers=http://127.0.0.1:4001 \
        --logtostderr=true
        Restart=always
        RestartSec=10

        [Install]
        WantedBy=multi-user.target
    - name: proxy.service
      command: start
      content: |
        [Unit]
        After=etcd.service
        After=download-kubernetes.service
        ConditionFileIsExecutable=/opt/bin/proxy
        Description=Kubernetes Proxy
        Documentation=https://github.com/GoogleCloudPlatform/kubernetes
        Wants=etcd.service
        Wants=download-kubernetes.service

        [Service]
        ExecStart=/opt/bin/proxy --etcd_servers=http://127.0.0.1:4001 --logtostderr=true
        Restart=always
        RestartSec=10

        [Install]
        WantedBy=multi-user.target
  update:
    group: alpha
    reboot-strategy: off
ssh_authorized_keys:
    - <ssh_public_key> 
