Monday 10 January 2022

JQ vs jsonpath

Not sure why I'm not doing more with jsonpath but I do admire the elegance and simplicity of this: -

kubectl get service cluster-proxy -n default -o=jsonpath='{.spec.clusterIP}'

as compared to my default muscle memory using jq : -

kubectl get service cluster-proxy -n default --output JSON | jq -r .spec.clusterIP

The jsonpath alternate definitely requires fewer keystrokes AND doesn't require me to install jq 

Although, to be honest, I'm not going to stop using jq for all my other JSON wrangling ....


No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...