PART 7: INCIDENT MANAGEMENT
32. Cost Incident Post-Mortem Template
text
INCIDENT: Cost Spike - Unexpected 300% Increase in Monthly Bill
DATE: 2024-01-15
DURATION: 5 days
SEVERITY: SEV-2
IMPACT: Cloud bill increased from $15,000 to $60,000.
TIMELINE:
Day 1: Batch job deployed without resource limits
Day 3: Batch job scaled to 50 replicas (HPA)
Day 5: Cost alert fired
Day 5: On-call investigated, identified runaway batch job
Day 5: Job deleted, limits applied
Day 6: Cost normalized
ROOT CAUSE:
Batch job had no CPU limits and HPA scaled it to 50 replicas.
Each replica requested 2 CPUs, consuming 100 CPUs total.
No cost alerts for 5 days.
LESSONS LEARNED:
1. All workloads must have resource limits.
2. Cost alerts must fire at 50% of budget.
3. HPA maxReplicas must be bounded.
ACTION ITEMS:
[ ] Enforce resource limits via LimitRange (Owner: Platform)
[ ] Add cost alerts at 50% of monthly budget (Owner: SRE)
[ ] Audit all workloads for missing limits (Owner: Platform)
33. On-Call Runbook: Cost Spike / Autoscaling Failure
text
STEP 1: Check cost dashboard
# Open Kubecost/OpenCost dashboard
STEP 2: Identify the spike source
# By namespace, deployment, label
STEP 3: Check for runaway workloads
$ kubectl get pods -A --field-selector status.phase=Running
$ kubectl top pods -A --sort-by=cpu | head -20
STEP 4: Check HPA settings
$ kubectl get hpa -A
$ kubectl describe hpa <name>
STEP 5: Check for missing limits
$ kubectl get pods -A -o json | jq '.items[] | select(.spec.containers[].resources.limits == null) | .metadata.name'
STEP 6: Apply immediate fix
# Scale down runaway workload
# Apply resource limits
STEP 7: Check node count
$ kubectl get nodes
# Karpenter/Cluster Autoscaler may have added nodes
STEP 8: Escalate
34. Escalation Matrix
| Severity | Impact | Response Time | Escalation |
| SEV-1 | Cost spike > 200% / autoscaling failure causing outage | 5 min | On-call + Platform + Management |
| SEV-2 | Cost spike 50-200% / PDB blocking scale-down | 15 min | On-call + Platform |
| SEV-3 | Cost anomaly / optimization opportunity | 1 hour | On-call |
| SEV-4 | Rightsizing recommendation | 4 hours | Ticket |
1:1 copy of the class Google Doc, code in code blocks.