(01)Install
1curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd642sudo install minikube-linux-amd64 /usr/local/bin/minikube3minikube start --driver=dockerRun a local Kubernetes cluster on your laptop for development
If you're on Kubernetes 1.27 or older
If you're on Kubernetes 1.28
Alternative — team standard for Local Kubernetes
What is this?
Minikube runs a small Kubernetes cluster on your laptop for learning and testing.
Where to create or edit the main configuration — paths below match the setup steps.
~/.kube/configLocation: Updated by minikube start
Points kubectl at local Minikube cluster
Step 01
1curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd642sudo install minikube-linux-amd64 /usr/local/bin/minikube3minikube start --driver=dockerStep 02
1minikube start --cpus=4 --memory=8192 --driver=docker2minikube addons enable ingress3minikube addons enable metrics-server4minikube addons list1docker build -t myapp:local .2minikube image load myapp:local3kubectl create deployment myapp --image=myapp:local4kubectl expose deployment myapp --type=NodePort --port=80805minikube service myapp --urlStep 03
1minikube status2kubectl get nodesStep 04
1minikube start2minikube stop3minikube delete4minikube dashboard5minikube service my-svc --url6minikube image load myapp:local2 YAML templates for Minikube. Copy and deploy after setup.
2 ready-to-copy templates. Expand one, copy the YAML, then run the deploy commands.
deployment.yml
Deployment with resource requests/limits and local image
1apiVersion: apps/v12kind: Deployment3metadata:4 labels:5 app: api-deploy6 name: api-deploy7spec:8 replicas: 19 selector:10 matchLabels:11 app: api-deploy12 template:13 metadata:14 labels:15 app: api-deploy16 spec:17 containers:18 - image: api:local19 name: api20 imagePullPolicy: IfNotPresent21 ports:22 - containerPort: 300023 resources:24 limits:25 memory: "512Mi"26 cpu: "500m"27 requests:28 memory: "256Mi"29 cpu: "250m"services.yml
NodePort Service exposing the API on port 32000
1apiVersion: v12kind: Service3metadata:4 labels:5 app: api-deploy6 name: api-deploy-service7spec:8 type: NodePort9 selector:10 app: api-deploy11 ports:12 - port: 300013 protocol: TCP14 targetPort: 300015 nodePort: 32000Step 01
1# Build local image2docker build -t api:local .3 4# For Minikube / Kind — load image into cluster5minikube image load api:local6# OR: kind load docker-image api:local1kubectl apply -f deployment.yml2kubectl apply -f services.yml3kubectl get pods,svc4curl http://localhost:32000 # or minikube service api-deploy-service