Kubectl tips and tricks

I find jmespath syntax a lot easier than json path or even jq. Eliminates a lot of quotes and braces etc. It’s also used by aws cli --query.

Try jp (often expression doesn’t even need quoting, not at my terminal can’t test the following):

kubectl get pods -o=json | jp items[].[metadata.name, metadata.namespace]

You likely have to install jp. See https://jmespath.org/ for details.

1 Like