Skip to content

Instantly share code, notes, and snippets.

@andrei-dascalu
Created March 31, 2018 22:10
Show Gist options
  • Save andrei-dascalu/2b5ec069b9f5d15496efda6cd33b3bbe to your computer and use it in GitHub Desktop.
Save andrei-dascalu/2b5ec069b9f5d15496efda6cd33b3bbe to your computer and use it in GitHub Desktop.
Script to install docker/kubeadm/kubelet for a Kubernetes master node on Raspberry Pi 3
#!/bin/bash
# sudo apt-get -y install \
# raspberrypi-kernel-headers \
# raspberrypi-kernel
#sudo apt-get -y install \
# linux-headers-4.9.0-4-rpi2 \
# linux-image-4.9.0-4-rpi2
#At this moment, kubeadm/kubelete 1.10 can't be installed on the current version
#of raspbian, as it needs dkms-aufs, which has a hardcoded dependency on linux-headers-4.9.0
#Unfortuntely, with the current setup of raspbian, the autopartitioned sd card
#doesn't provide enough space on /boot partition to accomodate the downgrade
#from 4.14.31 to 4.9 something
#We need to install kubeadm/kubelet 1.9 for Raspberry pi
sudo apt-get update
sudo rpi-update
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
raspberrypi-kernel-headers \
raspberrypi-kernel \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
echo "deb [arch=armhf] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get -y install docker-ce
sudo usermod pi -aG docker
sudo dphys-swapfile swapoff && sudo dphys-swapfile uninstall && sudo update-rc.d dphys-swapfile remove
sudo sed -i '$s/$/\ cgroup_enable=cpuset\ cgroup_enable=memory\ cgroup_memory=1/' /boot/cmdline.txt
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update -q
sudo apt-get install -qy kubeadm=1.9.6-00 kubelet=1.9.6-00
sudo kubeadm init --apiserver-advertise-address=192.168.0.104 > kube.txt
mkdir -p $HOME/.kube && sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config && sudo chown $(id -u):$(id -g) $HOME/.kube/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment