Reputation: 5027
In the reference docs, they say you can print the image of a container like so.
kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
However, when I try any command that has brackets, I get an error message and no output.
no matches found: custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
if I just specify something like .spec.containers
it will output the entire array similar to this:
[map[image:weaveworksplugins/scope-traffic-control:latest imagePullPolicy:Always name:weavescope-traffic-control-plugin resources:map[requests:map[cpu:100m]] securityContext:map[privileged:true procMount:Default] terminationMessagePath:/dev/termination-log terminationMessagePolicy:File volumeMounts:[map[mountPath:/var/run/docker.sock name:docker-sock] map[mountPath:/var/run/scope/plugins name:scope-plugins]
...
Kubectl version information
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T16:54:35Z", GoVersion:"go1.12.7", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:14:56Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Upvotes: 2
Views: 1071
Reputation: 54251
That's a shell (probably ZSH?) error message, not related to kubectl. You need to quote the string that contains the [
and ]
so they don't get interpreted as shell metachars.
kubectl get pod test-pod \
-o custom-columns='CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image'
Upvotes: 7