Skip to content

Instantly share code, notes, and snippets.

@juliangroen
Last active January 10, 2023 20:28
Show Gist options
  • Save juliangroen/6b3f4ad7ffa01d6b3d269bf67741c1d5 to your computer and use it in GitHub Desktop.
Save juliangroen/6b3f4ad7ffa01d6b3d269bf67741c1d5 to your computer and use it in GitHub Desktop.
CKA Notes

Certified Kubernetes Administrator

kubectl notes

jsonpath filtering/searching/etc

  • syntax is similar to jq selectors
  • jsonpath root is represented by a $ but it not required.
  • when the output of a kubectl command is a list of items .items[*] must be used first.

Examples

best practice to surround with '{}'
  • '{.status.podIP}'
  • .status.podIP
reference to the root object ($) does not need to be provided
  • '{$.status.podIP}'
  • '{.status.podIP}'
sorting the results of a command
--sort-by='{.status.podIP}'
when using jsonpath as the output parameter on a command that returns a list
-o jsonpath='{.items[*].status.podIP}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment