My kubectl Cheat Sheet

This is a small kubectl Cheat Sheet with the list of commands and settings I use, almost on a daily basis, when working with kubernetes.

Get version and cluster information

Get kubectl version

1kubectl --version

Get cluster information

1kubectl cluster-info

Check cluster nodes

1kubectl get nodes

Get running services

1kubectl get services -w --all-namespaces


List all available contexts

1kubectl config get-contexts

Get current context

1kubectl config current-context

Change the context

1kubectl config use-context [context name]



1kubectl apply -f [yaml definition file]

Get deployment definition

1kubectl get deployment [deployment name] -o yaml

Update the image of a deployment

1kubectl set image deployment/[deployment name] [container name]=[image tag]

Set autoscale for a deployment

1kubectl autoscale deployment [deployment name] --min=2 --max=5 --cpu-percent=80

Delete a deployment

1kubectl delete -f [yaml definition file]

Get secret definition

1kubectl get secret [secret name] -o yaml

Force delete a pod

1kubectl delete pod [pod name] --grace-period=0 --force


Read a pod’s log

1kubectl logs [pod name] -n [namespace name]


Install kubernetes dashboard

1kubectl apply -f

Hope it helps!

Microsoft MVP Global Summit 2018 Experience
Secure your Kubernetes services with NGINX ingress controller, tls and more.
comments powered by Disqus