kubectl Cheat Sheet

Every kubectl command in the library, on one page. Search, filter by category, or jump to a full command reference for detailed examples.

CommandSyntaxDescription
kubectl getkubectl get <resource> [-n <namespace>]Lists one or more resources of a given type.
kubectl describekubectl describe <resource> <name>Shows detailed information about a specific resource, including recent events — the first stop when debugging.
kubectl logskubectl logs [-f] <pod> [-c <container>]Prints the logs from a container in a pod.
kubectl execkubectl exec [-it] <pod> -- <command>Runs a command inside a running container in a pod.
kubectl applykubectl apply -f <file>Creates or updates resources to match a manifest file — the standard way to deploy declaratively.
kubectl deletekubectl delete <resource> <name> | kubectl delete -f <file>Deletes resources by name or manifest file.
kubectl rolloutkubectl rollout status|undo|history deployment/<name>Manages the rollout of a Deployment — checking status, viewing history, or rolling back.
kubectl scalekubectl scale deployment/<name> --replicas=<n>Changes the number of replicas for a Deployment, ReplicaSet, or StatefulSet.
kubectl port-forwardkubectl port-forward <pod> <local-port>:<pod-port>Forwards a local port to a port on a pod, useful for debugging a service without exposing it publicly.
kubectl configkubectl config get-contexts | use-context <name>Views or modifies kubeconfig — including switching between clusters and namespaces via contexts.