Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Kubernetes Cheat Sheet

Cluster and context

kubectl cluster-info
kubectl get nodes
kubectl config get-contexts
kubectl config use-context minikube
kubectl get all -A

Apply and inspect

kubectl apply -f app.yaml
kubectl get pods -o wide
kubectl describe pod <name>
kubectl logs -f <pod> --previous
kubectl exec -it <pod> -- sh
kubectl delete -f app.yaml

Deployments

kubectl create deployment web --image=nginx --replicas=3
kubectl scale deploy web --replicas=5
kubectl set image deploy/web web=nginx:1.27
kubectl rollout status deploy/web
kubectl rollout undo deploy/web
kubectl autoscale deploy web --min=2 --max=10 --cpu-percent=70

Services and debugging

kubectl expose deploy web --port=80 --type=ClusterIP
kubectl port-forward svc/web 8080:80
kubectl get events --sort-by=.metadata.creationTimestamp
kubectl top pods
kubectl get pod <pod> -o yaml

Config

kubectl create configmap cfg --from-literal=LOG_LEVEL=info
kubectl create secret generic sec --from-env-file=.env
kubectl create namespace dev
kubectl get pods -n dev

Full Kubernetes documentation