This is a quick and short text on how to install MICROK8S 1.19/Edge on Ubuntu 22.04. I am confident it will work on current version 1.25(At the time of writing of course). These steps will also work for other Kubernetes solutions.
These are the critical issues that I found to be recurring with microk8s and frankly other kubernetes solutions:
- Hostname has capital letters and underscores.
- IP FORWARDING error on every restart of the server.
- Memory Cgroups are not enabled error.
After searching and reviewing several blogs and discussions I stumbled upon this discussion on github. Particularly this comment ultimately helped resolve my persistent issue.
I would also like to credit this blog for helping further with my understanding of the issues. You can consider this as documentation of my understanding of the issues and steps taken to sort them out.
Here are the steps taken to solve these issues.
- Update the system repositories using the command:
# apt update
- Change the hostname of your server:
- # hostnamectl set-hostname example.com
- # echo ‘192.168.0.30 example.com’ >> /etc/hosts ::: Change for multiple nodes if you have them.
- Load the necessary kernel modules.
- # modprobe br_netfilter
- # modprobe overlay
- Add these two modules on the modules file to ensure they are loaded on reboot : /etc/modules-load.d/k8s-modules.conf
- Enable IP FORWARDING.
cat << EOF | tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
read values from all system directories
sysctl --system
Enable Memory Cgroups:
This was the most persistent issue I faced, in case of any issues there is an email at the bottom for you to reach out incase of any issues. NOW lets get on with it.
Add the following values to the file /etc/default/grub
cgroup_enable=memory cgroup_memory=1 systemd.unified_cgroup_hierarchy=0
Update your grub and initramfs. Using:
# update-initramfs -u
# update-grub
REBOOT the server at this time to ensure the changes are loaded.
- Install Microk8s now.
- snap install microk8s –classic –channel=1.19
- sudo usermod -a -G microk8s $USER
- sudo chown -f -R $USER ~/.kube
- su – $USER
- alias kubectl=’microk8s kubectl’
- microk8s enable dns storage dashboard
- microk8s stop
- microk8s start
That’s it. It should be working now. Check the status using microk8s status