Skip to content

Instantly share code, notes, and snippets.

@lucasrenan
Created April 30, 2019 17:50
Show Gist options
  • Save lucasrenan/c686e204ed7fb8e52825de34bc437771 to your computer and use it in GitHub Desktop.
Save lucasrenan/c686e204ed7fb8e52825de34bc437771 to your computer and use it in GitHub Desktop.
Kubernetes get all pods/containers resources requests/limits
kubectl get pods --all-namespaces --sort-by='.metadata.name' -o jsonpath='{.items[*].spec.containers[*].resources.limits.memory}'
kubectl get pod --all-namespaces --sort-by='.metadata.name' -o json | jq -r '[.items[] | {pod_name: .metadata.name, containers: .spec.containers[] | [ {container_name: .name, memory_requested: .resources.requests.memory, cpu_requested: .resources.requests.cpu} ] }]'
@dberardo-com
Copy link

kubectl get pod --all-namespaces --sort-by='.metadata.name' -o json | jq -r '[.items[] | {pod_name: .metadata.name, containers: .spec.containers[] | [ {container_name: .name, memory_requested: .resources.requests.memory, cpu_requested: .resources.requests.cpu} ] }]' | jq 'sort_by(.containers[0].cpu_requested)'

@SergeiCherevko
Copy link

kubectl get pods --all-namespaces -o custom-columns='NAME:.metadata.name,CPU_REQ:spec.containers[].resources.requests.cpu,CPU_LIM:spec.containers[].resources.limits.cpu,MEMORY_REQ:spec.containers[].resources.requests.memory,MEM_LIM:spec.containers[].resources.limits.memory'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment