Skill 7.3.2

Optimize Kubernetes cost through rightsizing requests, bin packing, autoscaling and spot nodes

Key Concepts

Rightsizing requests is the first step: requests set far above actual usage reserve capacity that nothing uses. Tools such as the Vertical Pod Autoscaler recommend requests from observed usage. Bin packing then places pods efficiently on nodes, and node sizes are chosen to fit the pods' CPU-to-memory ratio.

Rightsizing requests only saves money when nodes are removed. The Cluster Autoscaler or a node provisioner such as Karpenter adds nodes when pods cannot be scheduled and removes underused nodes after consolidating their pods. The Horizontal Pod Autoscaler adjusts replica counts with load.

Spot node pools run interruptible workloads at a deep discount, using pod disruption budgets and multiple instance types to tolerate interruptions. Non-production clusters or namespaces can be scaled to zero outside working hours.