Alex Novik:
Hey guys I bet many has this question too.
How to get list of pods with names, which node it allocated to, and images without using jsonpath. It is possible! Check this out:
kubectl get pods -o custom-columns=PODNAME:.metadata.name,NODENAME:.spec.nodeName,IMAGE:.spec..image
controlplane $ kubectl get pods -o custom-columns=PODNAME:.metadata.name,NODENAME:.spec.nodeName,IMAGE:.spec..image
PODNAME NODENAME IMAGE
webserver-c9584bdf5-2blqt node01 nginx:1.19
webserver-c9584bdf5-2gtrq node01 nginx:1.19
webserver-c9584bdf5-4sjkx node01 nginx:1.19
webserver-c9584bdf5-4v5v6 node01 nginx:1.19
webserver-c9584bdf5-6xhth node01 nginx:1.19
webserver-c9584bdf5-6xwft node01 nginx:1.19
webserver-c9584bdf5-hhqhx node01 nginx:1.19
webserver-c9584bdf5-kz2t8 node01 nginx:1.19
webserver-c9584bdf5-ldg7z node01 nginx:1.19
webserver-c9584bdf5-mzhxx node01 nginx:1.19
webserver-c9584bdf5-vg7zz node01 nginx:1.19
webserver-c9584bdf5-vzm2z node01 nginx:1.19
webserver-c9584bdf5-xhxj7 node01 nginx:1.19
webserver-c9584bdf5-xxtl5 node01 nginx:1.19
webserver-c9584bdf5-zpf9j node01 nginx:1.19
If you want to save it to a file without headers then just add a parameter --no-headers
it is much easier to understand than jsonpath I think, it follows the same structure as YAML, and json
So in preparation of your custom output table, just get configuration using command:
kubectl get pods -oyaml or -ojson and follow parenthesis
Collumn names may have any name you want