Minikube Cheatsheet
Last Updated: 2024-08-23
Setup
# Install / Upgrade - macOS
$ brew install minikube kubectl
# Check docker version
$ docker --version
# Check minikube version
$ minikube version
# Check kubectl version
$ kubectl version
Lifecycle of a cluster
# Start a cluster
$ minikube start
# Start a cluster of a specific k8s version
$ minikube start --kubernetes-version=1.31.0
$ minikube start --kubernetes-version=latest
# Start with containerd instead of default (docker)
$ minikube start --container-runtime=containerd
# minikube can be deployed as a VM, a container, or bare-metal.
# Start with podman as driver instead of docker
$ minikube start --driver=podman
# Use VM for nodes (not supported on darwin/arm64)
$ minikube start --driver=kvm2
# Pause/unpause the cluster
$ minikube pause
$ minikube unpause
# Stop the cluster
$ minikube stop
# Delete the cluster
$ minikube delete
$ minikube delete --all
Manage the clusters
# List profiles (existing clusters)
$ minikube profile list
# List minikube addons
$ minikube addons list
# Enable / Disable an addon
$ minikube addons enable ADDON_NAME
$ minikube addons enable kubevirt
$ minikube addons disable ADDON_NAME
# Set default memory limit
$ minikube config set memory 9001
# Set default version
$ minikube config defaults kubernetes-version
# List all services
$ minikube service list
# Access the service in a web browser, e.g. open the dashboard
$ minikube service kubernetes-dashboard -n kubernetes-dashboard
# Or get the link to the dashbaord
$ minikube dashboard
Multiple Clusters
# Create another cluster with a different profile (p for profile)
$ minikube start -p anothercluster --kubernetes-version=v1.30.0
# Change active context, use kubectl
$ kubectl config get-contexts
$ kubectl config use-context CONTEXT_NAME
# Change active profile
$ minikube config set profile PROFILE_NAME
# Verify the active profile is correctly set
$ minikube profile list
Minikube config
$ cat ~/.minikube/profiles/PROFILE_NAME/config.json
$ cat ~/.minikube/machines/PROFILE_NAME/config.json
# If you used `set`, otherwise this is mostly empty
$ minikube config view
# Equivalent to
$ cat ~/.minikube/config/config.json
# Check CA cert, should be self-assigned (Issuer == Subject)
$ openssl x509 -noout -text -in ~/.minikube/ca.pem
# Check server certificate
$ openssl x509 -noout -text -in ~/.minikube/machines/server.pem
Explore the Node
# If driver=docker, find the container
$ docker ps
$ docker exec -it NAME bash
# Or use `minikube ssh`
# SSH to node of the active profile
$ minikube ssh
# SSH to node of the specified profile
$ minikube ssh -p PROFILE_NAME
# Check static pod confs
docker@minikube:~$ ls /etc/kubernetes/manifests
# Check addons
docker@minikube:~$ ls /etc/kubernetes/addons
# Check admin kubeconfig
docker@minikube:~$ sudo cat /etc/kubernetes/admin.conf
# Check CA cert
docker@minikube:~$ openssl x509 -noout -text -in /var/lib/minikube/certs/ca.crt
docker@minikube:~$ openssl x509 -noout -text -in /etc/ssl/certs/minikubeCA.pem
# Check running containers inside the cluster
# If --container-runtime=containerd (`docker ps` shows nothing)
docker@minikube:~$ sudo ctr -n k8s.io containers ls
# If --container-runtime=docker (`ctr` shows nothing)
docker@minikube:~$ docker ps
# Or verify container runtime by checking the Node
$ kubectl get node NODE_NAME -o yaml | grep containerRuntimeVersion