Created
September 5, 2018 14:16
-
-
Save sebgoa/10fce47d935326f29d94246bb4116ab6 to your computer and use it in GitHub Desktop.
cloud-init script to boostrap Kubernetes in a single VM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e -x | |
apt-get --yes --quiet update | |
apt-get --yes --quiet install apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
apt-get update | |
apt-get --yes --quiet install docker-ce | |
usermod -aG docker ubuntu | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list | |
deb http://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
apt-get update | |
apt-get install --yes kubelet kubeadm kubectl | |
apt-mark hold kubelet kubeadm kubectl | |
kubeadm init | |
# for the ubuntu user | |
mkdir -p /home/ubuntu/.kube | |
cp -i /etc/kubernetes/admin.conf /home/ubuntu/.kube/config | |
chown 1000:1000 /home/ubuntu/.kube/config | |
# for the root user | |
mkdir -p $HOME/.kube | |
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
chown $(id -u):$(id -g) $HOME/.kube/config | |
kubectl taint nodes --all node-role.kubernetes.io/master- | |
sysctl net.bridge.bridge-nf-call-iptables=1 | |
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment