There are good reasons to follow along and get a local Kubernetes cluster:
- learn more about containers and orchestration
- experimentation is a great way to learn
- gain new skills and understanding
I will be writing more about CI/CD tooling that targets Kubernetes, and starting with documenting how I created my local cluster makes what I'm writing about easier for others to reproduce.
Kubernetes is an Open Source container orchestration system. Kubernetes' API provides a uniform control layer for managing containerized services. There is a lot of great material available that explains what Kubernetes is. See
Further Reading at the end for some suggestions.
After five years managing physical servers, then another four years working with VM clusters, the value of Linux Containers(LXC) and their eventual productization as Docker appealed to me.
Three years of creating and evolving internal tooling to manage hosting and configuration of Dockerized microservices ended when I discovered Kubernetes in the fall of 2016.
At that time, I migrated a pricy Heroku deployment to a self-managed Kubernetes cluster in AWS that expanded our capabilities, reduced maintenance efforts, increased capacity, and slashed our hosting costs by more than half.
Today there are quite a few ways to get a Kubernetes experience on a local machine. Here are a few that I'm most familiar with and have tried at one point or another:
microk8s is Canonical's packaged Kubernetes cluster purpose-built for more straightforward installs. Like Rancher Lab's k3s, Canonical built microk8s for local development, edge computing, and IoT applications.
For this post, I chose my Windows desktop running the following:
- Windows 10.0.19044.2364
- WSL2 22.214.171.124
- Debian GNU/Linux 11 (bullseye)
- Kernel Linux 126.96.36.199-microsoft-standard-WSL2
Some of the steps I share are specific to my environment. You may have to adjust the approach to work for you if you're running a different Linux distribution or version.
My WSL Debian container required two changes before I could install microk8s. I needed to enable systemd and install Canonical's Snap package manager.
You can enable systemd by creating (or adding to) the file
You'll need to restart WSL after this:
- Close your WSL terminal window
wsl.exe --shutdownfrom a PowerShell terminal
- Re-open your WSL terminal window
Now that systemd is up, install Snap with the following set of commands:
sudo apt update
sudo apt install snapd
To install microk8s:
sudo snap install microk8s --classic
I use zsh, so I needed to:
- add Snap's bin folder to my path
- add an alias for microk8s.
I edited my
~/.zshrc file to source the alias file and add Snap's bin folder to my path:
I created an alias file
~/.zsh_aliases and added the contents:
alias k8s='m8s kubectl'
Finally, I sourced my changes back into the current console session with the following:
To verify everything is working, issue the command:
k8s get nodes
You should see something like the following:
NAME STATUS ROLES AGE VERSION
computer-name Ready <none> 9h v1.26.0
Now that I have a working cluster, the next thing I'll write about is to add some essential features like role based authentication (RBAC) and a dashboard.