Kubernetes Cheatsheet

Core kubectl commands to inspect, deploy, and debug workloads in minutes.

Contexts & Namespaces

Key / CodeDescription
kubectl config get-contextsList contexts.
kubectl config use-context <ctx>Switch context.
kubectl config set-context --current --namespace=devSet default namespace.

Workloads

Key / CodeDescription
kubectl get podsList pods.
kubectl get deployList deployments.
kubectl apply -f app.yamlApply manifest.
kubectl rollout status deploy/appCheck rollout status.
kubectl scale deploy/app --replicas=3Scale replicas.

Services & Ingress

Key / CodeDescription
kubectl get svcList services.
kubectl describe svc apiDescribe a service.
kubectl get ingressList ingresses.

Config & Secrets

Key / CodeDescription
kubectl get configmapList ConfigMaps.
kubectl create configmap app-config --from-file=./configCreate a ConfigMap.
kubectl get secretList Secrets.

Debugging

When things fail, focus on status, logs, and events.

kubectl describe pod <pod>
kubectl logs <pod>
kubectl logs <pod> -c <container>
kubectl get events --sort-by=.metadata.creationTimestamp
Knowledge is power.