Overview
Curated: · Written: · Reviewed:
Containerization & Orchestration
In one line
A container is a process started from an image with its own namespaces and cgroups, sharing the host kernel. Kubernetes schedules Pods, and controllers keep actual state matching declared state. Reach for it when you need repeatable packaging plus self-healing, rolling change and rollback across many nodes.
Key definitions
- Digest: the content hash of an image manifest. It pins exact bytes; a tag can move.
- Namespace and cgroup: Linux isolation of the process view, and CPU, memory and I/O accounting and limits. The kernel is shared.
- Pod: the scheduled unit. Its containers share a network namespace and can share volumes.
- Requests vs limits: requests drive scheduling; limits cap runtime use.
- Probes: startup gates the others; readiness controls Service endpoints; liveness restarts a container.
- PodDisruptionBudget: limits voluntary evictions only, not node failure.
Formulas and complexity
CPU limits become a CFS quota per period:
With the default 100 ms period, a 200m limit gives:
The scheduler places a Pod only where the sum of requests fits allocatable. Limits play no part in that check.
How it works
- Controllers never touch nodes. They write Pods, and the scheduler binds each Pod to a node.
- The scheduler filters on requests, affinity, taints and topology, then scores the survivors.
- The kubelet pulls by digest, runs probes and reports status to the API server.
- kube-proxy programs Service rules, and it balances new TCP connections, not individual requests.
- Under node pressure, the kubelet evicts by QoS class: BestEffort first, Guaranteed last.
When to use and when not to
| Need | Use | Why |
|---|---|---|
| Interchangeable stateless replicas, rolling update, rollback | Deployment | ReplicaSet revisions; rollback scales an older one back up |
| Stable names and per-replica storage | StatefulSet | Ordinal identity, per-replica volumes, ordered rollout |
| One agent per node | DaemonSet | Log shippers, CNI plugins |
| Run to completion | Job or CronJob | Pod exits and is not restarted as a service |
| Helper that must share a volume and lifecycle | Second container in the same Pod | Replaced together on every rollout |
| Unrelated services | Separate Pods | Separate fate and trust boundaries |
Traps interviewers probe
- Deploying a mutable tag. A moved tag changes what new pods pull. Fix: pin the digest in the pod template and verify the running digest after rollout.
- Deleting a secret in a later layer. The earlier layer keeps the bytes. Fix:
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ciso the file never lands in a layer. - Shell-form CMD.
sh -cbecomes PID 1 and does not forward SIGTERM, sodocker stopwaits 10 s and the exit code is 137. Fix: exec form, orexec node server.jsinside the shell. - Lowering the CPU limit to fix a slow handler. At 200m, 50 ms of CPU needs about 210 ms of wall-clock time, because only 20 ms runs per 100 ms period. Fix: size requests from measured load, then remove or raise the CPU limit and watch
container_cpu_cfs_throttled_seconds_total. - Liveness or readiness calling a shared dependency. A database outage then restarts every replica or empties every endpoint at once. Fix: liveness checks only local process health. Readiness checks a bounded, local condition, not a shared dependency.
Interview tips
Open by naming the layer that owns the decision: scheduler, kubelet, controller or Service proxy. Then say which signal you read first.
Follow-ups to expect:
- Rollout stuck at 80%: readiness failing, a PDB blocking eviction, no surge capacity, image pull failure, or resource pressure. Check
kubectl describeevents first. - Request vs limit: requests are the scheduling contract; limits are the runtime cap.
- Slow dependency: readiness catches it, and only if the check is bounded. Liveness would cascade.
- In-flight requests on drain: SIGTERM, preStop, grace period, endpoint removal. Add a preStop sleep so endpoint removal lands before the listener closes, and set the grace period above sleep plus the longest request.
- Tenant isolation: namespaces are administrative. Add RBAC, NetworkPolicy, ResourceQuota, and often separate nodes or clusters.
30-second outline: "This is a [layer] question. The API server records desired state, the controller creates Pods, the scheduler binds them using requests, and the kubelet pulls the digest and runs probes. I'd check the events for the owning component first, then compare against requests, allocatable or the probe result. The fix is [X], and I verify it with [the running digest, the endpoint list or the error rate]."
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.