Skip to content

Instantly share code, notes, and snippets.

@tuxerrante
Created August 25, 2023 10:58
Show Gist options
  • Save tuxerrante/896a07da51efcff8593a27474ae51666 to your computer and use it in GitHub Desktop.
Save tuxerrante/896a07da51efcff8593a27474ae51666 to your computer and use it in GitHub Desktop.
get all namespaces resourcequotas from kubernetes
# It could be improved to highlight quotas over 60%
# But that would require a major rework since quotas are already pre-formatted by kubectl by merging status hard/used numbers
kubectl get ns --no-headers -o=custom-columns=:.metadata.name |xargs -I {} bash -c "echo -e '\nNamespace {}'; kubectl get -n {} --no-headers resourcequotas" |sed -e "s|count/|\\n- |g" -e "s|cpu|\\n- cpu|g" -e "s|memory|\\n- memory|g" |sed "/^namespace-resource-quota/d" >/mnt/c/Users/alessandr
o.affinito/Downloads/dev-resource-quotas.log
"""
Namespace default
Namespace dev-xyz
- configmaps: 4/999,
- cronjobs.batch: 0/100,
- deployments.apps: 4/100,
- jobs.batch: 0/100,
- persistentvolumeclaims: 0/100,
- pods: 4/250,
- replicationcontrollers: 0/100,
- secrets: 28/500,
- services: 3/100,
- services.loadbalancers: 0/10,
- statefulsets.apps: 0/100,
- cpu: 800m/16,
- memory: 1212Mi/32Gi
Namespace dev-xyz
- configmaps: 5/999,
- cronjobs.batch: 1/100,
- deployments.apps: 3/100,
- jobs.batch: 3/100,
- persistentvolumeclaims: 1/100,
- pods: 8/250,
- replicationcontrollers: 0/100,
- secrets: 23/500,
- services: 4/100,
- services.loadbalancers: 0/10,
- statefulsets.apps: 0/100,
- cpu: 500m/16,
- memory: 1280Mi/32Gi
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment