I want to print a list of all my pods along with cpu requirements in a column
pretty sure its something like kubectl get pods 'spec.containers[].resources.limits.cpu'
Can someone give the correct syntax
You can get the pods (in the default namespace) and their CPU Limit with the following command.
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[].resources.limits.cpu}{"\n"}{end}'
We use the JSONPath output with the -o=jsonpath
flag, and provide it with the data we want to extract.
You can find more details on using the JSONPath output at https://kubernetes.io/docs/reference/kubectl/jsonpath/
Can you try below commands. replace cpu with memory to get memory requests and limits as well
CPU Requests
--------------
kubectl get po --all-namespaces \
-o=jsonpath="{range .items[*]}{.metadata.namespace}:{.metadata.name}{'\n'}{range .spec.containers[*]} {.name}:{.resources.requests.cpu}{'\n'}{end}{'\n'}{end}"
CPU Limits
-----------
kubectl get po --all-namespaces \
-o=jsonpath="{range .items[*]}{.metadata.namespace}:{.metadata.name}{'\n'}{range .spec.containers[*]} {.name}:{.resources.limits.cpu}{'\n'}{end}{'\n'}{end}"