Compare Kubernetes namespaces side by side: workloads, pod health, CPU, memory and storage
Some questions are about one namespace. Many are about several. Is staging shaped like production, or has it drifted? Which team's namespace reserves the most CPU, and which actually uses it? Why does tenant B have four times the pods of tenant A? Answering them with kubectl means running the same commands per namespace and lining the numbers up yourself.
Kubexer's Compare Namespaces view, a Pro feature, puts them in one table: a row per measure, a column per namespace.
How people do it today
for ns in staging production; do
echo "== $ns"
kubectl get deploy,sts,ds,pods -n $ns --no-headers | wc -l
kubectl top pods -n $ns --no-headers | awk '{c+=$2; m+=$3} END {print c, m}'
done
Then a resource quota describe for requests, and a spreadsheet if you want the numbers next to each other. It is doable and nobody enjoys it.
Opening a comparison
Go to Workbench → Compare Namespaces, or press Cmd/Ctrl+K and run "Go to Compare Namespaces". Use Select namespaces to pick two or more. Each one becomes a column. There is no fixed cap; compare two environments, or every tenant namespace at once.
The view takes a snapshot. For the namespaces you pick, Kubexer briefly watches just those namespaces, waits for the first full list and the first metrics sample, freezes the numbers and stops. Adding a namespace fetches only that one. The refresh button (Refetch all values) takes a fresh snapshot. This keeps the page light on large clusters, and means the numbers describe one moment, not a live stream.
What the table shows
Rows are grouped into sections:
- Workloads: counts of Deployments, StatefulSets, DaemonSets, ReplicaSets, Jobs, CronJobs and Pods.
- Pod health: Running, Pending, Failed, Succeeded, and Crash looping (pods with a container waiting in
CrashLoopBackOff). - CPU and Memory: total Requests and Limits across pod containers, current Usage, and Utilization, which is usage divided by requests.
- Services: the total, with badges for ClusterIP, NodePort, LoadBalancer and ExternalName counts.
- Networking & Config: Ingresses, ConfigMaps, Secrets, HPAs.
- Storage: PVCs and total requested storage.
In every row, an up arrow marks the highest value and a down arrow the lowest, so outliers stand out without reading every number.
Usage and utilization come from metrics-server. If it is not installed, those cells show a dash and the column carries a "no metrics" badge; everything else still works.
Four ways to use it
1. Is staging a fair copy of production?
Put staging and production side by side. Different Deployment counts mean something exists in one and not the other. A big gap in memory requests per pod means staging is not testing the sizing production runs with. Neither is necessarily wrong, but you should know.
2. Who reserves capacity without using it?
Select all tenant namespaces and read the Utilization rows. A namespace at 15% CPU utilization is requesting six times what it uses. On a cluster where pods are stuck Pending for lack of schedulable CPU, that reservation is the capacity you are missing. The fix is lower requests, not more nodes.
3. Where is the instability?
The Pod health rows show crash looping, pending and failed counts per namespace. A namespace with the down arrow on Running and the up arrow on Crash looping is where to look first.
4. Before and after a migration
Moving an app from one namespace to a new one? Compare the old and new namespace before cutting over: same workloads, same services, same ConfigMap and Secret counts, similar requests.
Reading the numbers correctly
A few details make the difference between a useful comparison and a misleading one:
- Utilization is against requests, not limits. 200% CPU utilization is possible and means pods are bursting well above what they reserved, which the scheduler does not know about. That is a sizing problem in the other direction.
- Pods without requests add usage but no requests, which pushes utilization up. If a namespace shows high utilization and low requests, check whether its pods set requests at all.
- Usage is a single sample. A batch namespace compared at an idle moment will look oversized. Take the snapshot when the workloads are doing their normal work, and refresh it at a busy time before drawing conclusions.
- ReplicaSet counts include old revisions kept for rollback, so a namespace with frequent deploys shows more ReplicaSets than Deployments. That is expected.
What it does not do
Compare Namespaces compares totals. It is worth being precise about that:
- It counts resources; it does not diff them by name or spec. It will tell you staging has 12 Deployments and production 14, not which two are missing. For that, open each namespace's Deployments list, or use search across namespaces.
- It covers the kinds listed above, not CRDs, ServiceAccounts, NetworkPolicies or RBAC.
- It compares namespaces within one cluster, not across clusters.
- It is a snapshot, refreshed on demand, and there is no export.
Try it
Compare Namespaces is part of Pro in Kubexer, and included in the free trial. Start with the two namespaces you most often wonder about. For more on reading requests against usage, see understanding Kubernetes resource usage.