☸️
DevOps

Kubectl Cheat Sheet

Common kubectl commands quick reference

kubectl get pods -A

All pods in all namespaces

kubectl describe pod <name>

Pod events and status

kubectl logs <pod> -f

Stream pod logs

kubectl apply -f .

Apply manifests in folder

kubectl delete -f deployment.yml

Delete resources from file

kubectl exec -it <pod> -- /bin/sh

Shell into pod

kubectl port-forward svc/<name> 8080:80

Forward local port to service

kubectl get events --sort-by=.lastTimestamp

Recent cluster events

kubectl rollout restart deployment/<name>

Restart deployment

kubectl top pods

Pod CPU/memory usage