How to setup a single node Kubernetes cluster on local environment for testing purpose?

Kubernetes is a production-grade, open-source platform that orchestrates the placement (scheduling) and execution of application containers within and across computer clusters.

In this post, I will demonstrate some options that we can use to self-provision a single-node k8s cluster, for exam practice or testing purposes, check it out!


Option 1: minikube

I used Macbook Air M2 (macOS Monterey), and going to use brew to install minikube.

Step 1: Installation

brew install minikube

Step 2: Start

minikube start

It will take a few minutes for package downloading and cluster provisioning. If you see this message "Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default", you’re good to go!

Step 3: Verification

[email protected] Downloads % kubectl cluster-info
Kubernetes control plane is running at
CoreDNS is running at
[email protected] Downloads % kubectl run nginx --image=nginx:alpine 
pod/nginx created
[email protected] Downloads % kubectl get po
nginx   1/1     Running   0          13s

You can also SSH to cluster node by using this command

[email protected] Downloads % minikube ssh
[email protected]:~$ sudo ls /etc/kubernetes/manifests/                    
etcd.yaml  kube-apiserver.yaml	kube-controller-manager.yaml  kube-scheduler.yaml

Reference: minikube start | minikube

Option 2: Docker for Desktop Kubernetes

With Docker for Desktop, it much more easier to provision a Kubernetes cluster as it part of Docker for Desktop, we just needed to enable it.

Step 1: Installation
Install Docker for Desktop: Install Docker Desktop on Mac | Docker Documentation

Step 2: Start
Enable Kubernetes cluster: Deploy on Kubernetes | Docker Documentation

  1. From the Docker Dashboard, select the Setting icon, or Preferences icon if you use a macOS.
  2. Select Kubernetes from the left sidebar.
  3. Next to Enable Kubernetes , select the checkbox.
  4. Select Apply & Restart to save the settings and then click Install to confirm.

Step 3: Verification

[email protected] ~ % kubectl cluster-info
Kubernetes control plane is running at https://kubernetes.docker.internal:6443
CoreDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
kubectl get po -n kube-system
NAME                                     READY   STATUS    RESTARTS           AGE
coredns-95db45d46-54v7m                  1/1     Running   3 (2d16h ago)      32d
coredns-95db45d46-wjvht                  1/1     Running   3 (2d16h ago)      32d
etcd-docker-desktop                      1/1     Running   3 (2d16h ago)      32d
kube-apiserver-docker-desktop            1/1     Running   3 (2d16h ago)      32d
kube-controller-manager-docker-desktop   1/1     Running   3 (2d16h ago)      32d
kube-proxy-jqp7j                         1/1     Running   3 (2d16h ago)      32d
kube-scheduler-docker-desktop            1/1     Running   3 (2d16h ago)      32d
storage-provisioner                      1/1     Running   3 (2d16h ago)      32d
vpnkit-controller                        1/1     Running   1360 (5m14s ago)   32d

Notes: if you have more than 1 cluster on local env (minikube and Docker for Desktop), you can switch the context by accessing the below menu:

Option 3: Kind

This option is quite complex compared to minikube and Docker for Desktop, please visit the official guidelines from Kind for detailed information!

Happy learning,