Skip to main content

Kubernetes Idle Cost: What It Is and How to Eliminate It

· 8 min read

Idle workloads are the silent budget killer in Kubernetes. They consume node capacity, inflate your cloud bill, and deliver exactly zero value. Here's how to find and eliminate them.

What Counts as "Idle" in Kubernetes?​

Not every underutilized workload is idle. A pod running at 5% CPU might be a legitimate low-traffic service waiting for requests. The distinction matters because the remediation is different:

  • Idle: a workload that serves no traffic, processes no jobs, and has no functional purpose. It should be deleted or scaled to zero.
  • Underutilized: a workload that does real work but has far more capacity than it needs. It should be right-sized (see our previous post on right-sizing).

In practice, "idle" falls into several categories:

CategoryExampleTypical Cause
Forgotten stagingstaging-api-v2 still running after v3 shippedNo cleanup process
Orphaned deploymentsCI/CD created a preview environment that was never torn downMissing TTL or garbage collection
Dev workloads in prodA developer's debug pod left runningNo namespace isolation
Unused infrastructureA Redis cluster provisioned for a feature that was cancelledOver-eager provisioning
Always-on cronjobsA CronJob pod that runs for 30 seconds per hour but keeps a warm pod 24/7Misconfigured concurrencyPolicy or suspend

How Much Does Idle Cost Actually Cost?​

The answer depends on how much of your cluster capacity is consumed by idle workloads. Industry data suggests the number is significant:

  • CNCF FinOps Survey 2025: 31% of Kubernetes spend is waste, with idle resources as the leading contributor.
  • Datadog State of Containers: 20-30% of running containers show near-zero CPU utilization over 7-day windows.

Let's model a concrete example. A mid-size cluster running 200 pods on AWS EKS:

CountAvg CPU RequestAvg Memory Request
Active pods150500m1 GiB
Idle pods50500m1 GiB

The idle pods reserve:

  • CPU: 50 * 0.5 cores = 25 cores
  • Memory: 50 * 1 GiB = 50 GiB

On m7i.xlarge instances ($0.1008/hr, 4 vCPU, 16 GiB), those idle reservations require approximately 7 extra nodes:

Monthly cost of idle pods: 7 nodes * $0.1008/hr * 730 hrs = ~$515/month = ~$6,180/year

And that's a modest example. Large organizations with hundreds of namespaces routinely discover $50K-$100K/year in idle workloads.

Step 1: Find Idle Pods​

The quickest way to surface idle pods is to compare CPU usage against requests over a meaningful time window. A pod that averages less than 1% of its CPU request over 7 days is almost certainly idle.

Using kubectl and metrics-server:

# Get pods sorted by CPU usage (ascending = idle first)
kubectl top pods -A --sort-by=cpu | head -20

# Example output:
# NAMESPACE NAME CPU(cores) MEMORY(bytes)
# staging preview-api-pr-847-7d8f9c-x2k4p 0m 12Mi
# staging preview-api-pr-832-5c7d8e-k3j7p 0m 11Mi
# default debug-shell-hakob-9f1e2d-r8m2n 1m 45Mi
# qa load-test-runner-6b5c4d-j9k2p 1m 128Mi

Pods showing 0m or 1m CPU usage are strong idle candidates. But kubectl top only shows a snapshot. For a definitive verdict, you need historical data.

Using Prometheus (if installed):

# Pods averaging < 1% CPU request utilization over 7 days
(
avg_over_time(
rate(container_cpu_usage_seconds_total{container!="POD",container!=""}[5m])[7d:]
)
/
kube_pod_container_resource_requests{resource="cpu"}
) < 0.01

This query identifies pods where average CPU usage is less than 1% of what they requested — a reliable signal for idle workloads.

Using network traffic as a secondary signal:

# Pods with near-zero network I/O over 7 days (likely not serving traffic)
sum by (pod, namespace) (
rate(container_network_receive_bytes_total[7d])
+ rate(container_network_transmit_bytes_total[7d])
) < 100 # less than 100 bytes/sec average

Combining CPU and network signals gives you high confidence. A pod with near-zero CPU and near-zero network activity is idle.

Step 2: Find Idle Namespaces​

Sometimes the problem isn't individual pods — it's entire namespaces that should no longer exist.

# List namespaces with their pod count and total CPU usage
for ns in $(kubectl get ns -o jsonpath='{.items[*].metadata.name}'); do
pods=$(kubectl get pods -n "$ns" --no-headers 2>/dev/null | wc -l)
cpu=$(kubectl top pods -n "$ns" --no-headers 2>/dev/null | \
awk '{sum += $2} END {printf "%.0f", sum}')
echo "$ns: $pods pods, ${cpu:-0}m CPU"
done | sort -t, -k2 -n

Common patterns to look for:

  • preview-*, pr-*, feat-* namespaces: CI/CD preview environments that weren't cleaned up.
  • staging-* with dates in the name: Time-stamped staging deployments from weeks or months ago.
  • Namespaces with 0 pods: Namespace exists but everything inside was already deleted (just the namespace shell remains).

Step 3: Find Idle Nodes​

Cluster Autoscaler should handle idle nodes automatically, but it often doesn't — especially with node affinity rules, PodDisruptionBudgets, or system pods that prevent scale-down.

