Tuesday 25 June 2024

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="{..image}"

which returns the image name(s) on the same line

Or we can do this: -

kubectl get deployment foobar --namespace snafu --output JSON | jq -r '.spec.template.spec.containers[].image'

which does much the same, although with each image on a separate line 'cos formatting

Alternatively, we can examine the pod: -

kubectl get pods --namespace snafu --selector app=foobar --output jsonpath="{..image}"

which, again, returns the image(s) on the same line, but for each pod in the deployment - which perhaps leads to duplication

For me, kubectl get deployment is simpler ...

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="{...