This tutoriel is HEAVILY inspired by https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975, but adapted (docker/kubernetes versions + custom scripts + a hacky "background script" to tune the timeout of Kubeadm)
- Hypriot 1.9.x (1.10 not tested yet because rc)
- Kernel >= 4.14.54
- Raspberry Pis
- SD cards class 10
- Dump the hypriot image on the SD card, following official instructions at https://blog.hypriot.com/downloads/
- Repeat for each SD
For each Pi:
- Insert and SD an boot the Pi
- Connect to the Pi with
ssh [email protected]
. Password ishypriot
. If you cannot access the machine, search for its IP withnmap -sP 192.168.0.1/24
(adapt network and mask to your setup). - Curl the 2 shell scripts below, using the RAW URLs
- Execute the
prepare-system.sh
script with sudo, passing hostname and expected static IP as arguments:sudo bash /boot/prepare-system.sh <hostname> <IP>
. After a while, the machine will reboot by itself. - Iterate One pi after the other.
- Once the first Pi has rebooted, SSH to it again, using the static IP adress.
- ONLY for the first Pi, initialize the Kubernetes cluster with the
kube-init.sh
script:sudo bash /boot/kube-init.sh
- After a (looong) while, Kubeadm will print the set of instructions and the "join" token. Write this token persistent on your admin machine (it is valid for 24 hours).
- Validate the readiness with
kubectl get node
- On each other Pi, run the join command provided by
kubeadm init ...
. You can do all at the same time:sudo kubeadm join --token <token> <static IP of the master>:6443
- After a while, the command
kubectl get node
will report all your nodes as ready (be patient!)
MetalLB provides a configurable and distributed load balancer system (ala ELB/ALB/NLB), with a floating IP on your network, to allow external access: https://metallb.universe.tf/ .
Installation is straight forward:
-
Installation of MetalLB using Kubernetes YAML from the master node:
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.7.3/manifests/metallb.yaml
-
Configure MetalLB to use Layer-2 load balancing (you might use BGP if your router is compliant - Ref. https://metallb.universe.tf/configuration). As described in https://metallb.universe.tf/configuration/#layer-2-configuration, on the master, create a file named
metallb-config.yaml
, and file it with the following content (adapting the IP to your network of course):apiVersion: v1 kind: ConfigMap metadata: namespace: metallb-system name: config data: config: | address-pools: - name: default protocol: layer2 addresses: - 192.168.0.100-192.168.0.150 # Ip range (all must be availables)
- On the administration machine, download the file
/etc/kubernetes/admin.conf
from the master node (usingscp
). - Adapt your
kubectl
configuration (located in"${HOME}/.kube/config"
with the 3 objects: cluster, user, and context. - Switch to this newly created context with
kubectl config use-context <name you gave to your context>
- Install Helm on your administration machine (ref. https://docs.helm.sh/).
- Apply this YAML to Kubernetes to initialize the RBAC Roles and Service Accounts:
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
- Initializing Helm means starting a pod with a service named "Tiller" on your cluster. Your need to specify a specialized docker image for running Tiller for ARM architecture. Use the following command:
helm init --service-account tiller --tiller-image=jessestuart/tiller:v2.9.1 --upgrade