Cost and capacity
A cluster bills for what pods reserve, not what they use. Learn to attribute cost from requests and usage, find idle capacity, buy cheaper nodes safely and plan headroom for failure and growth.
Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.
Cloud bills arrive per node, per volume and per load balancer. Teams think in Deployments. The work of cost management is translating between the two, and the work of capacity planning is making sure there is room when a node, a zone or a launch day arrives.
Reconcile, in 6 scenes
Requests are the bill
The scheduler places pods by their resource requestsThe CPU and memory a container declares it needs. The scheduler reserves that much node capacity for it, whether or not it is used., so a node is full when the requests of its pods add up to its allocatable capacity (capacity minus what the kubelet reserves for the system and for eviction thresholds), even if the processes are idle. Nodes cost the same either way:
kubectl -n team-a top pods
NAME CPU(cores) MEMORY(bytes) api-6b584679b7-46lmz 1m 24Mi api-6b584679b7-gjtld 1m 24Mi api-6b584679b7-vtcvr 1m 24Mi
kubectl -n team-a get pods -o custom-columns=NAME:.metadata.name,CPU_REQ:.spec.containers[0].resources.requests.cpu,MEM_REQ:.spec.containers[0].resources.requests.memory
NAME CPU_REQ MEM_REQ api-6b584679b7-46lmz 500m 256Mi api-6b584679b7-gjtld 500m 256Mi api-6b584679b7-vtcvr 500m 256Mi
Each replica reserves 500 times the CPU it uses. Across three replicas, 1.5 cores of paid capacity sit idle and unavailable to anyone else.
Allocation tools
OpenCost, a CNCF project with an open specification, splits node cost among workloads: each container is charged for the larger of its request and its usage, priced per CPU-hour and GB-hour from the node’s price. Whatever is left of the node is reported as idle, and shared costs such as system namespaces are spread by a chosen rule. Kubecost, acquired by IBM in September 2024, builds on the same model; its 3.x releases install from the kubecost/kubecost chart (repository https://kubecost.github.io/kubecost) with global.clusterId set, while the cost-analyzer chart is the 2.x path.
Allocation needs a key. Label every namespace with its owning team and cost centre, and the tools can roll pods up to teams. Showback (reporting each team’s cost) usually comes before chargeback (billing it back).
Waste patterns
Oversized requests are the largest waste in most clusters. Requests set once from a guess are rarely lowered. The Vertical Pod Autoscaler in Off mode publishes recommendations without acting on them; its other modes are Initial, Recreate (the default), InPlaceOrRecreate and InPlace, and VPA 1.5.0 deprecated Auto.
Idle environments run all night and all weekend. Scaling dev and staging to zero outside working hours saves most of their cost; a Deployment at zero replicas uses no compute and no compute quota, though its objects stay in etcd and count toward object-count quotas such as count/deployments.apps. Tools such as GoKubeDownscaler, the maintained successor to kube-downscaler, do this by annotation. A hand-written CronJob needs its own ServiceAccount with a Role granting get, list and patch on deployments and deployments/scale, must record each Deployment’s replica count (in an annotation, for example) before scaling to zero so it can restore it, and should run a maintained kubectl image pinned by version or digest: Bitnami moved its versioned images to the unmaintained bitnamilegacy repository on August 28, 2025. In Kubernetes 1.37 the HPAScaleToZero feature is beta and on by default, so an HPA scaling on an object or external metric can set minReplicas: 0; one scaling only on CPU or memory still needs at least 1.
Orphaned resources outlive their workloads: PersistentVolumes with a Retain reclaim policy sitting Released after their claim was deleted, cloud disks nobody attached, and Services of type LoadBalancer, each holding a cloud load balancer that bills by the hour.
Cross-zone traffic costs money in most clouds. A Service with trafficDistribution: PreferSameZone keeps traffic in the client’s zone when local endpoints exist. The field is GA in Kubernetes 1.33 and the PreferSameZone value in 1.35; PreferClose is a deprecated alias, and the service.kubernetes.io/topology-mode: Auto annotation takes precedence when both are set.
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- name: http
port: 80
targetPort: 8080
trafficDistribution: PreferSameZone
Cheaper capacity
Spot (preemptible) nodes cost a fraction of on-demand and can be reclaimed with little notice. Workloads that run on them need several replicas spread across nodes and zones, PodDisruptionBudgets, and graceful shutdown that fits the notice period. Diversifying across many instance types makes a mass reclaim less likely. Arm nodes are often cheaper for the same work, provided every image is published as a multi-platform image index.
Karpenter, a SIG Autoscaling project with cloud-specific providers, provisions nodes to fit pending pods and consolidates them later. Its NodePool (karpenter.sh/v1) says which nodes it may create and points at a provider’s node class. A NodePool’s consolidation policy (WhenEmpty or WhenEmptyOrUnderutilized) decides when nodes are removed, its disruption budgets (10% of nodes by default) limit how many go at once, and the karpenter.sh/do-not-disrupt annotation exempts a pod.
Capacity planning
Headroom has two jobs: absorbing failure and absorbing growth.
For failure, plan N+1: the cluster must carry its load with one node gone, and in a multi-zone cluster with one zone gone. With three equal zones, losing one moves its load to the other two, so each zone can run at no more than two thirds of its capacity. Spread replicas with topology spread constraints so the loss is shared.
For growth, state the model. At 70% utilization and 10% compounding monthly growth, the cluster reaches 100% in ln(1/0.7) / ln(1.1), about 3.7 months; at 10 percentage points a month, it is 3 months; against a 70% planning ceiling, it is already out of runway.
CPU and memory are not the only limits. The kubelet caps pods per node (110 by default), pod networking consumes IP addresses from a fixed range, and cloud quotas cap nodes and node groups.
Guardrails
Each team’s namespace gets a ResourceQuota that caps its total requests and limits, and a LimitRange that fills in defaults for containers that state none. Without the defaults, a quota on requests.cpu makes the API server reject every pod that does not set one.
apiVersion: v1
kind: ResourceQuota
metadata:
name: team-a-compute
namespace: team-a
spec:
hard:
requests.cpu: "2"
requests.memory: 4Gi
limits.memory: 8Gi
services.loadbalancers: "1"
---
apiVersion: v1
kind: LimitRange
metadata:
name: team-a-defaults
namespace: team-a
spec:
limits:
- type: Container
defaultRequest:
cpu: 100m
memory: 128Mi
default:
memory: 256Mi
When a team hits its quota, the ReplicaSet controller reports it and the Deployment stops short:
kubectl -n team-a scale deployment api --replicas=5
deployment.apps/api scaled
kubectl -n team-a get events --field-selector reason=FailedCreate
LAST SEEN TYPE REASON OBJECT MESSAGE 0s Warning FailedCreate replicaset/api-6b584679b7 Error creating: pods "api-6b584679b7-smnpj" is forbidden: exceeded quota: team-a-compute, requested: requests.cpu=500m, used: requests.cpu=2, limited: requests.cpu=2
kubectl -n team-a describe quota team-a-compute
Name: team-a-compute Namespace: team-a Resource Used Hard -------- ---- ---- limits.memory 2Gi 8Gi requests.cpu 2 2 requests.memory 1Gi 4Gi services.loadbalancers 0 1
Four replicas fit in 2 CPUs of requests; the fifth is refused. The quota did its job, and the transcript above shows the fix is not a bigger quota: those pods use 1m each against a 500m request.
kubectl --context kind-kx create namespace team-bkubectl --context kind-kx -n team-b create quota team-b-compute --hard=requests.cpu=2,requests.memory=4Gikubectl --context kind-kx -n team-b create deployment api --image=nginx:1.30 --replicas=5kubectl --context kind-kx -n team-b set resources deployment api --requests=cpu=500m,memory=256Mikubectl --context kind-kx -n team-b describe quota team-b-computekubectl --context kind-kx -n team-b get events --field-selector reason=FailedCreatekubectl --context kind-kx delete namespace team-b
For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. Pods created before set resources have no requests and are rejected by the quota; after it, four replicas fit in 2 CPUs and the fifth is refused.
Actual state
Check your understanding
Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.
Lesson not yet reconciled
Desired: 3 objectives, 0 metReconciled: 3 of 3 objectives met
- Attribute cluster cost to namespaces and teams from requests and usage. (not yet met)
- Find idle capacity: over-requested pods, empty nodes and unbound volumes. (not yet met)
- Plan capacity with headroom for failure and growth. (not yet met)
Pass every check above to reconcile this lesson.
Every check has passed, so the desired state is met. First-try accuracy: 0 of 5. This lesson's review cards are in your queue.
Changed since the notes
This lesson draws on an earlier set of study notes. Where the documentation contradicts a claim in them, qualifies it or has moved past it, the claim is listed here with the corrected statement and the source it was checked against.
Show 25 corrections
The notes saidEKS control plane fixed at $0.10 per hour (~$73/month)
Corrected$0.10 per cluster-hour applies to versions in standard support. A cluster on a version in extended support costs $0.60 per cluster-hour. EKS Auto Mode adds a per-instance management fee, Provisioned Control Plane tiers cost $1.65-$13.90 per hour (XL to 8XL), and EKS Hybrid Nodes are billed per vCPU-hour.
The notes saidReserved Instances discounts of 30-60%; Savings Plans cover any instance type, any region, any OS
CorrectedAWS advertises up to 72% off On-Demand for Reserved Instances and EC2 Instance Savings Plans, and up to 66% for Compute Savings Plans. Only Compute Savings Plans apply across instance family, size, AZ, Region, OS and tenancy (and to Fargate and Lambda); EC2 Instance Savings Plans are tied to one instance family in one Region.
The notes saidservice.kubernetes.io/topology-mode: Auto
CorrectedThe annotation still works, but spec.trafficDistribution is the standard field (GA in Kubernetes 1.33). PreferSameZone and PreferSameNode went alpha in 1.33, beta in 1.34 and GA in 1.35, and PreferClose is a deprecated alias for PreferSameZone. If both are set, topology-mode: Auto takes precedence, and the docs warn the annotation may be deprecated.
Sourcekubernetes.io/docs/reference/networking/virtual-ips#traffic-distribution
The notes saidstandard HPA has a minimum of 1
CorrectedThe HPAScaleToZero feature gate is beta and enabled by default in Kubernetes 1.37 (alpha from 1.16 to 1.36). minReplicas: 0 is accepted when the HPA has at least one object or external metric; HPAs scaling only on CPU/memory still need minReplicas >= 1. On clusters older than 1.37, including EKS, where alpha gates can't be enabled, the minimum is 1.
Sourcekubernetes.io/docs/concepts/workloads/autoscaling/horizontal-pod-autoscale#scaling-to-and-from-zero
The notes saidVPA updateMode values
CorrectedVPA 1.5.0 deprecated updateMode 'Auto' (equivalent to 'Recreate', which is the default). Valid modes are Off, Initial, Recreate, InPlaceOrRecreate (in-place resize with eviction fallback; its feature gate was on by default from VPA 1.5.0 and removed in 1.7.0) and InPlace (in-place only, never evicts). The most recent VPA release as of 2026-11-19 is 1.8.1.
Sourcegithub.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/docs/quickstart.md
The notes saidimage: bitnami/kubectl
CorrectedFrom Aug 28, 2025 Bitnami moved its versioned Docker Hub images to docker.io/bitnamilegacy, which gets no updates, and the free catalog keeps only a limited set of hardened images. Use a maintained kubectl image pinned by version or digest. Whether bitnami/kubectl in particular still receives tags is unconfirmed.
The notes saidhelm install kubecost kubecost/cost-analyzer --set kubecostToken=…
CorrectedIBM acquired Kubecost (Sept 2024). Kubecost 3.x installs from the kubecost/kubecost chart (repo https://kubecost.github.io/kubecost) configured with global.clusterId; the cost-analyzer chart command is the 2.x path. Whether kubecostToken is still accepted is unconfirmed. AWS Split Cost Allocation Data for EKS adds pod-level costs to the Cost and Usage Report without a third-party tool.
The notes saidTools like kubernetes-reaper / kube-downscaler
CorrectedNo project named kubernetes-reaper could be found (similarly named projects include pod-reaper and kreaper), so cite a specific tool or drop it. The original hjacobs kube-downscaler is unmaintained; caas-team's py-kube-downscaler fork is in maintenance mode, and caas-team's GoKubeDownscaler is the maintained successor.
Sourcecaas-team.github.io/GoKubeDownscaler/blog/why-we-built-the-gokubedownscaler
The notes saidThe eksctl example puts spot: true and instanceTypes under nodeGroups; those fields belong to managedNodeGroups
CorrectedConfirmed. In eksctl, spot: true and instanceTypes are managedNodeGroups fields. Unmanaged nodeGroups don't support them and configure Spot through instancesDistribution instead.
Sourcedocs.aws.amazon.com/eks/latest/eksctl/spot-instances.html
The notes saidThe '100 Mbps cross-AZ ~ $1,500/month' math
CorrectedConfirmed. 100 Mbps sustained is 12.5 MB/s, about 32,400 GB in a 30-day month. Cross-AZ traffic is billed $0.01/GB on each side ($0.02/GB effective) in us-east-1, which is about $648/month, not about $1,500.
Sourcepricing.us-east-1.amazonaws.com/offers/v1.0/aws/AWSDataTransfer/current/us-east-1/index.json
The notes said'Each Service of type LoadBalancer creates an NLB or ALB'
CorrectedConfirmed. A Service of type LoadBalancer gets an NLB from the AWS Load Balancer Controller (or a Classic Load Balancer from the legacy in-tree provider), never an ALB. ALBs come from Ingress or Gateway API resources handled by the controller.
Sourcekubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/service/nlb
The notes saidThe scale-down CronJob has no ServiceAccount or RBAC; scaling back with --replicas=1 discards original counts
CorrectedConfirmed. The CronJob needs a ServiceAccount with a Role granting get, list and patch on deployments and deployments/scale in each target namespace; the default ServiceAccount gets Forbidden. Record each Deployment's replica count (for example in an annotation) before scaling to zero, and restore from it.
The notes said'Deployments scaled to zero still consume namespace resources'
CorrectedConfirmed. A Deployment at zero replicas runs no pods, so it uses no CPU or memory and no compute ResourceQuota. It still counts toward object-count quotas such as count/deployments.apps, and its objects stay in etcd.
The notes saidEKS cluster fees are $0.10 per hour per cluster ($73/month).
Corrected$0.10 per cluster-hour applies only while the Kubernetes version is in standard support (14 months). In extended support (the following 12 months, enabled by default) the fee is $0.60 per cluster-hour. EKS Provisioned Control Plane tiers add an hourly charge on top of the support fee (XL $1.65, 2XL $3.40, 4XL $6.90, 8XL $13.90 per cluster-hour). EKS Auto Mode adds a per-instance management fee on top of EC2 charges (rate not confirmed here; see the pricing page).
The notes saidCost Explorer date ranges can span up to 14 months of history.
CorrectedCost Explorer provides the current month plus the previous 13 months at daily and monthly granularity. You can opt in to multi-year data at monthly granularity (comparison lookback up to 38 months) and to granular hourly/daily data for the previous 14 days.
Sourcedocs.aws.amazon.com/cost-management/latest/userguide/ce-advanced-cost-analysis.html
The notes saidHourly granularity requires enablement.
CorrectedCorrect, and it is a paid opt-in: hourly data covers only the past 14 days and is billed daily at $0.00000033 per usage record ($0.01 per 1,000 usage records per month) for the records hosted over that 14-day window.
Sourcedocs.aws.amazon.com/cost-management/latest/userguide/ce-hourly-granularity.html
The notes saidReserved Instances often save 30-60%; Spot 70-90%; Graviton 20-40%.
CorrectedAWS publishes ceilings, not typical ranges: Spot up to 90% off On-Demand; EC2 Instance Savings Plans and Standard RIs up to 72%; Compute Savings Plans up to 66%. The Graviton figure is 'up to 40% better price performance' than comparable x86 instances, a price-performance claim rather than a discount. Present these as AWS 'up to' figures and dated marketing numbers.
The notes saidCompute Savings Plans apply to EC2, Lambda, Fargate; EC2 Instance SPs to a family in a region.
CorrectedBoth descriptions are correct, but AWS offers four Savings Plans types: Compute (EC2 any family/Region, Fargate, Lambda; up to 66%), EC2 Instance (one family in one Region; up to 72%), Database (Aurora, RDS, DynamoDB, ElastiCache, DocumentDB, Neptune, Keyspaces, Timestream, DMS, OpenSearch; up to 35%), and SageMaker AI (up to 64%). EKS cluster fees are not covered; the underlying EC2/Fargate usage is.
Sourcedocs.aws.amazon.com/savingsplans/latest/userguide/plan-types.html
The notes saidFargate pricing is per-vCPU and per-GB-memory per second.
CorrectedFargate bills vCPU, memory, OS, CPU architecture and ephemeral storage above the 20 GB included, per second with a 1-minute minimum for Linux and a 5-minute minimum for Windows (Windows also adds a per-vCPU license fee). Usage is measured from image pull start until the task/pod terminates.
The notes saidAWS-generated tag aws:createdBy shows who created a resource.
CorrectedOnly after the management account activates the AWS-generated cost allocation tag, and only for resources created after activation. It is applied best-effort (derived from CloudTrail) to a fixed list of services/events and only in specific Regions, appears only in Billing and Cost Management (not Tag Editor), and cannot be edited.
Sourcedocs.aws.amazon.com/awsaccountbilling/latest/aboutv2/aws-tags.html
The notes saidFargate has per-account limits on concurrent pods.
CorrectedFargate's applicable quota is vCPU-based: 'Fargate On-Demand vCPU resource count' (default 6 for new accounts, adjustable, auto-raised with usage) per account per Region, plus a Spot vCPU quota and launch-rate throttling quotas. The pod count you can run is therefore total vCPU divided by per-pod vCPU size. (One EKS user-guide note still describes it as a pod/task count; the General Reference quota table is vCPU-based.)
The notes saidEKS has limits on nodes per cluster, pods per node; request increases proactively.
CorrectedEKS Service Quotas include managed node groups per cluster (30) and nodes per managed node group (450), both adjustable; there is no fixed nodes-per-cluster quota, and EKS supports up to 100,000 nodes in a single cluster for onboarded customers (engage AWS beyond about 1,000 nodes / 50,000 pods). Max pods per node defaults to 110 and is configurable; prefix delegation raises IP capacity; EKS Auto Mode caps nodes at 110 pods.
The notes saidFor very large clusters, EKS automatically scales the control plane, but there may be limits at extreme scale.
CorrectedEKS has two control-plane modes. Standard mode (default) autoscales. Provisioned Control Plane is an opt-in mode with fixed scaling tiers XL, 2XL, 4XL, 8XL defining API request concurrency (2,000 to 16,000 seats on 1.34+), pod scheduling rate (167 to 400 pods/s), etcd database size (16 GB, or 24 GB for 4XL/8XL on 1.34+) and a 99.99% SLA, billed hourly on top of the cluster fee.
Sourcedocs.aws.amazon.com/eks/latest/userguide/eks-provisioned-control-plane.html
The notes saidKarpenter provides faster, more flexible scaling than Cluster Autoscaler.
CorrectedTeach Karpenter with its v1 APIs: karpenter.sh/v1 NodePool and karpenter.k8s.aws/v1 EC2NodeClass (v1beta1 support was dropped in Karpenter 1.1.0; current release v1.15.2, 2026-11-12). NodePool disruption budgets (default 10% of nodes) and the karpenter.sh/do-not-disrupt annotation govern consolidation. EKS Auto Mode runs a managed Karpenter-based autoscaler with eks.amazonaws.com NodeClass/NodePool, removing the need to operate either autoscaler.
The notes saidRunway math: '30% headroom, 10% monthly growth -> about 3 months'.
CorrectedThe answer depends on what grows. If usage grows 10 percentage points per month, 3 months is right. If usage grows 10% per month compounding (the usual meaning), 70% reaches 100% in ln(1/0.7)/ln(1.1) = about 3.7 months. Measured against the note's own 60-70% utilization ceiling, a cluster already at 70% has roughly zero runway. State the growth model and the ceiling used.
Every correction across the guide, by note and topic.
Sources
Checked against kubernetes.io and AWS documentation for Kubernetes 1.37 on .
- kubernetes.io/docs/concepts/configuration/manage-resources-containers
- kubernetes.io/docs/concepts/policy/resource-quotas
- kubernetes.io/docs/concepts/policy/limit-range
- kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources
- kubernetes.io/docs/concepts/workloads/pods/disruptions
- kubernetes.io/docs/concepts/services-networking/service
- opencost.io/docs/specification
- karpenter.sh/docs/concepts/disruption
- docs.aws.amazon.com/cur/latest/userguide/split-cost-allocation-data.html
- aws.amazon.com/eks/pricing
- aws.amazon.com/savingsplans/compute-pricing
- docs.aws.amazon.com/eks/latest/best-practices/cost-opt.html
- docs.aws.amazon.com/eks/latest/userguide/cost-monitoring.html
Cost and capacity
↓ ↑ step, 1 to 6 scene, Esc leave