k3s: Kubernetes Dashboard + load balancer
In my post about first experience with k3s I blogged about setting up my k3s based cluster on Raspberry PI’s. Since that post I have added two more nodes Raspberry Pi’s and also updated to the 0.3.0 version of k3s.
Next step for me was getting the Kubernetes Dashboard up and running. I used the information from Web UI (Dashboard) First downloaded I the kubernetes-dashboard.yaml
and changed the image as it was pointing to the amd version and replaced it with the arm version.
After that I copied the yaml file to the /var/lib/rancher/k3s/server/manifests directory and the pod was created. To access the pod you have to run the command kubectl proxy. This makes it possible to access the dashboard from the local host only. It is possible to access the dashboard from a machine out of the cluster. To make it work you have to setup a ssl tunnel.
After that you can access the dashboard via this link: http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
In my environment, I have selected the option Token and followed the instructions for creating a token as described here . As they mention there it is a sample user with all permissions so in productions you would have to make other choices.
Next step was adding load balancing. Out of the box you can use nodeport to expose ports to the outside. This has however limitations. So I added, like a lot of other people, MetalLB . MetalLB can be run in two modes, layer-2 mode and bgp mode. I chose the layer-2 mode as this is very easy to install. You only have to download a YAML manifest.
By placing the file in /var/lib/rancher/k3s/server/manifests, it will be automatically applied. After that you have to
write a config map to
metallb-system/config. I chose a small ip-range.
To bind a service to a specific IP, you can use the
loadBalancerIP parameter in your service manifest:
This YAML is the example provided MetalLB in the tutorial. After the pod is running, you can look at the
nginx service with
kubectl get service nginx:
curl http://192.168.2.241 you should see the default nginx page: “Welcome to nginx!”