Stage 1, Part 4 of 9, Kubernetes Fundamentals (Day 0/1)
Text
PART 4: CAPACITY PLANNING & COST MODELING
18. Cluster Sizing Fundamentals
Node Sizing
| Workload Type | Node Size | Why |
| General apps | 4–8 vCPU, 16–32 GB | Balanced |
| Databases | 8–16 vCPU, 64–128 GB | Memory + I/O |
| ML training | GPU nodes | Specialized hardware |
| Batch | High CPU | Compute-optimized |
Cluster Sizing Formula
text
Total CPU needed = sum(pod requests) × overcommit_ratio + system_overhead
Total memory needed = sum(pod requests) × overcommit_ratio + system_overhead
overcommit_ratio for CPU: 2-4x
overcommit_ratio for memory: 1-1.5x (be conservative)
Reserved Capacity
Reserve ~10–20% for:
- Control plane components
- kubelet, kube-proxy
- DaemonSets (logging, monitoring)
- Burst headroom
19. Resource Overcommit and Cost Optimization
Overcommit Ratios
| Resource | Safe Overcommit | Risk |
| CPU | 2–4x | Throttling |
| Memory | 1–1.5x | OOMKill |
| Disk | 1x | Capacity exhaustion |
Cost Optimization Tactics
| Tactic | Savings |
| Right-size requests/limits | 20–40% |
| Use Spot/Preemptible nodes | 60–80% for interruptible |
| Bin-packing | 20–30% |
| Autoscaling | Variable |
| Reserved instances | 30–60% |
| Multi-tenancy | 30–50% |
Example: 100-Node Cluster
text
Before optimization:
100 × m5.2xlarge ($0.384/hour) = $27,648/month
Average utilization: 25%
After optimization:
Right-size: 60 nodes
Spot for batch: 20 nodes at 70% discount
Reserved for baseline: 30 nodes at 40% discount
Costs:
Baseline: 30 × $0.384 × 730 = $8,409
Spot: 20 × $0.115 × 730 = $1,679
Total: $10,088/month
Savings: $17,560/month = $210,720/year
20. SLA & Availability Design
Availability Math
text
99.9% = 8.76 hours downtime/year
99.99% = 52.56 minutes downtime/year
99.999% = 5.26 minutes downtime/year
Kubernetes SLA Design
| Target | Architecture |
| 99.9% | Multi-replica Deployments, basic monitoring |
| 99.99% | Multi-AZ, PodDisruptionBudgets, anti-affinity, HA control plane |
| 99.999% | Multi-region, chaos-tested, GitOps, automated recovery |
Zero-Downtime Checklist
- ✅
maxUnavailable: 0 in Deployment strategy - ✅ Readiness probes on all containers
- ✅ Graceful shutdown (SIGTERM handling)
- ✅
preStop hooks for connection draining - ✅ PodDisruptionBudgets
- ✅ Pod anti-affinity for HA
- ✅ Multiple replicas (3+)
- ✅ Multi-AZ scheduling
1:1 copy of the class Google Doc, code in code blocks.