local kubernetes clusters

For this article we’ll dig into some of the options for Local Kubernetes Clusters if you are developing on a Mac.  When doing microservices development, eventually you will want to start to test integrated services together. And there are several options available to run these tests:

  • Dedicated Clusters – Larger teams typically have dev environments and you can either run lots of little clusters or a big cluster with lots of namespaces in them. Running clusters 24/7 costs real money that can add up quickly. Also if you opt for big clusters with namespaces per developer, this is still not a good reflection of staging or production.
  • Docker Compose – This is an old standby and one we still use for certain workloads. You can quickly spin up a chain of images and network them together. One big drawback I find to using docker compose is that the manifests are not used in my staging and production clusters. This ends up being work only for the developer desktop.
  • Local Kubernetes Cluster – With a local cluster you can use the exact same manifests that are used in staging and production. Of course you need local hardware that can support the load, but the infrastructure requirements for this have come way down.

Tests were conducted on a 2019 MacBook Pro (Big Sur).

$ kubectx
docker-desktop
microk8s
minikube
rancher-desktop

Minikube

I’m not embarrassed to say that I cut my teeth on minikube. This is the recommended path for onboarding into Kubernetes and has a ton of benefits:

  • Much of the standard Kubernetes documentation applies to minikube
  • With over 20K stars on GitHub it is one of the most popular repos out there and is incredibly active
  • It runs a VM that with a single node cluster, and you can swap out the VM if you want to use a different engine

Source: GitHub minikube

Microk8s

Several years ago Canonical released microk8s, their own distribution of Kubernetes. It is available directly into Ubuntu through snap. Because it is designed for running in Linux, this may be a good choice if you prefer to interact with everything over the command-line. There are tons of built-in commands and features, and it also has the ability to automatically pull in lots of other open source projects.

  • It is built right into Ubuntu which is one of the most popular Linux distros, but it can also be deployed on Mac through brew
  • On a Mac it will spin up a VM using Multipass that runs ubuntu with microk8s inside
  • Microk8s includes a bunch of standard add-ons for instance if you want to test out a service mesh or particular kind of ingress
  • The instructions all assume you type microk8s before your kubectl commands, so you’ll want to add the context to your config instead

Rancher Desktop

As a new entrant to the local Kubernetes cluster, Rancher Desktop takes a completely different approach. Instead of Kubernetes, it spins up a thin k3s cluster under the hood. Rancher has packaged this tool as an electron app. It runs a thin VM and images are maintained using KIM (also an experimental project).

  • Easily switch between different versions of Kubernetes with a simple drop-down
  • Built-in UI for doing things like port-forwarding with a single click
  • It uses a surprisingly small amount of resources for an app built on top of electron
  • At the time of this article it is still in alpha version, so expect more things to change over time

Source: Ken’s Incredible MacBook Pro

Docker Desktop for Mac

If you are doing development on a Mac and dealing with Dockerfiles, chances are you have Docker Desktop deployed. This is a closed source project, although you can open issues on GitHub. This is a very active project, docker pushes out updates regularly. One of the built-in features of Docker Desktop is that you can turn on the included Kubernetes cluster. This works in a unique way:

  • It does not use a VM but deploys docker-in-docker across a set of nodes running as docker images themselves which is neat
  • You can run your regular docker ps command to see things that are running inside the cluster
  • Docker recently changed their policy that you must update to new versions unless on a paid plan, so this may force an unexpected upgrade
  • It is not as easy to switch between Kubernetes distributions, you must “reset” your cluster in Docker Desktop to allow an upgrade

Source: Docker Desktop Documentation

Summary

Fortunately there are still a ton of options for Kubernetes local development in 2021. Hopefully this inspires you to run some test workloads on a new platform as well.

Speedscale helps developers release with confidence by automatically generating integration tests and environments. This is done by collecting API calls to understand the environment an application encounters in production and replaying the calls in non-prod. If you would like more information, schedule a demo today!

Longer-Log

Stress test your APIs with real world scenarios.  Collect and replay traffic without scripting.

Newsletter Signup