Skip to content

Instantly share code, notes, and snippets.

@elmiko
Last active April 28, 2020 19:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmiko/45ae0fe1a006e37c23581709711f2508 to your computer and use it in GitHub Desktop.
Save elmiko/45ae0fe1a006e37c23581709711f2508 to your computer and use it in GitHub Desktop.
kubernetes command line incantations
% kubectl
# get all pods in cluster and show what node they are deployed on
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}' --all-namespaces
# get all pods on a node and show what namespace they are in
kubectl get pods -o=jsonpath='{range .items[?(@.spec.nodeName=="<Node ID>")]}{.metadata.name}{"\t"}{.metadata.namespace}{"\n"}' --all-namespaces
# get all machines and show their associated node
kubectl get machines -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.nodeRef.name}{"\n"}'
# get all machines and show their annotations
kubectl get machines -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.annotations}{"\n"}'
# show taints on all nodes
kubectl get nodes -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{range .spec.taints[*]} [{.effect}, {.key}]{"\n"}{end}{end}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment