Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
kubectl Cheat Sheet

Get a list of currently running Pod names:

$ kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'

SSH directly into a pod:

$ kubectl exec --namespace <namespace_name> -it <pod_name> -- bash

Multiple configs?

$ export KUBECONFIG=$PATH

Describe all contexts:

$ kubectl config get-contexts

Switching contexts:

$ kubectl config use-context gcloud-us-east1-k8s

List pods (all namespaces):

$ kubectl get pods -o json --all-namespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.