Find Pods Missing Resource Limits
Identifies all Kubernetes pods across all namespaces that have containers missing CPU or memory resource limits.
Setup
- → kubectl configured with cluster access
- → jq installed
Cost per run
Free
The one-liner
$ kubectl get pods -A -o json | jq -r '.items[] | select(any(.spec.containers[]; .resources.limits.cpu == null or .resources.limits.memory == null)) | "\(.metadata.namespace)/\(.metadata.name)"' | sort -uWhat each stage does
- [01] kubectl
kubectl get pods -A -o jsonFetches all pods across all namespaces and outputs the raw data as a JSON object. - [02] jq
jq -r '.items[] | select(any(.spec.containers[]; .resources.limits.cpu == null o…Iterates through the pods and filters for those where any container lacks either CPU or memory limits. - [03] jq
"\(.metadata.namespace)/\(.metadata.name)"Formats the matched pods into a clean namespace/pod-name string. - [04] sort
sort -uSorts the resulting list alphabetically and removes any duplicate entries.
Expected output (sample)
default/frontend-deployment-6b7984c77-x9q2z default/redis-cache-0 kube-system/metrics-server-85c57975b4-p8j9k monitoring/grafana-78459485b-4m2w9
Caveats & tips
- Requires `get pods` RBAC permissions across all namespaces (`-A`), which might be restricted in multi-tenant clusters.
- Does not check initContainers or ephemeralContainers, which can also consume resources without limits.