Skip to content

Instantly share code, notes, and snippets.

@tomaszwostal
Last active November 19, 2018 17:43
Show Gist options
  • Save tomaszwostal/c527f515b98cb7f4779b5897951dd5de to your computer and use it in GitHub Desktop.
Save tomaszwostal/c527f515b98cb7f4779b5897951dd5de to your computer and use it in GitHub Desktop.
Kubernetes on RaspberryPi

Run kubernetes cluster on RaspberryPi

Install docker

curl -sSL get.docker.com | sh && \
sudo usermod pi -aG docker

Disable swap

  sudo dphys-swapfile uninstall && \
  sudo update-rc.d dphys-swapfile remove

Edit /boot/cmdline.txt

Add this line at end of file.

cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory

Install kubernets

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 kubelet=1.9.11-00 kubectl=1.9.11-00 kubeadm=1.9.11-00

Reboot

sudo reboot

Initialize master node

sudo kubeadm init --token-ttl=0 --apiserver-advertise-address=192.168.88.100 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=ALL
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Install flannel

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

In case of network problems

sudo mkdir -p /etc/cni/net.d

sudo cat > /etc/cni/net.d/10-flannel.conflist <<EOF
{
    "name": "cbr0",
    "plugins": [
        {
            "type": "flannel",
            "delegate": {
                "hairpinMode": true,
                "isDefaultGateway": true
            }
        },
        {
            "type": "portmap",
            "capabilities": {
                "portMappings": true
            }
        }
    ]
}
EOF

Join worker node to the cluster

sudo kubeadm join 192.168.88.100:6443 \
--token 28115f.4dfba6838dfdbcf1 \
--discovery-token-ca-cert-hash sha256:14b227c334fe9d2293096b9c54944f8a6d1921348c03ded55b7bbce87a101883 \
--ignore-preflight-errors=all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment