Table of Content

Launch multi node k8s cluster using minikube on macOS

The minikube is single node cluster tool for test/dev purpose.
The demand from community asked multi nodes cluster for long time, finally this experimental feature comes out, it seems working well so far.

install minikube on macOS

It is easy to install minikube on macOS,

$ brew install minikube

install kubectl on macOS

There are two options to run kubectl for minikube, build in ‘minikube kubectl’ or separately to install kubectl,

$ brew install kubectl

start minikube cluster on macOS

start a single node cluster with default parameters,

$ minikube start

start a two nodes cluster with 2G memory each,

$ minikube start -n 2 --memory=2g

Here is example log,

😄  minikube v1.11.0 on Darwin 10.15.5
✨  Automatically selected the hyperkit driver. Other choices: virtualbox, vmwarefusion
👍  Starting control plane node minikube in cluster minikube
🔥  Creating hyperkit VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.18.3 on Docker 19.03.8 ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: default-storageclass, storage-provisioner

❗  Multi-node clusters are currently experimental and might exhibit unintended behavior.
📘  To track progress on multi-node clusters, see https://github.com/kubernetes/minikube/issues/7538.

👍  Starting node minikube-m02 in cluster minikube
🔥  Creating hyperkit VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
🌐  Found network options:
    ▪ NO_PROXY=192.168.64.9
🐳  Preparing Kubernetes v1.18.3 on Docker 19.03.8 ...
    ▪ env NO_PROXY=192.168.64.9
🏄  Done! kubectl is now configured to use "minikube"

❗  /usr/local/bin/kubectl is version 1.21.0, which may be incompatible with Kubernetes 1.18.3.
💡  You can also use 'minikube kubectl -- get pods' to invoke a matching version

check minikube cluster status

From status we can see first minikube as Control Plane or master node, 2nd minikube-m02 as worker node, it looks great.

$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

minikube-m02
type: Worker
host: Running
kubelet: Running

stop minikube cluster on macOS

stop minikube cluster

$ minikube stop

$ minikube status
minikube
type: Control Plane
host: Stopped
kubelet: Stopped
apiserver: Stopped
kubeconfig: Stopped

minikube-m02
type: Worker
host: Stopped
kubelet: Stopped

check minikube cluster with kubectl

$ kubectl get node 
NAME           STATUS   ROLES    AGE   VERSION
minikube       Ready    master   49s   v1.18.3
minikube-m02   Ready       15s   v1.18.3

deploy on minikube cluster

$ kubectl create deploy web-deploy --image=nginx --replicas=5 --dry-run=client -o yaml > web-deploy.yaml 

$ kubectl apply -f web-deploy.yaml
deployment.apps/web-deploy created

$ kubectl get pode -o wide
NAME                          READY   STATUS              RESTARTS   AGE   IP       NODE           NOMINATED NODE   READINESS GATES
web-deploy-7744d4866f-c9bk2   0/1     ContainerCreating   0          11s      minikube-m02              
web-deploy-7744d4866f-fzb7z   0/1     ContainerCreating   0          11s      minikube-m02              
web-deploy-7744d4866f-gp8d5   0/1     ContainerCreating   0          11s      minikube-m02              
web-deploy-7744d4866f-jfb2d   0/1     ContainerCreating   0          11s      minikube-m02              
web-deploy-7744d4866f-jvbl8   0/1     ContainerCreating   0          11s      minikube-m02              

scale up deployment

$ kubectl scale deployment web-deploy --replicas=10
deployment.apps/web-deploy scaled

$ kubectl get pod -o wide
NAME                          READY   STATUS    RESTARTS   AGE     IP           NODE           NOMINATED NODE   READINESS GATES
web-deploy-7744d4866f-4tc6z   1/1     Running   0          106s    10.244.1.8   minikube-m02              
web-deploy-7744d4866f-9pn9m   1/1     Running   0          106s    10.244.1.7   minikube-m02              
web-deploy-7744d4866f-c9bk2   1/1     Running   0          2m36s   10.244.1.4   minikube-m02              
web-deploy-7744d4866f-d5k28   1/1     Running   0          106s    10.244.1.9   minikube-m02              
web-deploy-7744d4866f-fzb7z   1/1     Running   0          2m36s   10.244.1.5   minikube-m02              
web-deploy-7744d4866f-gp8d5   1/1     Running   0          2m36s   10.244.1.2   minikube-m02              
web-deploy-7744d4866f-jfb2d   1/1     Running   0          2m36s   10.244.1.6   minikube-m02              
web-deploy-7744d4866f-jvbl8   1/1     Running   0          2m36s   10.244.1.3   minikube-m02              
web-deploy-7744d4866f-nxpql   1/1     Running   0          106s    10.244.0.3   minikube                  
web-deploy-7744d4866f-zsrgf   1/1     Running   0          106s    10.244.0.2   minikube                  

it deploys on two nodes, nice.