I am using jq to get some data in desired format, complete json data of a pod is pasted here https://pastebin.com/UMJA7xd5. This data is one of the pod in json format. I am going to run it on all pods, so that I can list the info like,
Based on number of containers in a pod. Number of containers in pods are random, some pods have 1 or some have upto 5 containers.
I am able to create upto here.
oc get po -o json | jq -j '.items | "\(.metadata.name), \(.spec.containers | .name +" , "+ .resources.limits.cpu +" , "+ .resources.limits.memory)\n" '
which give me output like below:-
kafka-0, kafka , 16 , 16Gi kafka-0, filebeat , 2 , 256Mi
In above example data, printing data of two container for a single pod kafka-0. kafka pod have two container so producing two line.
kafka-0, kafka , 16 , 16Gi, filebeat , 2 , 256Mi
I am new to jq and tried a lot of option, but could not succeed, might be doing something wrong. In this value of container are varying, so could not join these lines.