DEV Community

Cover image for Installing A Local Kubernetes
Alex Robson
Alex Robson

Posted on

Installing A Local Kubernetes


There are good reasons to follow along and get a local Kubernetes cluster:

  1. learn more about containers and orchestration
  2. experimentation is a great way to learn
  3. 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.

What's Kubernetes?

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:

  1. Docker for Desktop
  2. microk8s
  3. minikube
  4. k3s


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.

My Environment

For this post, I chose my Windows desktop running the following:

  • Windows 10.0.19044.2364
  • WSL2
  • Debian GNU/Linux 11 (bullseye)
  • Kernel Linux

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.

Enable systemd

You can enable systemd by creating (or adding to) the file /etc/wsl.conf:

Enter fullscreen mode Exit fullscreen mode

You'll need to restart WSL after this:

  1. Close your WSL terminal window
  2. Run wsl.exe --shutdown from a PowerShell terminal
  3. Re-open your WSL terminal window

Install Snap

Now that systemd is up, install Snap with the following set of commands:

sudo apt update
sudo apt install snapd
Enter fullscreen mode Exit fullscreen mode

Get microk8s

To install microk8s:

sudo snap install microk8s --classic
Enter fullscreen mode Exit fullscreen mode

System Setup

I use zsh, so I needed to:

  1. add Snap's bin folder to my path
  2. add an alias for microk8s.

I edited my ~/.zshrc file to source the alias file and add Snap's bin folder to my path:

source ~/.zsh_aliases
Enter fullscreen mode Exit fullscreen mode

I created an alias file ~/.zsh_aliases and added the contents:

alias m8s'microk8s'
alias k8s='m8s kubectl'
Enter fullscreen mode Exit fullscreen mode

Finally, I sourced my changes back into the current console session with the following:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

To verify everything is working, issue the command:

k8s get nodes
Enter fullscreen mode Exit fullscreen mode

You should see something like the following:

computer-name   Ready    <none>   9h    v1.26.0
Enter fullscreen mode Exit fullscreen mode

Up Next

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.


Kubernetes on Windows with microk8s and wsl2

How To Enable systemd in WSL

Installing Snap on Debian

Further Reading

Smooth Sailing with Kubernetes

The Illustrated Children's Guide to Kubernetes

What is Kubernetes Architecture?

Top comments (1)

zerix profile image

kind or k3d is also a good choice.