Kubernetes Cheat Sheet
Kubernetes Cheat Sheet
© Nic Wortel, Software Consultant & Trainer - Last updated on December 20, 2023 - Find more cheat sheets at https://nicwortel.nl/cheat-sheets
Edit resources Execute commands
Command Description Command Description
kubectl edit <resource> <name> Edit a resource in a text editor kubectl exec <pod> -- <command> Execute a command in a running pod
kubectl set image <resource> <name> kubectl exec -it <pod> -- sh Open a shell in a running pod
Update the image of a container in a pod
<container>=<image>
View logs
Set labels and annotations Command Description
Command Description
kubectl logs <pod> Print the logs for a pod
kubectl label <resource> <name>
Add a label to a resource kubectl logs -f <pod> Print the logs for a pod and keep streaming
<key>=<value>
kubectl annotate <resource> <name>
Add an annotation to a resource
<key>=<value> Resource usage
Command Description
Delete resources kubectl top node Show resource (CPU/memory) usage of nodes
Command Description kubectl top pod Show resource (CPU/memory) usage of pods
kubectl delete <resource> <name> Delete a particular resource
© Nic Wortel, Software Consultant & Trainer - Last updated on December 20, 2023 - Find more cheat sheets at https://nicwortel.nl/cheat-sheets