Skip to content

Instantly share code, notes, and snippets.

@mlsaito
Last active August 21, 2018 12:43
Show Gist options
  • Save mlsaito/399b63961e1fdfcb0c2427aa1b871d77 to your computer and use it in GitHub Desktop.
Save mlsaito/399b63961e1fdfcb0c2427aa1b871d77 to your computer and use it in GitHub Desktop.
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