# Nodes with low allocation (< 20% of allocatable CPU requested)
kubectl describe nodes | grep -A 5 "Allocated resources" | \
grep -E "cpu|Name:" | paste - - | \
awk '{print $2, $4}' | sort -k2 -n

With Prometheus:

# Nodes where allocated CPU is < 20% of allocatable
(
sum by (node) (kube_pod_container_resource_requests{resource="cpu"})
/
kube_node_status_allocatable{resource="cpu"}
) < 0.20

Nodes below 20% allocation are candidates for consolidation. If the Cluster Autoscaler isn't draining them, check for:

  • System-critical pods with PodDisruptionBudget preventing eviction
  • Node affinity or taints that lock specific pods to specific nodes
  • Local storage volumes (PVCs with local-path provisioner)

Step 4: Eliminate Idle Workloads​

Once you've identified idle resources, the remediation depends on the type:

Delete Forgotten Workloads​

# Delete a specific idle deployment
kubectl delete deployment preview-api-pr-847 -n staging

# Delete an entire stale namespace
kubectl delete namespace preview-pr-847

# Bulk delete preview namespaces older than 7 days
kubectl get ns -o json | jq -r '.items[] |
select(.metadata.name | startswith("preview-")) |
select(
(.metadata.creationTimestamp | fromdateiso8601) < (now - 604800)
) | .metadata.name' | xargs -I{} kubectl delete ns {}

Scale to Zero (Instead of Delete)​

If you're not sure whether a workload is truly idle, scale it to zero first. This frees all resources but keeps the deployment definition intact for easy restoration:

# Scale to zero
kubectl scale deployment staging-api-v2 -n staging --replicas=0

# Restore later if needed
kubectl scale deployment staging-api-v2 -n staging --replicas=2

Automate Cleanup with TTLs​

Prevent future idle workloads by adding TTL-based cleanup:

# Kubernetes 1.23+: TTL on Jobs
apiVersion: batch/v1
kind: Job
metadata:
name: data-migration
spec:
ttlSecondsAfterFinished: 3600 # Delete 1 hour after completion
template:
spec:
containers:
- name: migrate
image: myapp/migrate:latest
restartPolicy: Never

For preview environments, implement namespace-level TTLs using a controller like kube-janitor or a simple CronJob:

apiVersion: batch/v1
kind: CronJob
metadata:
name: cleanup-stale-previews
namespace: kube-system
spec:
schedule: "0 2 * * *" # Run daily at 2 AM
jobTemplate:
spec:
template:
spec:
serviceAccountName: namespace-cleaner
containers:
- name: cleaner
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
for ns in $(kubectl get ns -l purpose=preview \
-o jsonpath='{.items[?(@.metadata.creationTimestamp < "'"$(date -d '-7 days' -u +%Y-%m-%dT%H:%M:%SZ)"'")].metadata.name}'); do
echo "Deleting stale preview namespace: $ns"
kubectl delete ns "$ns"
done
restartPolicy: OnFailure

Set Up Idle Detection Rules​

Rather than manually hunting for idle workloads, codify your idle detection criteria as rules that run continuously.

A YAML-based rules engine (like the one in K8Cost) lets you define idle detection thresholds declaratively:

# Example idle detection rule
- id: idle-deployment
name: "Idle Deployment Detected"
description: "Deployment has near-zero CPU usage for 7+ days"
severity: warning
category: idle
conditions:
- metric: cpu_utilization_avg_7d
operator: less_than
value: 0.01
- metric: network_receive_bytes_avg_7d
operator: less_than
value: 100
remediation: |
Scale the deployment to 0 replicas or delete it entirely.
Verify with the owning team before deletion.

Step 5: Prevent Idle Workloads from Recurring​

Detection and cleanup are reactive. To truly solve the problem, you need guardrails:

  1. Label everything with an owner. Require a team or owner label on all deployments. When something goes idle, you know who to ask.

  2. Enforce namespace quotas. Set ResourceQuota on non-production namespaces to limit total CPU/memory. Teams that hit their quota will clean up idle workloads themselves.

  3. Require expiry annotations on non-production workloads. A simple expires-at: 2026-04-11 annotation, enforced by a webhook or CronJob, prevents preview environments from lingering indefinitely.

  4. Review cost reports weekly. A 5-minute weekly scan of your top idle workloads catches problems before they compound. Tools like K8Cost surface these automatically in the Waste Analysis dashboard.

  5. Track idle cost as a metric. Add idle cost to your FinOps dashboard alongside total spend. When teams see "30% of your namespace cost is idle," behavior changes.

Key Takeaways​

  • Idle workloads waste 20-30% of typical Kubernetes cluster spend.
  • "Idle" means zero useful work — distinguish from "underutilized" which needs right-sizing instead.
  • Combine CPU and network signals for high-confidence idle detection.
  • Scale to zero before deleting if you're uncertain.
  • Automate cleanup with TTLs, CronJobs, and namespace-level policies.
  • The best long-term fix is prevention: ownership labels, quotas, and expiry annotations.

Idle cost is the lowest-hanging fruit in Kubernetes cost optimization. Unlike right-sizing (which requires careful analysis and testing), eliminating truly idle workloads is pure savings with zero risk to production.