Skip to content

Instantly share code, notes, and snippets.

@sekka1
Created June 7, 2016 16:50
Show Gist options
  • Save sekka1/37c38ed69f24a92eeb183042b6adafcc to your computer and use it in GitHub Desktop.
Save sekka1/37c38ed69f24a92eeb183042b6adafcc to your computer and use it in GitHub Desktop.
#cloud-config
write-files:
- path: /opt/bin/wupiao
permissions: '0755'
content: |
#!/bin/bash
# [w]ait [u]ntil [p]ort [i]s [a]ctually [o]pen
[ -n "$1" ] && [ -n "$2" ] && while ! curl --output /dev/null \
--silent --head --fail \
http://${1}:${2}; do sleep 1 && echo -n .; done;
exit $?
#
- path: /etc/modules-load.d/nf.conf
owner: root:root
permissions: 0644
content: |
nf_conntrack
- path: /etc/sysctl.d/perf_settings.conf
owner: root:root
permissions: 0644
content: |
net.ipv4.tcp_tw_reuse=1
net.ipv4.ip_local_port_range=2000 65535
net.netfilter.nf_conntrack_max=327680
net.netfilter.nf_conntrack_tcp_timeout_established=86400
net.netfilter.nf_conntrack_generic_timeout=30
net.ipv4.tcp_fin_timeout=10
net.core.somaxconn=16384
net.core.netdev_max_backlog=16384
- path: /etc/sysctl.d/10-disable-ipv6.conf
owner: root:root
permissions: 0644
content: |
net.ipv6.conf.all.disable_ipv6=1
#
coreos:
etcd2:
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
discovery-srv: {{ ETCD_DISCOVERY_SRV }}
proxy: on
fleet:
metadata: "role=kube-node,zone=c,function=ASGNew"
units:
- 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.20.0.0/16", "Backend": {"Type": "vxlan"}}'
- name: setup-network-environment.service
command: start
content: |
[Unit]
Description=Setup Network Environment
Documentation=https://github.com/kelseyhightower/setup-network-environment
Requires=network-online.target
After=network-online.target
[Service]
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/curl -L -o /opt/bin/setup-network-environment -z /opt/bin/setup-network-environment https://github.com/kelseyhightower/setup-network-environment/releases/download/1.0.1/setup-network-environment
ExecStartPre=/usr/bin/chmod +x /opt/bin/setup-network-environment
ExecStart=/opt/bin/setup-network-environment
RemainAfterExit=yes
Type=oneshot
- name: docker.service
command: start
drop-ins:
- name: 51-docker-mirror.conf
content: |
[Unit]
Requires=flanneld.service var-lib-docker-perms.service
After=flanneld.service var-lib-docker-perms.service
[Service]
Environment=DOCKER_OPTS='--ipv6=false --userland-proxy=false --registry-mirror=http://{{ VPC_NETWORK }}.31.10:5000'
- name: 30-increase-ulimit.conf
content: |
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=100000
- name: kube-proxy.service
command: start
content: |
[Unit]
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service
After=docker.service
[Service]
LimitNOFILE=100000
ExecStartPre=/usr/bin/curl -L -o /opt/bin/kube-proxy -z /opt/bin/kube-proxy https://storage.googleapis.com/kubernetes-release/release/{{ KUBE_VERSION }}/bin/linux/amd64/kube-proxy
ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-proxy
# wait for kubernetes master to be up and ready
ExecStartPre=/opt/bin/wupiao {{ VPC_NETWORK }}.31.10 8080
ExecStart=/opt/bin/kube-proxy \
--master={{ VPC_NETWORK }}.31.10:8080 \
--logtostderr=true \
--proxy-mode=iptables \
Restart=always
RestartSec=10
- name: kube-kubelet.service
command: start
content: |
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service
After=docker.service
[Service]
LimitNOFILE=100000
EnvironmentFile=/etc/network-environment
ExecStartPre=/usr/bin/curl -L -o /opt/bin/kubelet -z /opt/bin/kubelet https://storage.googleapis.com/kubernetes-release/release/{{ KUBE_VERSION }}/bin/linux/amd64/kubelet
ExecStartPre=/usr/bin/chmod +x /opt/bin/kubelet
# wait for kubernetes master to be up and ready
ExecStartPre=/opt/bin/wupiao {{ VPC_NETWORK }}.31.10 8080
ExecStart=/opt/bin/kubelet \
--root-dir="/var/lib/docker" \
--address=0.0.0.0 \
--port=10250 \
--api_servers={{ VPC_NETWORK }}.31.10:8080 \
--allow_privileged=true \
--logtostderr=true \
--cloud-provider="aws" \
--healthz_bind_address=0.0.0.0 \
--healthz_port=10248 \
--cluster_dns=10.100.0.10 \
--cluster_domain=cluster.local
Restart=always
RestartSec=10
- name: format-ephemeral.service
command: start
content: |
[Unit]
Description=Formats the ephemeral drive
After=dev-xvdz.device
Requires=dev-xvdz.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/curl -L -o /opt/bin/format-ephemeral-uvwxyz.sh -z /opt/bin/format-ephemeral-uvwxyz.sh http://vungle-ops.s3.amazonaws.com/cf-scripts/format-ephemeral-uvwxyz.sh
ExecStartPre=/usr/bin/chmod +x /opt/bin/format-ephemeral-uvwxyz.sh
ExecStart=/opt/bin/format-ephemeral-uvwxyz.sh
- name: var-lib-docker.mount
command: start
content: |
[Unit]
Description=Mount ephemeral to /var/lib/docker
Requires=format-ephemeral.service
After=format-ephemeral.service
Before=docker.service
Before=docker.socket
[Mount]
What=/dev/md0
Where=/var/lib/docker
Type=ext4
- name: var-lib-docker-perms.service
command: start
content: |
[Unit]
Description=Ensure /var/lib/docker is owned by docker
Requires=var-lib-docker.mount
After=var-lib-docker.mount
Before=docker.service
Before=docker.socket
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/chown docker /var/lib/docker
- name: reload-sysctl.service
command: start
content: |
[Unit]
Description=Reload the sysctl configuration
Before=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/sysctl --system
- name: systemd-modules-load.service
command: restart
- name: systemd-sysctl.service
command: restart
update:
reboot-strategy: etcd-lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment