| name | operating-k8s-local |
| description | | Use when this capability is needed. |
Operating K8s Local
Quick Start
minikube start --memory=8192 --cpus=4
minikube addons enable ingress
minikube addons enable metrics-server
eval $(minikube docker-env)
docker build -t myapp:local .
kubectl apply -f k8s/
Minikube Essentials
Cluster Management
minikube start
minikube start --memory=8192 --cpus=4
minikube start --driver=docker
minikube status
minikube stop
minikube delete
Multiple Clusters
minikube start -p my-cluster
minikube profile my-cluster
minikube profile list
Addons
minikube addons list
minikube addons enable ingress
minikube addons enable metrics-server
minikube addons enable dashboard
minikube addons enable storage-provisioner
Accessing Services
minikube service my-service --url
minikube tunnel
kubectl port-forward svc/my-service 8080:80
Using Local Docker Images
eval $(minikube docker-env)
docker build -t my-app:local .
eval $(minikube docker-env -u)
kubectl Essentials
Context Management
kubectl config current-context
kubectl config get-contexts
kubectl config use-context minikube
kubectl config set-context --current --namespace=my-ns
Getting Information
kubectl get pods
kubectl get pods -A
kubectl get pods -o wide
kubectl get all
kubectl describe pod my-pod
kubectl get events --sort-by='.lastTimestamp'
Logs
kubectl logs my-pod
kubectl logs my-pod -f
kubectl logs my-pod -c container
kubectl logs my-pod --previous
kubectl logs my-pod --tail=50
Creating Resources
kubectl apply -f manifest.yaml
kubectl create deployment nginx --image=nginx
kubectl create configmap my-config --from-literal=key=value
kubectl create secret generic my-secret --from-literal=password=secret
kubectl create deployment nginx --image=nginx --dry-run=client -o yaml
Modifying Resources
kubectl edit deployment my-deploy
kubectl scale deployment my-deploy --replicas=3
kubectl set image deployment/my-deploy container=image:v2
kubectl rollout restart deployment/my-deploy
Debugging
kubectl exec -it my-pod -- /bin/sh
kubectl exec my-pod -- env
kubectl port-forward pod/my-pod 8080:80
kubectl top pods
kubectl top nodes
Resource Manifests
Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deploy
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: main
image: my-app:local
imagePullPolicy: Never
ports:
- containerPort: 8000
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 5
Service
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: ClusterIP
selector:
app: my-app
ports:
- port: 80
targetPort: 8000
ConfigMap & Secret
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
data:
DATABASE_HOST: postgres
DATABASE_PORT: "5432"
---
apiVersion: v1
kind: Secret
metadata:
name: my-secret
type: Opaque
stringData:
password: mysecretpassword
Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
spec:
ingressClassName: nginx
rules:
- host: myapp.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
Local Development Workflow
minikube start --memory=8192 --cpus=4
minikube addons enable ingress
minikube addons enable metrics-server
eval $(minikube docker-env)
docker build -t myapp/api:local ./api
docker build -t myapp/web:local ./web
kubectl apply -f k8s/
minikube service myapp-web --url
echo "$(minikube ip) myapp.local" | sudo tee -a /etc/hosts
Debugging Quick Reference
kubectl describe pod my-pod
kubectl logs my-pod --previous
kubectl exec -it my-pod -- nslookup my-service
kubectl exec -it my-pod -- wget -qO- http://my-service:80
kubectl top pods
kubectl top nodes
Verification
Run: python scripts/verify.py
Related Skills
containerizing-applications - Docker and Helm charts
deploying-cloud-k8s - Cloud Kubernetes deployment
Converted and distributed by TomeVault — claim your Tome and manage your conversions.