PAITS Cheat Sheet Cloud & DevOps Intermediate Updated 2026-10-23

Kubernetes Production Architecture & Pod Lifecycle Cheat Sheet

Control plane components, QoS eviction classes, readiness/liveness probes, HPA math, and network policies.

Executive Summary: Production SRE guide to Kubernetes scheduling, resource QoS classes, graceful pod termination lifecycle, Horizontal Pod Autoscaler (HPA) equations, and zero-downtime rolling deployments.

Key Equations & Invariants

Horizontal Pod Autoscaler (HPA) Replica Formula
R_{\text{desired}} = \left\lceil R_{\text{current}} \times \frac{M_{\text{current}}}{M_{\text{target}}} \right\rceil

Scales pod replicas proportionally to the ratio of observed metric M_current to target M_target.

1. Resource Requests, Limits & OOMKill QoS Classes

CPU is a compressible resource (throttled via CFS quota when exceeding `limits.cpu`), whereas Memory is incompressible (exceeding `limits.memory` triggers immediate kernel `OOMKilled` exit code 137).

QoS ClassConfiguration RuleOOM Score AdjEviction Priority
Guaranteedrequests == limits for ALL containers (CPU & Mem)-997Evicted LAST (protected)
BurstableAt least one container has requests < limits2 to 999Evicted second under node pressure
BestEffortNo requests or limits set on any container1000Evicted FIRST when node memory is low
Zero-Downtime Production Deployment Manifest with Probes & PreStop Hookyaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: paits-inference-gateway
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate: { maxSurge: 1, maxUnavailable: 0 }
  template:
    spec:
      terminationGracePeriodSeconds: 45
      containers:
        - name: api
          resources:
            requests: { cpu: '500m', memory: '1Gi' }
            limits:   { memory: '1Gi' }
          readinessProbe:
            httpGet: { path: /health/ready, port: 8000 }
            periodSeconds: 5
          lifecycle:
            preStop:
              exec:
                command: ['/bin/sh', '-c', 'sleep 5']

Common Production & Interview Pitfalls

Frequently Asked Questions

Q: Why do many SRE teams avoid setting CPU limits while enforcing Memory limits?

Strict CPU CFS quotas can cause artificial latency spikes on multi-threaded runtimes even when the host node has idle CPU cores available.