Today, the use of containers is becoming more widespread, and their orchestration with solutions such as Openshift or Kubernetes. If in our day to day it is something that we have to deal with continuously, or we simply want to mess around with a personal project, it may be interesting to have a small laboratory at home for testing.
With our beloved RaspberryPi we can set up a small cluster (for now we are going to leave it as standalone) that although it will not serve as a production environment, and it is not something quick or easy, it can be tremendously entertaining.
To start what we are going to need is going to be very simple:
- RaspberryPi 4 with at least 4GB of RAM
- 64GB microSD card
- Current adapter of at least 3A to power the Raspberry
- Another computer with which we will connect by ssh.
Preparation
The first thing will be to prepare the S.O. of our RaspberryPi. This time we are going to use Ubuntu Server.
To do this we are going to download the corresponding ISO from its official website and load it onto our SD using [Balena Etcher](https://www.balena.io /etcher/).
We plug in the power adapter and boot up our board. The initial boot process usually takes about 5 minutes before it allows us to login.
We access our Raspberry through ssh, if we do not have a monitor and keyboard. The default login is:
- user:
ubuntu
- pass:
ubuntu
|
|
Once inside, the first thing it will ask us is to establish a password.
We update parcel
|
|
We prepare the S.O. to use cgroups. To do this we add the following to the end of the boot line of the /boot/firmware/cmdline.txt
file:
|
|
Initially we connect the Raspberry by network cable, but we can optionally leave the Wifi configured as “failover”
|
|
|
|
We correct our time zone
|
|
We add a hostname
|
|
and finally restart
|
|
##MicroK8s
When setting up our small Kubernetes cluster, we have several options:
- The official path of kubernetes
- minikube
- Embedded Kubernetes from Docker desktop
- microk8s
In our case, since we are using an operating system as a base, we are going to go with the microk8s solution, since it is developed by Canonical itself as a snap package. This can provide us with more compatibility and simplicity in keeping you up to date.
To do this, it is as simple as installing the package.
|
|
The syntax to manage our cluster with microk8s is: microk8s kubectl ******
. Our intention is to abstract as much as possible from this syntax, and simplify it by using kubectl
as an alias:
In this case it is bash but if we used zsh we would have to change the path of the aliases file
|
|
we add permissions to our user
|
|
We check that it is running:
|
|
We added some essential plugins, such as Dashboard, Ingress Registry and DNS
|
|
A short description of each of them
|
|
We verify that our aliases work correctly, and we have a running node
|
|
ite have a local registry to store the docker images
|
|
MetalLB
We are going to install the Load Balancer, using the solution of MetalLB
|
|
It will ask us for a range of reserved IPS to manage. In my home Network I am going to reserve these: 192.168.200.220-192.168.200.249
We are going to launch a small deployment to verify that our balancer is working correctly:
|
|
We can verify that one of the reserved IPs has been assigned:
|
|
Now we only need to attack the IP from the browser or with a simple curl
|
|
dashboard
To access our dashboard, we need to know the IP and port assigned to it:
|
|
With this we can now access the dashboard from outside our raspbery PI
https://{server ip}:{port number}
In my case:
|
|
When accessing from the browser, it will ask us for authentication. We need to find out the token. We can obtain this information in the microk8s configuration itself
|
|
We copy the token and paste it into the UI.
With this we would already have our cluster with a single node running and ready to work with it. Later we will see how to add more nodes to this cluster, remove them, etc.
MetalLB
We are going to install the Load Balancer, using the solution of MetalLB
|
|
It will ask us for a range of reserved IPS to manage. In my home Network I am going to reserve these: 192.168.200.220-192.168.200.249
We are going to launch a small deployment to verify that our balancer is working correctly:
|
|
We can verify that one of the reserved IPs has been assigned:
|
|
Now we only need to attack the IP from the browser or with a simple curl
|
|
dashboard
To access our dashboard, we need to know the IP and port assigned to it:
|
|
With this we can now access the dashboard from outside our raspbery PI
https://{server ip}:{port number}
In my case:
|
|
When accessing from the browser, it will ask us for authentication. We need to find out the token. We can obtain this information in the microk8s configuration itself
|
|
We copy the token and paste it into the UI.
With this we would already have our cluster with a single node running and ready to work with it. Later we will see how to add more nodes to this cluster, remove them, etc.