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.
| Command | Syntax | Description | |
|---|---|---|---|
| kubectl get | kubectl get <resource> [-n <namespace>] | Lists one or more resources of a given type. | |
| kubectl describe | kubectl describe <resource> <name> | Shows detailed information about a specific resource, including recent events — the first stop when debugging. | |
| kubectl logs | kubectl logs [-f] <pod> [-c <container>] | Prints the logs from a container in a pod. | |
| kubectl exec | kubectl exec [-it] <pod> -- <command> | Runs a command inside a running container in a pod. | |
| kubectl apply | kubectl apply -f <file> | Creates or updates resources to match a manifest file — the standard way to deploy declaratively. | |
| kubectl delete | kubectl delete <resource> <name> | kubectl delete -f <file> | Deletes resources by name or manifest file. | |
| kubectl rollout | kubectl rollout status|undo|history deployment/<name> | Manages the rollout of a Deployment — checking status, viewing history, or rolling back. | |
| kubectl scale | kubectl scale deployment/<name> --replicas=<n> | Changes the number of replicas for a Deployment, ReplicaSet, or StatefulSet. | |
| kubectl port-forward | kubectl 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 config | kubectl config get-contexts | use-context <name> | Views or modifies kubeconfig — including switching between clusters and namespaces via contexts. |