← All cheatsheets

Containers

kubectl — the 14 commands that get you through 95% of kube work

## Context
`kubectl config get-contexts` — list
`kubectl config use-context name` — switch
`kubectl config current-context` — show

## Pods + workloads
`kubectl get pods` / `kubectl get pods -A` — current ns / all ns
`kubectl describe pod name` — details
`kubectl logs -f pod` — follow logs
`kubectl exec -it pod -- bash` — shell in
`kubectl get deployment` / `kubectl get svc` — deployments / services
`kubectl rollout restart deployment/name`
`kubectl scale deployment/name --replicas=3`

## Apply / debug
`kubectl apply -f file.yaml` — apply manifest
`kubectl delete -f file.yaml` — delete
`kubectl port-forward svc/name 8080:80` — local tunnel
`kubectl get events --sort-by='.lastTimestamp'` — recent events