Stage 10, Part 5 of 9 · p. 87, Autoscaling & Cost Optimization

PART 5: ARCHITECTURE & STRATEGY

20. Cost Governance Architecture

text
┌─────────────────────────────────────────────────────────────┐
│                    COST GOVERNANCE STACK                    │
│                                                             │
│  Layer 1: Visibility                                        │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  Kubecost / OpenCost                                 │   │
│  │  • Cost allocation by namespace, label, team        │   │
│  │  • Real-time monitoring                             │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
│  Layer 2: Optimization                                      │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  VPA (Off) + Goldilocks                             │   │
│  │  • Rightsizing recommendations                      │   │
│  │  • Historical analysis                              │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
│  Layer 3: Scaling                                           │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  HPA + KEDA + Karpenter                             │   │
│  │  • Replica scaling (HPA/KEDA)                       │   │
│  │  • Node scaling (Karpenter)                         │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
│  Layer 4: Governance                                        │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  ResourceQuotas + LimitRanges + Budgets             │   │
│  │  • Team budgets                                     │   │
│  │  • Resource caps                                     │   │
│  └─────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘

21. Multi-Tenant Cost Allocation

Showback vs Chargeback

ModelDescriptionImpact
ShowbackShow teams their costsAwareness
ChargebackCharge teams for costsAccountability

Cost Allocation Labels

yaml
metadata:
  labels:
    team: platform
    cost-center: engineering
    environment: production
    app: web

ResourceQuotas for Cost Control

yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: team-budget
  namespace: team-a
spec:
  hard:
    requests.cpu: "100"
    requests.memory: 200Gi
    limits.cpu: "200"
    limits.memory: 400Gi

22. Compliance & Security for Cost Management

FrameworkRequirement
SOC2Change management, monitoring
PCI-DSSAccess controls, audit logs
HIPAAAudit trails, access controls
FedRAMPFIPS 140-2, cost controls

1:1 copy of the class Google Doc, code in code blocks.