Setup HA ETCD cluster on Raspberry Pi using K8s
Contents
This is a detailed guide on how to setup high availability etcd cluster on raspberry pi using kubernetes.
- Flash raspbianos on usb drive that you are going to use
Download Raspbian OS from official sources
Flash it using the command
# Replace <X> with the drive letter of your storage media, please refer to my previous guide for more info
# Replace <PATH TO RASPBIAN> with your system path where your image is located at
|
This will be completed at around 2.1GB size, time is completely dependent upon the speeds of your storage media. See here for reference
- change the host name to etcd-x where x is the number you are going to use
- change the locale and keyboard to en_US
- Turn Swap off permanently
On Raspbian, we can turn off swap by doing
- Install essentials
- choose your container runtime interface
Again we have two options, one is to use
Docker Installation
CRI-O Installation
As the dockershim CRI is deprecated for Kubernetes 1.24 onwards, we are going to choose a better and more lightweight option for our usecase
|
This script will automatically setup the CRI-O container runtime engine for our Raspbian OS.
Enable the runtime from systemd by command
You can check the status of runtime by using crictl info
and the version by crictl version
- add the etcd system config file at /etc/systemd/system/kubelet.service.d/20-etcd-service-manager.conf
vi /etc/systemd/system/kubelet.service.d/20-etcd-service-manager.conf
[Service]
/usr/bin/kubelet --address= --pod-manifest-path=/etc/kubernetes/manifests --cgroup-driver=systemd --container-runtime=remote --container-runtime-endpoint= --runtime-request-timeout=5m
always
- add the /var/lib/kubelet/config.yaml file with proper configuration
vi /var/lib/kubelet/config.yaml
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
address: 127.0.0.1
staticPodPath: /etc/kubernetes/manifests
cgroupDriver: systemd
runtimeRequestTimeout: 10m
- install kubernetes
- restore etcd data directory
-
edit the kubeadm.config file with initial-cluster-state=existing
-
manage your etcd cluster
More commands to manage your etcd cluster can be found at https://etcd.io/docs/v3.5/op-guide