Cheatsheets
kubectl
Common Kubernetes commands for pods, deployments, networking, and contexts.
28 entries
Pods & workloads10
kubectl get pods -AList pods across all namespaces
kubectl get pods -o widePods with node & IP details
kubectl describe pod <name>Detailed pod info & events
kubectl logs -f <pod>Follow a pod's logs
kubectl logs <pod> -c <container> --previousPrevious container's logs
kubectl exec -it <pod> -- shOpen a shell in a pod
kubectl get deployList deployments
kubectl rollout restart deploy/<name>Restart a deployment
kubectl rollout undo deploy/<name>Roll back to the previous revision
kubectl scale deploy/<name> --replicas=3Scale a deployment
Apply & manage6
kubectl apply -f file.yamlCreate/update from a file
kubectl apply -k ./overlayApply a kustomize overlay
kubectl delete -f file.yamlDelete resources from a file
kubectl get <res> -o yamlPrint a resource as YAML
kubectl explain <res>Show a resource's schema docs
apiVersion: v1
kind: Pod
metadata:
name: demo
spec:
containers:
- name: app
image: nginxMinimal pod manifest
Networking & config6
kubectl get svcList services
kubectl port-forward svc/<name> 8080:80Forward a local port to a service
kubectl get ingressList ingresses
kubectl get cm,secretList config maps and secrets
kubectl create secret generic s --from-literal=k=vCreate a secret
kubectl get secret s -o jsonpath='{.data.k}' | base64 -dDecode a secret value
Contexts & debugging6
kubectl config get-contextsList configured contexts
kubectl config use-context <name>Switch the current context
kubectl config set-context --current --namespace=<ns>Set default namespace
kubectl top podPod CPU/memory usage
kubectl get events --sort-by=.lastTimestampRecent cluster events
kubectl debug -it <pod> --image=busyboxAttach an ephemeral debug container