Sub topic 6
Managing the cluster lifecycle
This chapter assumes you have Docker (or another supported runtime) installed and have created a cluster with kind or minikube, as in the previous two chapters. It covers the four lifecycle operations: create, list, stop, and delete. The two tools handle them differently, and the difference affects whether your work survives.
The lifecycle at a glance
A local cluster moves through a few states. kind has no stop command, so a kind cluster is either present or deleted. minikube can pause its node without destroying it.
Create and list
Both tools name the cluster so you can run several side by side.
kind create cluster --name dev
minikube start -p devkind prefixes the kubectl context with kind-, so the context is kind-dev. minikube uses the profile name as is, so the context is dev. To see what exists:
kind get clusters
minikube profile listkind get clusters prints only names. minikube profile list also shows the driver, runtime, Kubernetes version, and status.
Stop and start (minikube)
minikube keeps the cluster's state on disk, so you can free CPU and memory without losing your Deployments.
minikube stop -p dev
minikube start -p devOn the second start, minikube reuses the existing node and your resources are still there. Passing different settings such as --cpus to an existing profile usually has no effect, because the node was already created. Delete the profile to change them.
kind has no stop. kind nodes are Docker containers, so you can run docker stop dev-control-plane and docker start dev-control-plane. This sometimes works, but it is not supported. Node IP addresses can change after a restart and break the cluster. Treat kind clusters as disposable and recreate them.
Delete
kind delete cluster --name dev
minikube delete -p devDeletion removes the node containers or VM and all data inside them. Both commands also remove the matching entry from your kubeconfig. Running kind delete cluster without --name deletes the cluster named kind, not dev, so always pass the name.
Common errors
- Name already exists.
kind create cluster --name devfails ifdevexists. Delete it or choose another name. - Docker not running. Both tools report that they cannot reach the Docker daemon. Start Docker first.
- Stale resources after a failed start. Run the matching
deletecommand, then create again. - Forgetting that minikube profiles use resources while running. Run
minikube stopwhen you finish for the day.
Exercise
You ran minikube stop -p dev yesterday. Today you run minikube start -p dev. Are the Deployments you created still there? Would the same be true after kind delete cluster --name dev followed by kind create cluster --name dev?
Show answer
With minikube, yes. The stop only halts the node, and its state is kept on disk. With kind, no. Deleting the cluster removes the node containers and everything stored in them, so the new cluster starts empty.