Key Terms
| Term | In one line |
|---|---|
| Multi-stage build | Build tooling and secrets never reach the runtime image |
| Liveness probe | “Is this container still functional?” — failure restarts it |
| Readiness probe | “Can it take traffic right now?” — failure removes it from the Service |
| Startup probe | “Has slow startup finished?” — protects slow starters from liveness restarts |
| HPA | Scales on CPU/memory or custom Metrics API values; cannot scale below 1 |
| KEDA | Event-driven autoscaling from 50+ external sources; can scale to zero |
| Azure CNI | Every pod gets a routable VNet IP |
| CNI Overlay / Kubenet | Pods get IPs from a separate CIDR — conserves VNet address space |
| Workload Identity / IRSA | Pod-level cloud identity, no mounted secrets |
| OPA Gatekeeper / Azure Policy | Admission-time policy enforcement |
Numbers That Matter
| Figure | Value | Where it bites |
|---|---|---|
| Build stage size | Often 1 GB+ | Never ships with a multi-stage build |
| Runtime image | Often <200 MB | The result worth quoting |
| Model weight loading | 60–300 seconds into GPU memory | Without a startupProbe, liveness kills the pod in a restart loop — the AI-specific gotcha |
| KEDA sources | 50+ | SQS, Kafka, Service Bus, Prometheus, cron |
Decision Rules
- Multi-stage builds for three reasons, not one: size, security (no build secrets, source maps or toolchains in the runtime image, so there’s nothing to exfiltrate from a running container), and reproducibility.
- Container security checklist: run as non-root, pin base image versions (never
:latest), scan in CI, never bake secrets into layers (they persist in registry history even if a later layer deletes the file — use build secrets), drop all capabilities, and sign images with verification at deploy. - Set a startup probe on any slow-starting workload. For model servers this is not optional: weights take 60–300 seconds to load, and the default liveness probe will restart the pod before it ever becomes ready.
- Readiness gates traffic; liveness restarts. Pointing liveness at a dependency check is how a slow database turns into a cluster-wide restart storm — check only this container’s health.
- HPA for CPU/memory and custom metrics; KEDA when scaling must be driven by an external event source or must reach zero. Layer them: cluster autoscaler for nodes, HPA/KEDA for pods, virtual nodes for burst.
- Deployment strategy by risk: rolling for routine changes; blue-green when a partial-rollout state is worse than running two environments (breaking schema migration, major framework upgrade); canary for gradual blast-radius control; shadow first for model changes.
- Canary answers “is this technically safe”; A/B answers “is this better.” They look alike and measure entirely different things — conflating them is a common interview stumble.
Say This Out Loud
“For a model-serving container I always set a startup probe, and it’s the thing I check first when someone tells me their GPU pods are crash-looping. Loading weights into GPU memory takes sixty to three hundred seconds. The default liveness probe starts checking long before that, decides the container is dead, restarts it, and you get an infinite loop that looks like an application bug. The startup probe holds liveness off until the slow start has genuinely finished.”
“Multi-stage builds are usually sold on image size, but security is the better argument. Your build stage has the SDK, the compilers, often a package-registry token — and none of it reaches the runtime image, so there’s nothing for an attacker to find inside a running container. Related: never delete a secret in a later layer and assume it’s gone. Layers persist in registry history; the file is still there for anyone who pulls the image.”
“For rolling out a new model version I’d use shadow first, then canary. Shadow runs the new model against real production traffic with responses discarded, and I log both models side by side — that tells me about quality, which a canary can’t, because error rate and latency stay green through a quality regression. Once quality is proven, the canary handles the operational risk with traffic weights and automated rollback.”