In my minikube, I have 3 pods, 1 of the pods has 2 containers, so total of 4 containers. I want to get name of pod, namespace, and contianer image using jsonpath query, but it is failing.
$ k get pods
NAME READY STATUS RESTARTS AGE
busybox 1/1 Running 0 3d15h
log-app-dd9bfccf-58g6p 2/2 Running 0 3d22h
test-pod 1/1 Running 1 (4d1h ago) 6d3h
just to get name and namespace works:
$ kubectl get pods -o=jsonpath=“{.items[*][‘metadata.name’,‘metadata.namespace’]}”
busybox log-app-dd9bfccf-58g6p test-pod default default default
just to get the container image also works:
$ kubectl get pods -o=jsonpath=‘{.items[].spec.containers[].image}’
busybox busybox busybox nginx
But when I try to combine all the above in one command, it fails:
$ kubectl get pods -o=jsonpath=“{.items[][‘metadata.name’,‘metadata.namespace’,'spec.containers[].image’]}”
error: error parsing jsonpath {.items[][‘metadata.name’,‘metadata.namespace’,'spec.containers[].image’]}, invalid array index 'spec.containers[*