Skip to content

Instantly share code, notes, and snippets.

@madsonic
Last active March 25, 2020 14:14
Show Gist options
  • Save madsonic/5192ea63f43fa212308d7e68afeeb338 to your computer and use it in GitHub Desktop.
Save madsonic/5192ea63f43fa212308d7e68afeeb338 to your computer and use it in GitHub Desktop.
kubectl-jq
# conditional expr
# select(.metadata.name == "abc") single test
# select(.metadata.name|test("abc.")) regex test
# final pipe expr prints in defined json shape
k get deploy --all-namespaces -o json | \
jq '.items[] | select(.metadata.name|test("abc.") | not) | {"name":.metadata.name,"podSpec":.spec.template.spec}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment