Lets create a multi-node cluster using k3d from Rancher.Rancher created k3s, which is a lightweight Kubernetes distribution. Rancher says that k3s is 5 less than k8s if that makes any sense. The basic idea is to remove features and capabilities that most people don’t need such as:
- In-tree storage drivers
- In-tree cloud providers
- Non-default features
- Legacy features
- Alpha features
k3s removed Docker completely and uses containerd instead. You can still bring Docker back if you depend on it. Another major change is that k3s stores its state in a sqlite DB instead of etcd. For networking and DNS k3s uses Flannel and CoreDNS.k3s also added a simplified installer that takes care of SSL and certificate provisioning.The end result is astonishing – a single binary (less than 40MB) that needs only 512MB of memory. Unlike Minikube and KinD, k3s is actually designed for production. The primary use case is for edge computing, IoT and CI systems. It is optimized for ARM devices.OK. That’s k3s, but what’s k3d? k3d takes all the goodness that is k3s and packages it in Docker (similar to KinD) and adds a friendly CLI to manage it.
Installing k3d on the MacOs is as simple as:
brew install k3d
Creating the cluster with k3d On ubuntu operating system
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
root@ubuntu-s-1vcpu-2gb-sgp1-01:~# k3d --version
k3d version v5.4.6
k3s version v1.24.4-k3s1 (default)
root@ubuntu-s-1vcpu-2gb-sgp1-01:~#
root@ubuntu-s-1vcpu-2gb-sgp1-01:~# time k3d cluster create --agents 3
INFO[0000] Prep: NetworkINFO[0000] Created network 'k3d-k3s-default'
INFO[0000] Created image volume k3d-k3s-default-images
INFO[0000] Starting new tools node...
INFO[0000] Starting Node 'k3d-k3s-default-tools'
INFO[0001] Creating node 'k3d-k3s-default-server-0'
INFO[0001] Creating node 'k3d-k3s-default-agent-0'
INFO[0001] Creating node 'k3d-k3s-default-agent-1'
INFO[0001] Creating node 'k3d-k3s-default-
INFO[0013] Starting Node 'k3d-k3s-default-agent-0'
INFO[0013] Starting Node 'k3d-k3s-default-agent-2'
INFO[0014] Starting Node 'k3d-k3s-default-agent-1'
INFO[0039] Cluster 'k3s-default' created successfully!
INFO[0040] You can now use it like this:kubectl cluster-info
real 0m40.408s
user 0m0.467s
sys 0m0.122s
root@ubuntu-s-1vcpu-2gb-sgp1-01:~# kubectl cluster-info
Kubernetes control plane is running at https://0.0.0.0:43373
CoreDNS is running at https://0.0.0.0:43373/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://0.0.0.0:43373/api/v1/namespaces/kube-system/services/https:metrics-server:https/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
root@ubuntu-s-1vcpu-2gb-sgp1-01:~#
root@ubuntu-s-1vcpu-2gb-sgp1-01:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3d-k3s-default-server-0 Ready control-plane,master 2m44s v1.24.4+k3s1
k3d-k3s-default-agent-2 Ready <none> 2m30s v1.24.4+k3s1
k3d-k3s-default-agent-1 Ready <none> 2m29s v1.24.4+k3s1
k3d-k3s-default-agent-0 Ready <none> 2m29s v1.24.4+k3s1
root@ubuntu-s-1vcpu-2gb-sgp1-01:~#
root@ubuntu-s-1vcpu-2gb-sgp1-01:~# k3d cluster delete
INFO[0000] Deleting cluster 'k3s-default'
INFO[0004] Deleting cluster network 'k3d-k3s-default'
INFO[0004] Deleting 2 attached volumes...
WARN[0004] Failed to delete volume 'k3d-k3s-default-images' of cluster 'k3s-default': failed to find volume 'k3d-k3s-default-images': Error: No such volume: k3d-k3s-default-images -> Try to delete it manually
INFO[0004] Removing cluster details from default kubeconfig...
INFO[0004] Removing standalone kubeconfig file (if there is one)...
INFO[0004] Successfully deleted cluster k3s-default!
root@ubuntu-s-1vcpu-2gb-sgp1-01:~#