Local K8S cluster setup with Minikube on Mac OS

Local K8S cluster setup with Minikube on Mac OS
Photo by Venti Views / Unsplash

Introduction

Having a local K8S cluster is handy for container development. Minikube is one of my favorite tools for kubernetes development. It's stable and support quite a lot of features.

The environment of the setup:
- Mac OS 13.3.1
- minikube version: v1.31.2

The easiest way to install minikube is to use Homebrew

brew install minikube
minikube version

Minikube configuration

Let's configure some important settings of minikube cluster

Minikube driver

On Mac OS, a minikube cluster runs inside a container (docker driver) or a virtual machine (hyperkit driver)

💡
On MacOS, the docker driver is preferred
minikube config set driver docker

Container runtime

Kubernetes requires a container runtime to be installed.

minikube config set container-runtime containerd

Cluster resources allocation

# allocate 4Gi of RAM
minikube config set memory 4096

# allocate CPU used by minikube cluster (minimum 2)
minikube config set cpus 2

Up and running

minikube start

Let's get all the pods running in the cluster

kubectl get po -A

The output looks like this

NAMESPACE     NAME                               READY   STATUS    RESTARTS   AGE
kube-system   coredns-5d78c9869d-r5jff           1/1     Running   0          2m50s
kube-system   etcd-profile2                      1/1     Running   0          3m3s
kube-system   kindnet-4z6pt                      1/1     Running   0          2m50s
kube-system   kube-apiserver-profile2            1/1     Running   0          3m3s
kube-system   kube-controller-manager-profile2   1/1     Running   0          3m3s
kube-system   kube-proxy-j8mb7                   1/1     Running   0          2m50s
kube-system   kube-scheduler-profile2            1/1     Running   0          3m3s
kube-system   storage-provisioner                1/1     Running   0          3m

Tada! The minikube cluster is up and running 🫢

You can view our minikube cluster running as a container with docker stats command

CONTAINER ID   NAME         CPU %     MEM USAGE / LIMIT
d4b23bd088a5   minikube     11.91%    542.9MiB / 4GiB 
...