I tried this:
k get po -n myns -o=custom-columns=NAME:.spec.containers.name,MEMREQ:.spec.containers.resources.requests.memory,MEMLIM:.spec.containers.resources.limits.memory,CPUREQ:.spec.containers.resources.requests.cpu,CPULIM:.spec.containers.resources.limits.cpu
but it returned me this:
NAME MEMREQ MEMLIM CPUREQ CPULIM
<none> <none> <none> <none> <none>
<none> <none> <none> <none> <none>
<none> <none> <none> <none> <none>
<none> <none> <none> <none> <none>
<none> <none> <none> <none> <none>
<none> <none> <none> <none> <none>
<none> <none> <none> <none> <none>
Note that containers
is a list, so you would have to either supply the index or *
for all containers.
Here is an example from my environment, you can tweak your rest of the command.
kubectl get po -o=custom-columns=NAME:.spec.containers[*].name
NAME
nginx
nginx
kubectl get po -o=custom-columns=NAME:.spec.containers.name
NAME
<none>
<none>
To visualize the structure, here is an example with one pod, notice that a list is returned in the output of this command:
kubectl get pod my-nginx-66b6c48dd5-gq6vd -o jsonpath='{.spec.containers}'
[{"image":"nginx:1.14.2","imagePullPolicy":"IfNotPresent","name":"nginx","ports":[{"containerPort":80,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","volumeMounts":[{"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount","name":"default-token-cbmr2","readOnly":true}]}]