Install kubernetes v1.9.2 on Rasberry Pi

Install kubernetes v1.9.2 on Rasberry Pi

Below are the steps to install 5 nodes + 1 master of k8s on Raspberry Pi

SD card preparation

Prepare 6 SD cards and flash with the Hypriot OS, this would be the most stable OS as of today. Install the tool flash

curl -O$(uname -s)/flash
chmod +x flash
sudo mv flash /usr/local/bin/flash

Flashing 6 SD card with the latest Hyprio OS - hostname from node[01-06]

flash --hostname node01

Default username and password would be pirate:hypriot, make sure to change it before proceed.

Install kubeadm on master and other nodes

Use root privilege to install kubeadm on all 6 raspberry pi

sudo su -
curl -s | apt-key add -
echo "deb kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get update && apt-get install -y kubeadm

For the Master node

Deploy the master with the below network, better don’t change the network mask, since other plugins (flannel) are also using the same one for somea reason I don’t know. Better don’t take the extra risk for nothing :)

kubeadm init --pod-network-cidr

After installation, it should prompt for something like this below (for k8s version 1.9.2)

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

For the rest of 5 slave nodes

After master node deployted, it should prompt for something like below for connectng to the master node.

kubeadm join --token 1-masked-5e31-masked-d90bc 192.168.-.-:6443 --discovery-token-ca-cert-hash sha256:6bbb9bdd507c1f58510--masked--0f37cba2d62--masked--00af6cb69a7

Last step - to deploy the flannel network driver

Instead of following the tutorial from Hypriot for v0.7.1 or v0.8, we install the latest one from the community. In which, we don’t have to install the rbac. (Not sure if RBAC is already included, but the below deployment works anyway).

curl -sSL | sed "s/amd64/arm/g" | kubectl apply -f -

Notice that the script is “apply” instead of “create”.

Finally, you should be able to get below:

Apple Super
After connecting 1 slave node (node02) to master

Last and the least step - Upgrade to the latest version (v1.9.3)

Before we proceed, we upgrade kubeadm client first:

export VERSION=$(curl -sSL # or manually specify a released Kubernetes version
export ARCH=arm # or: arm, arm64, ppc64le, s390x
curl -sSL${VERSION}/bin/linux/${ARCH}/kubeadm > /usr/bin/kubeadm
$ chmod a+rx /usr/bin/kubeadm

Store the kubeadm init’s flags:

kubeadm config upload from-flags --pod-network-cidr

Apply the upgrade

kubeadm upgrade plan
kubeadm upgrade apply 

It failed and get the below error:

[upgrade/apply] FATAL: couldn't upgrade control plane. kubeadm has tried to recover everything into the earlier state. Errors faced: [timed out waiting for the condition]

Alright, we fall back to v1.9.2…. :)

kubeadm upgrade apply 1.9.2

Deploy the Web UI

kubectl apply -f

The default image is in amd64 format, which doesn’t work. Following error message will be thrown: standard_init_linux.go:190: exec user process caused “exec format error”

Option 1: Login with Token: Print the replicaset controller token with:

kubectl -n kube-system describe secret `kubectl -n kube-system get secret | grep replicaset-controller-token | awk '{print $1}'` | grep token: | awk '{print $2}'

Option 2: Totally skip it:

kind: ClusterRoleBinding
  name: kubernetes-dashboard
    k8s-app: kubernetes-dashboard
  kind: ClusterRole
  name: cluster-admin
- kind: ServiceAccount
  name: kubernetes-dashboard
  namespace: kube-system

Deploy it with:

kubectl create -f dashboard-admin.yaml

Some useful commands

In case it fucked up, you can reset everything with below:

kubeadm reset

Enable CPU and memory accounting:

mkdir -p /etc/systemd/system.conf.d
cat <<EOF >/etc/systemd/system.conf.d/kubernetes-accounting.conf

#Reload it
systemctl daemon-reload


Scott Tse's Picture

About Scott Tse

Discover and Exploit.

Hong Kong, China