Introduction
This blog is an "answer" to the The New Stack article and the goal is to see how few changes, based on the Rancher official documentation, could help run the example in the article.
Prerequisites
I'm working on Windows and to have a comparable environment, I created an Hyper-V virtual machine (VM) instead of using WSL2.
Here's the configuration details:
- VM: 2 cores / 4Go Ram / 60Go disk
- OS: Ubuntu server 22.04
- Option: OpenSSH server installed
I decided to not install MicroK8s from the installer and will instead make it part of the environment configuration steps (see below).
Memory consumption
One of the points pointed out by the author, is that "Rancher" requires at least 4Go RAM as mentioned in the docs.
So while there's some sort of misunderstanding in the requirements, I've taken up to the challenge and created the VM with only 4Go.
Note: the misunderstanding is that the requirements are only for Rancher on Docker, in a standalone server. The author tried to put everything in the same server. This means that only the Rancher requirements were "looked into", and discarded the MicroK8s' own requirements.
For the time being, let's see what a fresh install of Ubuntu server uses:
As displayed, the OS footprint is about 200 Mo, which represents only 5% of the RAM available.
Configuration
Once the OS is installed, we can SSH with the user and password created during the installation.
MicroK8s
The first part will be to update the system and install MicroK8s:
# Update the repositories
sudo apt update
# Update the packages
sudo apt upgrade -y
# Install MicroK8s
sudo snap install microk8s --classic
# [Optional] Install Kubectl
sudo snap install kubectl --classic
## [Option 2] Create an alias to `microk8s kubectl`
sudo snap alias microk8s.kubectl mk
# Add the user to the microk8s group
sudo usermod -a -G microk8s $USER
sudo chown -R $USER ~/.kube
# Apply the group change by starting a new session
# [Optional] Create the .kube directory
mkdir ~/.kube
# Get the Kubeconfig
microk8s config > ~/.kube/config
Attention: MicroK8s shows different cluster IP depending on which
kubectl
is used.Attention 2: As of May 2023, the version installed by default is 1.26.4 from the channel 1.26/stable. However the current version of Rancher Manager, 2.7.3, only supports Kubernetes 1.25+. Source: Support matrix | SUSE
Memory consumption
As stated in MicroK8s official documentation, the cluster doesn't need much RAM, about 500Mo, which fully correlates with the RAM usage once MicroK8s has been installed:
As displayed, the current RAM used is around 700Mo which represents the 200Mo from the OS and the 500Mo from MicroK8s. So we're about 20% of RAM usage, which seems plenty to continue.
Docker
The second part and which relates now to the article, is the installation of Docker which will be used to run the Rancher container.
# Install the dependencies
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
# Install the Docker repository GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add the Docker repository
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the repositories
sudo apt update
# Install docker
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
# Add the user to the docker group
sudo usermod -aG docker $USER
# Apply the group change by starting a new session
Memory consumption
Docker install doesn't consume much, around 20Mo only. This is normal as the daemon is idle with no containers running:
Let's try to run a "minimal" Nginx container from the Chainguard image:
Even with such minimal container running, the RAM usage is about 90Mo.
Note: before continuing, I stopped all the containers running and rebooted the server. This brought bach the RAM usage to 790+Mo
Rancher Manager
Here's the final component, and so far the RAM usage seems to handle pretty well the workloads.
I'll start a new container based on the latest Rancher version, instead of 2.4 as described in the article. The reason why the author faced issues between Rancher and MicroK8s is due to the version mismatch.
The current version of Rancher, 2.7.3, only supports Kubernetes versions up to 1.25 (as described in the official Rancher Support Matrix. However, the default MicroK8s version is 1.26.
I'll explain later how we can easily change the MicroK8s version, but let's go back to the Rancher container.
The command to start the container is the following:
# Start a new Rancher container
docker run -d --name=rancher-server --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:latest
Once the container started, Rancher is available via the web on the address of the server. Example: https://192.168.0.31
Memory consumption
The Rancher container contains a K3s single node cluster, the containerD runtime and Rancher Manager installed. This is reflected in the memory usage:
As displayed, this is a clear jump in RAM usage as it went from almost 800Mo to 2Go+, which represents 50% of the total RAM.
Still, there's plenty of RAM to continue and perform the last task.
Add MicroK8s to Rancher
As stated above, one of the issue the author ran into was due to a version mismatch.
The current default version installed by MicroK8s is 1.26. So to ensure the compatibility between Rancher and MicroK8s, the version needs to be downgraded to 1.25.
Thanks to the concept of snap channels
, this can be achieved in one command:
# [Optional] Check the current MicroK8s version
microk8s version
# Change the channel to the 1.25 stable
sudo snap refresh microk8s --channel=1.25/stable
# [Optional] Check the current MicroK8s version
microk8s version
Now that all the components have compatible versions, MicroK8s can be imported into Rancher in the web interface as follow:
- In the welcome page, once logged in, click on
Import Existing
- Choose
Generic
- Write a name, all lowercase, and click
Create
- On the registration page, click on the second option
curl --insecure ...
to copy the text
Note: Based on how Rancher was installed with the Docker command, it created a self-signed certificate. This means that MicroK8s will not have the corresponding certificate and would generate an error if the first option was used
- Once the registration completes, the node will appear as active
Memory consumption
After all the tasks were done, and which were successful, the final RAM usage is around 2.5Go, which represents 60%+:
Conclusion
As stated in a tweet, this article comes with a bitter-sweet taste for me.
In one end, I can totally relate to the "learning in public" by writing blog posts, trying new technology and making (many) mistakes while doing so.
However when I face specific issues that others don't seem to have, then I tend to ask for help on different community channels, and of course I go back to the products/projects official documentation.
This is also where I don't relate at all, with the article as a whole and have some questions about the publishing process of The New Stack. The article ends abruptly by stating: Portainer is better, use it!
Well, because the article is somewhat incorrect in certain points, again due to the lack of documentation checking, the article actually brought a shade on both Portainer and MicroK8s which never asked for it (I got DMs from both companies).
So here's my advice to anyone reading this blog post: please continue learning in public, ask questions and if you face issues ask for help. But sincerely, avoid doing unwanted comparisons and READ THE DOCS! I'm a Tech Writer, if my docs are not good/complete, open an issue, they're ALL open sourced.
The Corsair 🏴☠️
Top comments (0)