Sun. Sep 25th, 2022
I have been researching for about 2 months for an alternative to Portainer, just because. Although Portainer is a sweet piece of software the priority is put on the business customers. I used to work for Portainer and other than one manager there it was great. Back to the point Portainer is not for the faint at heart. The other thing is they had a great product for managing docker containers and then for some reason they changed gears and focused on Kubernetes and it turns out to be a good move actually because Kubernetes is the latest and greatest buzzword/technology.

In this article I will try and teach you how to install Ubuntu Server with microk8s. Then we will install a Rancher VM to manage multiple Kubernetes Clusters. I have a K3s article on this site here, that shows you how to install Rancher with K3s.

Just an FYI anything that has a link in it , you should look at or research it will deepen you knowledge for this subject.

Let’s get started on our journey:

1 – Install OS (Ubuntu Server 20.04.4 is what I used.)
2 – sudo nano -c /boot/firmware/cmdline.txt
add the following to the end of the line:
cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1
You have to turn on cgroups for Kubernetes to work properly.
3 – sudo nano -c config.txt
add the following to the /boot/firmware/config.txt file it allows to turn off some hardware stuff:
dtoverlay=disable-wifi
dtoverlay=disable-bt

dtparam=audio=off
arm_64bit=1

Let me explain the last few lines:
the dtoverlay’s are used to enable and disable different hardware components, the reason these are disabled is to use the resources for other important tasks/hardware.

The last one forces the Raspberry Pi to use a 64bit mode for software otherwise it runs in 32 bit mode.

4 – sudo nano -c /etc/hosts – Put all the ips of you hosts in here

Little story about the DNS on Ubuntu Server, I was installing something to an Ubuntu Server and I noticed I could not update the repositories or the packages. So I started investigating and for some reason they basically broke the resolv.conf, so I had to fix it with the following commands.

5 – sudo nano -c /etc/resolv.conf
nameserver 1.1.1.1
nameserver 9.9.9.9

Fix the resolv.conf permanently with the following:
6 – sudo apt -y install resolvconf
7 – sudo systemctl start resolvconf.service
8 – sudo systemctl enable resolvconf.service
9 – sudo systemctl status resolvconf.service
Let’s set the preferred DNS Servers:

10 – sudo nano /etc/resolvconf/resolv.conf.d/head
nameserver 1.1.1.1
nameserver 9.9.9.9


Let’s restart the service to apply the fix:
11 – sudo systemctl restart resolvconf.service
12 – sudo systemctl restart systemd-resolved.service

We have to turn off swap kubernetes will not work with swap very well if at all.
13 – sudo swapoff -a
be sure to open the /etc/fstab and put a # mark in front of the swapline
you should also make sure you have your system time and date set to the current local region (for ex: EST).
Let’s update the Repositories and OS Packages:
14 – sudo apt update && sudo apt -y full-upgrade

Remove obsolete packages with the following:
15 – sudo apt -y autoremove
16 – sudo reboot

Install Kubernetes via Microk8s channel=1.19

You can use whatever version you like I used v1.19 that definitely works with Rancher. The versions go up to v1.24(Most Recent)

17 – sudo snap install microk8s –classic –channel=1.19/stable
Set user priviledges for your user to run kubernetes/microk8s commands
18 – sudo usermod -a -G microk8s $USER
19 – sudo chown -f -R $USER ~/.kube
20 – newgrp microk8s
On the master node run the following to add a node to the cluster:
21 – sudo microk8s add-node
On the master node use the following to watch the nodes come online:
22 – sudo watch microk8s kubectl get no
On the worker node run the following to join the cluster:
23 – sudo microk8s join 192.168.1.160:25000/<Rest_of_Token>
We should enable the plugins for the cluster at this point:
24 – sudo microk8s.enable dns dashboard storage ingress helm3
We should create an alias so you can just type kubectl:
25 – sudo snap alias microk8s.kubectl kubectl
Allow running pods in priviledged mode:
26 – sudo sh -c ‘echo “–allow-privileged=true” >> /var/snap/microk8s/current/args/kube-apiserver’
27 – sudo systemctl restart snap.microk8s.daemon-apiserver.service
28 – sudo microk8s.stop && sudo microk8s.start

End of Kubernetes Install

Install Rancher on the VM

After creating the VM with Ubuntu Server only NO DOCKER, & No Kubernetes (microk8s), Please perform the following on the VM.
We need to create a config file for rancher:
29 – mkdir -p /etc/rancher/rke2
30 – cd /etc/rancher/rke2
31 – nano -c config.yaml
token: t04m10r%(
tls-san:
– 192.168.1.69

32 – curl -sfL https://get.rancher.io | sh –
Let’s check to make sure eveything installed ok:
33 – rancherd –help – Look for the following Rancher Kubernetes Engine 2

This means rancher installed properly.

Enable & Start the Rancher Service:
34 – systemctl enable rancherd-server.service
35 – systemctl strat rancherd-server.service
Check on the progress of Rancher:
36 – journalctl -eu rancherd-server -f

Wait for all PODs to come up – Wait Approx: 5 minutes:
Reset the Admin password:
37 – rancherd reset-admin

Next we will get you started with Rancher
I will continue this article with how to setup/configure Rancher with your cluster.

By Michael Cooper

30 years in it, Senior Systems Engineer

Leave a Reply

Your email address will not be published.