320 x 50 Mobile Ad
Cheat Sheets

Kubernetes Cheat Sheet

Transform, format, and optimize your data instantly with this free client-side tool.

Cluster Information

kubectl cluster-info

Display addresses of the master and services

kubectl version

Print the client and server version information

kubectl get nodes

List all nodes in the cluster

kubectl describe node <node_name>

Show detailed information about a node

Pods

kubectl get pods

List all pods in the current namespace

kubectl get pods -A

List all pods in all namespaces

kubectl get pods -w

Watch pods for changes

kubectl describe pod <pod_name>

Show details of a specific pod

kubectl delete pod <pod_name>

Delete a pod

kubectl run <name> --image=<image>

Start a single instance of a pod

Deployments

kubectl get deployments

List deployments

kubectl describe deployment <name>

Show details of a deployment

kubectl create deployment <name> --image=<image>

Create a new deployment

kubectl scale deployment <name> --replicas=<count>

Scale a deployment

kubectl set image deployment/<name> <container>=<image>

Update the image of a deployment

kubectl rollout status deployment/<name>

Check the rollout status

kubectl rollout undo deployment/<name>

Rollback to the previous deployment version

Services

kubectl get services

List all services in the namespace

kubectl describe service <name>

Show details of a service

kubectl expose deployment <name> --port=<ext> --target-port=<int>

Expose a deployment as a service

kubectl delete service <name>

Delete a service

Namespaces

kubectl get namespaces

List all namespaces

kubectl create namespace <name>

Create a namespace

kubectl config set-context --current --namespace=<name>

Set the default namespace for the current context

kubectl delete namespace <name>

Delete a namespace (and all resources within it)

Troubleshooting

kubectl logs <pod_name>

Print the logs for a pod

kubectl logs -f <pod_name>

Follow the logs for a pod

kubectl logs <pod_name> -c <container_name>

Print the logs for a specific container in a pod

kubectl exec -it <pod_name> -- sh

Get an interactive shell on a running pod

kubectl top pod

Show metrics for all pods in the default namespace

kubectl top node

Show metrics for all nodes

Config & Secrets

kubectl get configmaps

List configmaps

kubectl create configmap <name> --from-literal=<key>=<value>

Create a configmap

kubectl get secrets

List secrets

kubectl create secret generic <name> --from-literal=<key>=<value>

Create a secret

Declarative Config

kubectl apply -f <file.yaml>

Apply a configuration file

kubectl delete -f <file.yaml>

Delete resources defined in a configuration file

Advanced

kubectl get events --sort-by='.metadata.creationTimestamp'

List recent cluster events sorted by time

kubectl exec -it <pod> -- /bin/sh

Open shell inside a running pod

kubectl port-forward svc/<service> 8080:80

Forward local port 8080 to service port 80

320 x 50 Mobile Ad

Frequently Asked Questions

Got questions? We've got answers.

The K8s Cheatsheet is a quick-reference guide that provides developers with the most essential and frequently used K8s commands, syntax, and snippets in one centralized place.
This reference is built for both beginners who are just learning K8s and need a quick syntax lookup, as well as seasoned professionals who need to jog their memory on complex commands.
You can use the real-time search bar at the top of the cheatsheet. Simply type a keyword (like &#39;delete&#39; or &#39;file&#39;) and the list will instantly filter to show only matching K8s commands.
Yes! Every command block features a one-click copy button. Just hover over the command and click the copy icon to instantly send the snippet to your clipboard.
The cheatsheet is divided into logical categories such as Basics, Network, Operations, and specific K8s features. You can click on the category filters at the top to isolate specific groups of commands.
Absolutely. This K8s reference guide is 100% free, requiring no sign-ups or subscriptions, and is always available when you need it.
While these are standard K8s operations, you should always understand what a command does before running it, especially if it involves system operations or destructive actions.
Yes, we have recently expanded this cheatsheet to include advanced snippets, best practices, and edge-case syntax that go beyond basic introductory commands.
ADVERTISEMENT
Boost Your Business Online