$devvkit learn --librarie minikube-guide
Minikube Guide
[kubernetes][local][devops][containers]
Container / K8s
Install
brew install minikube # Linux: curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube # Windows: choco install minikube
Minikube runs a single-node Kubernetes cluster locally. Unlike kind (which runs K8s in Docker containers), Minikube uses a VM or Docker driver for full K8s feature support including LoadBalancer services, PersistentVolumes, Ingress, and metrics-server.
Start with `minikube start --cpus=4 --memory=8g`. Enable addons: `minikube addons enable ingress`, `minikube addons enable metrics-server`. The dashboard (`minikube dashboard`) opens a web UI. Use `minikube tunnel` to expose LoadBalancer services.
Minikube supports profiles for multiple clusters. Cache images with `minikube cache add alpine:latest`. For CI, use --driver=none (bare-metal) or --driver=docker. GUI: Minikube dashboard, Lens, Octant.
Setup
Start cluster— Create local K8s.
minikube start minikube start --driver=docker minikube start --cpus=4 --memory=8192 minikube start --kubernetes-version=v1.30.0 minikube start -p dev-cluster
Cluster Management
Dashboard— Open web UI.
minikube dashboard minikube dashboard --url minikube status minikube stop minikube delete minikube delete --all
Image management— Build and load images.
eval $(minikube docker-env) docker build -t myapp:latest . minikube cache add alpine:latest minikube cache list docker tag myapp localhost:5000/myapp docker push localhost:5000/myapp
Addons
Addons— Enable features.
minikube addons list minikube addons enable ingress minikube addons enable metrics-server minikube addons enable dashboard minikube addons enable registry minikube addons enable metallb # Open addon UI: minikube addons open dashboard
Networking
LoadBalancer tunnel— Access LoadBalancer services.
# Terminal 1: minikube tunnel # Terminal 2: kubectl create deployment web --image=nginx kubectl expose deployment web --port=80 --type=LoadBalancer minikube service web minikube service web --url
Service access— Service URLs.
minikube service myservice --url minikube service list minikube service myservice kubectl port-forward service/myservice 8080:80 minikube ip
Troubleshooting
SSH into node— Debug the VM.
minikube ssh # Inside VM: docker ps journalctl -u kubelet minikube logs > minikube.log minikube logs --problems-only minikube cp /host/file /vm/file
Mount host directory— Share files with cluster.
# Background mount: minikube mount /host/path:/vm/path # Or on start: minikube start --mount --mount-string="/host/path:/vm/path"