AI Hints
Home›Kubernetes Tutorial›Bonus: Managed Kubernetes and Best Practices
Kubernetes · Lesson 85 of 86

Cost Optimisation

Pay for what you need.

⏱ 2 min read▶ Video at 3:12:59🎓 Free
Watch this lesson in the Kubernetes courseWatch on YouTube ↗Full Kubernetes course

Kubernetes makes it easy to start resources, and just as easy to forget them. Without care, a cluster slowly becomes a very expensive hobby. The good news is that most savings come from a handful of habits. In this lesson, we walk through them, from the biggest savings, to the smallest.

Cost Optimisation
From the video: Cost Optimisation
  • Easy to start, easy to forget
  • A handful of habits
  • Biggest savings first

Where the money goes

The bill has a clear shape. Most of it is worker nodes, the virtual machines that run your pods. Then storage, disks and snapshots. Then network, especially traffic between zones, and out to the internet. And last, load balancers, which are billed by the hour, even when idle. The largest lever is, how efficiently your pods fill your nodes. If the nodes are half empty, you are paying double. So we start there.

  1. Worker nodesthe biggest line
  2. Storagedisks and snapshots
  3. Networkcross-zone and egress
  4. Load balancersbilled even when idle
Fill your nodes efficiently
Where the money goes
From the video: Where the money goes

The savings checklist

Here is the checklist, by impact. First, right size requests, using real usage from your metrics, because inflated requests waste whole nodes. Second, autoscale pods, and nodes, so that capacity follows demand. Third, use spot, or preemptible nodes, for fault tolerant workloads, with big discounts. Fourth, remove idle resources, unused load balancers, old volumes, forgotten test namespaces. Fifth, share one ingress, instead of many load balancers. And sixth, set quotas, and labels by team, so that costs are visible, and owned.

LeverWhy it saves
Right-size requestsstop reserving unused capacity
Autoscale pods and nodespay for demand, not peak
Spot nodes for tolerant worklarge discounts
Delete idle resourcesno more silent bills
One ingress, not many load balancersfewer hourly charges
Quotas and team labelscosts become visible

Measure before you cut

Never cut blindly. Measure first. Use your monitoring system, to see requested versus actually used resources, per workload. Use cost tools, that break down spending by namespace, and label. Set alerts on sudden jumps. Change one thing at a time, and watch quality, and latency, after each change. A saving that causes an outage is not a saving. Review the numbers monthly, and make cost one of the standing topics, of your team's weekly rhythm.

Requested vs usedper workload, from metrics
Cost by namespace and labelwho spends what
Alert on jumpscatch accidents early
Change one thing at a timeand watch quality

Summary

Wonderful. Nodes are the biggest cost, so fill them efficiently. Right size requests, autoscale, use spot nodes, delete idle resources, and make costs visible. Measure before every change. Finally, let us gather everything into a best practice checklist.

Key takeaways
  • Fill nodes efficiently
  • Right-size, autoscale, spot
  • Measure, then cut
Next up: Best Practices — the checklist for real clusters