4 Ways to Create a Kubernetes Cluster for Local Use
Four different tools for creating a Kubernetes cluster locally

In order to increase the Kubernetes experience for developers, a Kubernetes environment is required.
To do this, we can create a cluster on external on-premise servers or in the cloud. AWS, Google, or Azure offer very good solutions here. However, these variants are associated with increased costs or additional effort.
For many use cases, however, it is sufficient to create a local cluster. This is possible within a few seconds with the right tool. The creation is often very simple and available in a very short time. After we are done with our work, we can shut down the cluster very easily and all required resources are released again.
In this article I present 4 tools I use to create local clusters and evaluate certain aspects all the time.
kind
kind (Kubernetes-IN-Docker) is an open-source command line tool that uses Docker to run local Kubernetes environments. That means, every k8s node is bootstrapped as a Docker container.
This tool has a lot of features and is very lightweight.
Installation and Configuration
kind ist very comfortable and easy to use. To install kind on our local machine, we can follow the installation instructions.
On the one hand, we can create a local Kubernetes cluster with default settings using the following command:
kind create cluster --name my-cluster
On the other hand, we can create a config file that describes our cluster to follow the principle of Infrastructure of Code:
# kind.config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: k3s-cluster
nodes:
- role: control-plane
- role: worker
extraPortMappings:
- containerPort: 30950
hostPort: 80
labels:
tier: frontend
- role: worker
labels:
tier: backendTo create a cluster with a separate config file we need to run the following command:
kind create cluster --config=kind.config.yaml
After initialization of a cluster the kubeconfig will automatically be appended to the profile directory, so that we can simply run kubectl commands like kubectl get pods -A.
k3d
k3d is a community-driven project and a lightweight wrapper to run k3s in Docker. k3s is an excellent tool for running baremetal k8s clusters for things like home automation, IoT, or embedded applications. You can checkout one of my latest articles about k3s here:
k3d makes it very easy to run local Kubernetes clusters with single- or multi-nodes in Docker.
Installation and Configuration
To install k3d on our local machine, we can follow the installation instructions.
Just like with kind, we can create a local k8s cluster with a single command:
k3d cluster create mycluster
After initialization of a cluster the kubeconfig will automatically be appended to the profile directory, so that we can simply run kubectl commands like kubectl get nodes.
As with kind, we can create a config file that describes our cluster to follow the principle of Infrastructure of Code:
# k3d.config.yaml
apiVersion: k3d.io/v1alpha3
kind: Simple
name: k3d-cluster
servers: 1
agents: 2
image: rancher/k3s:v1.20.4-k3s1To create a cluster with a separate config file we need to run the following command:
k3d cluster create --config=k3d.config.yaml
After this we can simply run kubectl commands like kubectl get deployments -A.
Minikube
Minikube is the most famous tool in this list and runs a single-node Kubernetes cluster in a virtual machine (VM) on our local system’s hypervisor. By default, Minikube expects to use VirtualBox, but with a few extra steps it can also use a native hypervisor, like KVM on Linux, Hyper-V on Windows, or HyperKit and Hypervisor.framework on macOS.
Personally, Minikube was my first environment which I set up and configured Kubernetes to my own specifications in. The tool is super beginner friendly.
Installation and Configuration
Minikube, like the other tools, has a very clear documentation page where we can easily read how to set up the environment. Also edge cases like Proxies or VPN connections are described.
If we follow the instructions according to the personal operating system, we can easily start Minikube with the following command:
minikube start
Like the other tools, the kubeconfig will automatically be appended to the profile directory. If we already have kubectl installed, we can now use it to access our shiny new cluster: kubectl get nodesor kubectl get pods.
Alternatively, minikube can download the appropriate version of kubectl and we should be able to use it like this: minikube kubectl -- get pods -A.
MicroK8s
MicroK8s is a single package that enables developers to get a fully featured, conformant and secure Kubernetes system running in under 60 seconds. Designed for local development, IoT appliances, CI/CD, and use at the edge, MicroK8s is available as a snap and available on Linux, Windows and Mac.
In terms of feel, MicroK8s is a mix of Minikube and kind. MicroK8s will install a minimal, lightweight Kubernetes we can run and use on practically any machine. By default it is started with one node, but we can add as many as we like. It also has extensibility features like NFS storages, ingress, or different authentication strategies.
Installation and Configuration
Following the instructions, the commissioning of the local cluster appears very simple. It can be installed via a snap:
sudo snap install microk8s --classic --channel=1.25
MicroK8s creates a group to enable seamless usage of commands which require admin privilege. To add our current user to the group and gain access to the .kube caching directory, we need to run the following commands:
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
su - $USERMicroK8s bundles its own version of kubectl for accessing Kubernetes:
microk8s kubectl get nodes microk8s kubectl get services
MicroK8s uses a namespaced kubectl command to prevent conflicts with any existing installs of kubectl. If we do not have an existing install, it is easier to add an alias (append to ~/.bash_aliases) with alias kubectl=’microk8s kubectl’.
We can also add different add-ons like DNS storage, Prometheus Operator, or a metrics server. Here is a list of all the add-ons.
Conclusion
For my first personal local Kubernetes cluster I used Minikube on a dedicated server (1 CPU and 8GB RAM). Minikube is sufficient for the learning curve and covers all use cases for beginners. In this environment I deployed my first self-written applications and made them available via nodeports.
After that I gained a lot of experience using kind, because kind offers the possibility to use multiple nodes. With this I expanded my knowledge regarding DaemonSets, StatefulSets, etc.
I am currently running my own Kubernetes cluster with three on-premise servers created via k3s in a VPN. The control plane is a k3s server and the nodes are K3s agents.
My next challenge will be a Kubernetes cluster of cloud servers and on-premise servers. For this I will probably also use k3s. But let’s see.
Thanks for reading! Follow me on Medium, or Twitter, or Instagram, or subscribe here on Medium to read more about DevOps, Agile & Development Principles, Angular, and other useful stuff. Happy Coding! :)





