Kubernetes interview question · Most asked
How do you control costs in Kubernetes?
Summary
Right-size requests from real usage (requests drive node count), use autoscaling at both the pod and node level, bin-pack with tools such as Karpenter consolidation, run interruption-tolerant workloads on spot or preemptible nodes, scale non-production environments down outside working hours, and allocate costs per team with labels and tools such as OpenCost or Kubecost.
Longer Answer
Over-requesting is the biggest waste: pods requesting 2 CPU and using 0.2 keep nodes half empty. Other wins: ARM-based nodes where images support them, removing orphaned volumes and load balancers, limiting log and metric volume, and avoiding one cloud load balancer per Service. Measure before and after, and keep reliability headroom.
Key Points
- Right-size requests.
- Autoscale pods and nodes; consolidate.
- Spot for tolerant workloads; schedule non-prod down.
- Cost allocation by labels (OpenCost).
More most-asked Kubernetes questions
- ConfigMaps and Secrets: how do they differ, and how should secrets really be handled?
- How does the scheduler place pods? Explain resource requests, node affinity, taints and tolerations.
- Describe the Kubernetes architecture: what runs on the control plane and what runs on the nodes?
- How do rolling updates work in a Deployment, and how do you roll back?
- Explain the Service types: ClusterIP, NodePort, LoadBalancer, ExternalName and headless.
- What happens, step by step, when you run kubectl apply for a Deployment?
- Deployment, StatefulSet, DaemonSet, Job and CronJob: when do you use each?
- What is the difference between resource requests and limits, and what are the QoS classes?