Last active
May 21, 2019 21:47
-
-
Save steebchen/786cd84d8b8316f13251bc2638d7bc24 to your computer and use it in GitHub Desktop.
Kubernetes on Ubuntu
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 | |
# run this on all nodes | |
apt-get update && apt-get install -qy docker.io | |
apt-get update && apt-get install -y apt-transport-https \ | |
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list | |
apt-get update && apt-get install -y kubelet kubeadm kubernetes-cni | |
# pre-pull images on master so they're ready when we initialize the cluster | |
# kubeadm config images pull |
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 | |
# run this on all nodes | |
apt-get update && apt-get install -qy --allow-downgrades docker.io=18.06.1-0ubuntu1.2~16.04.1 | |
apt-get update && apt-get install -y apt-transport-https \ | |
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list | |
apt-get update && apt-get install -y --allow-downgrades kubelet=1.13.0-00 kubeadm=1.13.0-00 kubernetes-cni=0.6.0-00 |
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 | |
# RUN THIS ON THE ADMIN NODE ONLY | |
# 10.244.0.0/16 is the flannel subnet | |
# advertise the correct local IP | |
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=YOUR_LOCAL_IP_GOES_HERE | |
# add a user called default, this is required by k8s | |
sudo useradd default -G sudo -m -s /bin/bash | |
# replace 'a' with your password | |
echo "default:a" | chpasswd |
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
# use `su - default` to switch to user first | |
# make sure you can use sudo | |
# RUN THIS ON THE ADMIN NODE ONLY | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
sudo cp /etc/kubernetes/admin.conf $HOME/ | |
sudo chown $(id -u):$(id -g) $HOME/admin.conf | |
# this variable is read by flannel in a sec | |
export KUBECONFIG=$HOME/admin.conf | |
echo "export KUBECONFIG=$HOME/admin.conf" | tee -a ~/.bashrc | |
# set up network | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml |
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
# now run this in the shell to get the cluster joining command for the other nodes | |
kubeadm token create --print-join-command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment