Specialization DepthVol. 17 · Part XVII
0 / 0

Trails / Specialization Depth

SD·194E

Docker, Kubernetes, Cloud and CI/CD at L5/L6

Platform depth from first principles: ladders for containers, Kubernetes, cloud and CI/CD; containers as namespaces plus cgroups plus a content-addressed filesystem (a PID namespace created with unshare; layer digests that change with timestamps and stabilise with SOURCE_DATE_EPOCH); Kubernetes as a set of reconciliation loops (a controller simulated through a rolling update and a node failure), the scheduler, requests and limits, and CPU throttling under CFS quotas (60 ms becoming 410 ms at a 0.5-CPU limit); the L4 toolkit and failure signatures for pods, nodes and networking; cloud at L5/L6 — the shared-responsibility model, IAM evaluation logic (explicit deny, implicit deny, conditions) simulated, networking, managed versus self-run, and cost; CI/CD at L5/L6 — pipeline design, supply-chain security, flaky tests, and DORA's four key metrics computed from a month of deploys.

18 topics · ~20 min read · 30-question quiz
Updated Suggest a correction

Start here: what L5/L6 containers, Kubernetes, cloud and CI/CD look like

At L2 you can write a Dockerfile, deploy to Kubernetes and set up a pipeline. At L3 you know a container is just a process with namespaces (what it can see) and cgroups (what it can use), and that Kubernetes is a set of control loops reconciling desired state. At L4 you can explain why a pod was OOM-killed, evicted or throttled. At L5/L6 you set resource, scaling, cost and delivery policies for many teams, and run the platform through upgrades and incidents.

One example: the CPU limit that slows a service at 40% usage

Kubernetes CPU limits are enforced by the Linux scheduler's quota: in every 100 ms period, a container may use at most its limit's worth of CPU time, then it's throttled until the next period. The lab ran four processes that each needed 20 ms of CPU every 200 ms, all at the same moment, in a cgroup:

CPU limit Average CPU used Request latency (median) Throttled periods
none 0.4 CPU 39.6 ms 0
1 CPU 0.4 CPU 39.5 ms 0
0.5 CPU 0.4 CPU 76.4 ms 31

The service used less than its limit on average, and still nearly doubled its latency, because its work arrived in bursts: 80 ms of CPU needed in one moment, 50 ms allowed per 100 ms. Average utilisation dashboards would show "40% of limit, fine". This is why many teams set CPU requests but no CPU limits for latency-sensitive services, and why L4 engineers check nr_throttled.

How deep to go in containers, Kubernetes, cloud and CI/CD

Volume 17 defines six mastery levels; for this chapter's topics they look like this:

Level You can…
L1 explain containers, orchestration, cloud service models and pipelines
L2 build images, deploy to Kubernetes and a cloud, and run a CI/CD pipeline
L3 explain namespaces, cgroups, the control plane, networking and storage, IAM
L4 debug OOM kills, throttling, scheduling failures, networking and IAM errors
L5 set platform policies: resources, autoscaling, multi-tenancy, cost, delivery
L6 run platforms at scale: upgrades, incidents, capacity and cost governance

The ladders

Level Docker / containers Kubernetes Cloud CI/CD
L1 Knows images, containers, registries Knows pods, deployments, services Knows IaaS/PaaS/SaaS, regions, main services Knows build, test, deploy pipelines
L2 Writes Dockerfiles, runs Compose Writes manifests/Helm charts, uses kubectl Provisions with console/Terraform; uses managed DBs, queues, buckets Writes pipelines (GitHub Actions, GitLab CI), caches dependencies
L3 Explains namespaces, cgroups, overlay filesystems, image layers and digests, OCI specs Explains the control plane, etcd, controllers and reconciliation, scheduler, kubelet, CNI, kube-proxy, probes Explains IAM evaluation, VPC networking, availability zones, the managed services' internals and limits Explains pipeline execution, artefact flow, caching keys, provenance
L4 Diagnoses image bloat, slow builds, PID 1 signal issues, OOM kills, file permission problems Diagnoses CrashLoopBackOff, Pending pods, throttling, OOMKilled, DNS issues, network policies, evictions Diagnoses IAM AccessDenied, network reachability, quota limits, throttling (API rate limits), surprise bills Diagnoses flaky tests, slow pipelines, cache misses, non-reproducible builds
L5 Chooses base images, build strategies, runtime security posture Chooses workload types, autoscaling strategy, multi-tenancy model, ingress/gateway, mesh or not, when not to use Kubernetes Chooses managed vs self-run, account structure, network topology, regions, pricing models Chooses branching and release strategy, deployment strategy, test pyramid in CI, monorepo tooling
L6 Runs fleets: patching base images, supply-chain policy, registry operations Runs clusters: upgrades every few months, capacity, cost, security, incident response Runs multi-account estates: guardrails, cost management, compliance, DR Runs delivery at scale: DORA metrics, platform as a product, governance without friction

Containers from first principles

A container is not a VM. It's an ordinary Linux process with three things applied:

  1. Namespaces give it its own view of global resources: PID (its own process tree, where it is PID 1), mount (its own filesystem tree), network (its own interfaces, routes and ports), UTS (hostname), IPC, user (UID mapping, for rootless containers), cgroup.
  2. cgroups limit and account resources: CPU (shares/weight and quota), memory (hard limit → OOM kill), I/O, PIDs.
  3. A root filesystem assembled from image layers with an overlay filesystem (read-only lower layers + a writable upper layer).

Plus security filters: capabilities dropped, seccomp syscall filtering, AppArmor/SELinux, read-only root filesystem, no-new-privileges.

A PID namespace in one command (no Docker needed):

Shell
unshare --pid --fork --mount-proc sh -c 'echo "PID inside: $$"; ps -e | head -5'
Text
PID inside: 1
    PID TTY          TIME CMD
      1 ?        00:00:00 sh
      2 ?        00:00:00 ps
      3 ?        00:00:00 head

The shell believes it's PID 1 and sees only its own descendants, which is exactly the situation of your application inside a container, and why PID 1 signal handling matters (Volume 16, ch. 192): PID 1 gets no default signal handlers from the kernel, so a process that doesn't install a SIGTERM handler ignores it.

Images are content-addressed

An OCI image is a manifest listing a config and layers, each identified by the SHA-256 digest of its bytes. Pulling by digest (image@sha256:…) is immutable; tags are mutable pointers. Because digests hash every byte, including file metadata, two builds of the same source differ if timestamps differ:

Python
# Image layers are content-addressed tarballs: the digest is sha256 of the bytes, so metadata like mtimes changes it.
def layer(files, mtime):
    buf = io.BytesIO()
    with tarfile.open(fileobj=buf, mode="w", format=tarfile.PAX_FORMAT) as tar:
        for name, data in sorted(files.items()):          # sorted: deterministic order
            info = tarfile.TarInfo(name); info.size = len(data); info.mtime = mtime
            info.uid = info.gid = 0; info.uname = info.gname = ""
            tar.addfile(info, io.BytesIO(data))
    return "sha256:" + hashlib.sha256(buf.getvalue()).hexdigest()[:16] + "…"
Text
build 1, mtime = now          : sha256:d10a4217647440a7…
build 2, mtime = now          : sha256:3ab9774fb3c2c8e2…
build 3, SOURCE_DATE_EPOCH=0  : sha256:658913b764269adf…
build 4, SOURCE_DATE_EPOCH=0  : sha256:658913b764269adf…
build 5, one byte changed     : sha256:6d2e93dd7f308438…

Identical content built twice produced different digests until timestamps were pinned (the SOURCE_DATE_EPOCH convention, honoured by BuildKit, ko, Jib, Bazel and others). Reproducible builds let anyone verify that an image was built from the claimed source, which is the foundation of supply-chain security (SLSA provenance). They also make layer caching effective: unchanged layers keep their digests and aren't re-pushed or re-pulled.

Container L4/L5/L6

  • L4 signatures: exit code 137 (SIGKILL, usually OOM: check kubectl describe pod for OOMKilled); 143 (SIGTERM not handled in time); "permission denied" when running as non-root on files built as root; huge images from build tools left in the final stage; slow builds from cache-busting COPY . . before dependency installation.
  • L5 choices: base image (distroless/Chainguard-style minimal images: fewer CVEs, no shell for attackers or for you; Alpine: musl libc differences, DNS resolver quirks; Debian/Ubuntu slim: compatibility); build tool (Dockerfile with BuildKit, Jib for Java without a Dockerfile, ko for Go, Cloud Native Buildpacks); runtime posture (non-root, read-only root filesystem, drop all capabilities, seccomp RuntimeDefault).
  • L6: base-image patching cadence across a fleet (rebuild on base update, automated); registry operations (retention, replication, pull-through caches, rate limits); admission policy that only allows signed images from your registry.

Kubernetes from first principles

Kubernetes is a database of desired state (etcd behind the API server) plus many independent control loops (controllers) that each watch some objects and act to make reality match the specification. Nothing orchestrates step by step; each controller only ever asks: what is desired, what exists, what one action reduces the difference? This level-triggered design is why Kubernetes heals itself: after a crash, a network blip or a lost node, the next loop iteration sees the difference and acts.

A simplified Deployment controller doing a rolling update (surge 1, unavailable 0), with a node failure part-way through:

Python
# The controller pattern: observe actual state, compare with desired state, take ONE step to converge; repeat.
def reconcile():
    for p in pods:                                   # observe: pods created last loop have passed readiness now
        p["seen"] = p.get("seen", 0) + 1
        p["ready"] = p["ready"] or p["seen"] >= 2
    if any(not p["ready"] for p in pods):
        return "wait for readiness"
    outdated = [p for p in pods if p["image"] != desired["image"]]
    if len(pods) < desired["replicas"]:
        return new_pod() + " (below desired count)"
    if len(pods) > desired["replicas"]:
        victim = outdated[0] if outdated else pods[-1]
        pods.remove(victim)
        return f"delete {victim['name']}" + (" (outdated)" if outdated else " (excess)")
    if outdated:
        return new_pod() + " (surge 1 for rolling update)"
    return "in sync"
Text
loop  1: create api-4 (surge 1 for rolling update)    api-1:a1 api-2:a1 api-3:a1 api-4:b2(starting)
loop  2: wait for readiness                           api-1:a1 api-2:a1 api-3:a1 api-4:b2(starting)
loop  3: delete api-1 (outdated)                      api-2:a1 api-3:a1 api-4:b2
loop  4: create api-5 (surge 1 for rolling update)    api-2:a1 api-3:a1 api-4:b2 api-5:b2(starting)
loop  5: wait for readiness                           api-2:a1 api-3:a1 api-4:b2 api-5:b2(starting)
loop  6: delete api-2 (outdated)                      api-3:a1 api-4:b2 api-5:b2
loop  7: create api-6 (surge 1 for rolling update)    api-3:a1 api-4:b2 api-5:b2 api-6:b2(starting)
loop  8: wait for readiness                           api-3:a1 api-4:b2 api-5:b2 api-6:b2(starting)
loop  9: delete api-3 (outdated)                      api-4:b2 api-5:b2 api-6:b2
          node failure: api-4 disappears
loop 10: create api-7 (below desired count)           api-5:b2 api-6:b2 api-7:b2(starting)
loop 11: wait for readiness                           api-5:b2 api-6:b2 api-7:b2(starting)
loop 12: in sync                                      api-5:b2 api-6:b2 api-7:b2

The same loop handled the rollout and the failure without any special code path for either. The real Deployment controller manages ReplicaSets rather than pods directly, and the ReplicaSet controller manages pods, but the principle is identical: small, idempotent steps toward the desired state. Writing your own controller (an operator, with controller-runtime in Go or the Java Operator SDK) follows the same shape.

kubectl · CIArgo CD API server etcd controllersdeployment · rs scheduler node: kubelet node: kubelet node: kubelet desired every component:watch → compare → act
Kubernetes as cooperating control loops around one source of truth. Users and CI write desired state to the API server, which stores it in etcd. Controllers, the scheduler and every node's kubelet watch the API server and each act on their own slice: controllers create pods, the scheduler binds pods to nodes, kubelets start containers and report status back. No component calls another directly.

Scheduling, requests and limits

The scheduler places a pod on a node whose allocatable resources minus the requests of pods already there can fit the pod's requests, filtered by affinity, taints/tolerations and topology constraints, then scored (spreading, bin-packing). Requests are what the scheduler reserves; limits are what the kernel enforces:

  • Memory limit: hard. Exceeding it means the container is OOM-killed. Set limit = request for predictable memory (Guaranteed QoS when CPU also matches).
  • CPU limit: a CFS quota per period (100 ms by default). A container with limits.cpu: 1 may use 100 ms of CPU time per 100 ms period, summed over all its threads. A multi-threaded process can burn the quota in a fraction of the period and then be throttled (not scheduled at all) until the next period starts, even if the node is idle.
Python
# CPU limits are quotas per 100 ms period (CFS bandwidth control). A request needing 240 ms of CPU spread
# over 4 threads, in containers with different limits, on an otherwise idle 4-core node.
def latency(cpu_ms_total, threads, quota_ms, period_ms=100.0):
    remaining, t = cpu_ms_total, 0.0
    while remaining > 1e-9:
        usable = min(quota_ms, threads * period_ms, remaining)   # CPU usable in this period
        remaining -= usable
        t += usable / threads if remaining <= 1e-9 else period_ms  # throttled until the next period
    return t
Text
no limit (4 cores)   240 ms of CPU on 4 threads →     60 ms wall
limit 4 CPUs         240 ms of CPU on 4 threads →     60 ms wall
limit 2 CPUs         240 ms of CPU on 4 threads →    110 ms wall
limit 1 CPU          240 ms of CPU on 4 threads →    210 ms wall
limit 0.5 CPU        240 ms of CPU on 4 threads →    410 ms wall

Average CPU usage can look low (the container is idle most of the time) while tail latency is terrible, because bursts are throttled. The L4 signal is container_cpu_cfs_throttled_periods_total rising; the L5 choice is between removing CPU limits (keep requests, rely on fair CPU weights, which many operators now recommend for latency-sensitive services), raising them, or reducing parallelism (a JVM sizing GC and compiler threads from the node's cores, Go's GOMAXPROCS from the node rather than the quota: Go 1.25 made GOMAXPROCS respect cgroup CPU limits; older versions need automaxprocs).

Kubernetes L4 toolkit and signatures

Symptom Look at Typical causes
Pending kubectl describe pod events Insufficient requests capacity, taints, affinity, PVC binding, quota
CrashLoopBackOff kubectl logs --previous, exit code App crash at start, missing config/secret, failing liveness probe
OOMKilled (exit 137) describe, memory metrics Limit too low, leak, JVM non-heap (194B)
Running but not receiving traffic kubectl get endpointslices, readiness Readiness failing, label/selector mismatch, wrong port name
Latency spikes, low CPU average Throttling metrics CPU limits (above)
Intermittent DNS failures CoreDNS metrics, ndots, conntrack DNS load, UDP conntrack races, ndots:5
Evictions Node conditions, kubelet logs Memory/disk pressure, ephemeral storage limits
Can't reach service Network policies, kubectl exec + curl, CNI logs Default-deny policy, wrong namespace selector

Kubernetes at L5 and L6

  • L5: workload types (Deployment, StatefulSet for stable identity and storage, DaemonSet, Job/CronJob); autoscaling (HPA on CPU or custom metrics, KEDA on queue depth, VPA for right-sizing, cluster autoscaler or Karpenter for nodes); multi-tenancy (namespaces with quotas and policies vs separate clusters); Gateway API vs Ingress; service mesh only when you need mTLS, traffic splitting and per-request telemetry across many services, since meshes add latency and operational load; and when not to use Kubernetes at all (a few services, a small team: a managed container platform such as Cloud Run, App Runner, Azure Container Apps, or plain VMs may serve better).
  • L6: Kubernetes minor versions release about three times a year with roughly 14 months of upstream patch support, so clusters need upgrades every few months (API deprecations: check with tools like pluto or kubent); node image patching; etcd health and backups (if self-managed); capacity and bin-packing efficiency (requests vs actual usage); security (RBAC least privilege, Pod Security Standards, network policies, admission control with Kyverno/OPA Gatekeeper, image signature verification); cost allocation per team (OpenCost/Kubecost).

Cloud at L5/L6

Shared responsibility: the provider secures the cloud (hardware, hypervisor, their managed services' internals); you secure what you put in it (IAM, network exposure, data, OS and application patches on IaaS). The line moves with the service: you patch an EC2 instance's OS; you don't patch Lambda's runtime host.

IAM evaluation from first principles

Every cloud has an authorisation engine. AWS's logic, simplified: an explicit Deny in any applicable policy wins; otherwise an Allow is needed; otherwise the default is implicit deny. Conditions (source VPC endpoint, MFA, tags, time) narrow statements. Organisation-level guardrails (service control policies) and permission boundaries can only restrict.

Python
# Cloud IAM evaluation, simplified AWS logic: explicit Deny wins; otherwise any matching Allow; otherwise implicit deny.
policies = [
    {"Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject"], "Resource": "arn:aws:s3:::tiffinbox-invoices/*"},
    {"Effect": "Allow", "Action": ["s3:*"], "Resource": "arn:aws:s3:::tiffinbox-menu-images/*"},
    {"Effect": "Deny",  "Action": ["s3:DeleteObject"], "Resource": "arn:aws:s3:::*"},          # guardrail (e.g. an SCP)
    {"Effect": "Allow", "Action": ["kms:Decrypt"], "Resource": "arn:aws:kms:ap-south-1:111122223333:key/*",
     "Condition": {"aws:SourceVpce": "vpce-0abc"}},
]
Text
s3:GetObject     tiffinbox-invoices/2026/10/inv-77.pdf        → ALLOW
s3:DeleteObject  tiffinbox-menu-images/biryani.jpg            → DENY (explicit)
s3:GetObject     tiffinbox-backups/base.tar.gz                → DENY (implicit: no matching allow)
kms:Decrypt      k1                                           → ALLOW
kms:Decrypt      k1                                           → DENY (implicit: no matching allow)

The second row is the L4 trap: s3:* on the menu bucket looks like it allows deletion, but the guardrail's explicit deny wins. The last row: the same principal and key, but from outside the VPC endpoint, so the condition fails and nothing allows it. At L4 you read which statement decided (CloudTrail, IAM Access Analyzer, the policy simulator) instead of adding permissions until the error disappears. Real evaluation also involves resource policies (bucket and key policies), session policies, permission boundaries and cross-account rules, but the explicit-deny-first logic holds throughout (GCP and Azure have equivalent models, with GCP adding deny policies and Azure deny assignments).

Cloud L5 and L6

  • Account/project structure: separate accounts per environment and workload, a security account, a backup account, centralised logging; guardrails via SCPs/organisation policies (Volume 16, ch. 190).
  • Networking: VPC design (private subnets for workloads, public only for load balancers), NAT costs (NAT gateway data processing charges are a classic surprise bill), VPC endpoints/PrivateLink for cloud APIs, peering vs transit gateways.
  • Managed vs self-run: managed Postgres/Kafka/Redis cost more per unit but remove patching, backups and failover work; self-run makes sense with scale and expertise (Volume 15's build-vs-buy).
  • Limits and quotas: every service has them (API rate limits, IPs per subnet, Lambda concurrency); L6 means knowing yours before an incident finds them.
  • Cost (FinOps): unit economics (cost per order, per active user); pricing models (on-demand, savings plans/committed use for the steady baseline, spot/preemptible for interruptible batch and stateless workers); right-sizing from utilisation; storage tiers and lifecycle rules; egress awareness; tagging for allocation; budgets and anomaly alerts.
  • Multi-cloud: usually costs more than it saves; justified by regulation, acquisition, or specific best-of-breed services. Portability via Kubernetes, Postgres and Terraform keeps the option open cheaply.

CI/CD at L5/L6

L3: a pipeline is a DAG of jobs producing artefacts that flow to environments; caches keyed by lockfile hashes; runners (hosted or self-hosted, ephemeral is safer); secrets scoped to environments; provenance attached to artefacts.

L4 signatures: slow pipelines (no dependency caching, no test parallelisation, rebuilding unchanged modules in a monorepo: use affected-target detection with Nx, Turborepo, Bazel, Gradle build cache); flaky tests (a test that passes and fails on the same code: track flake rate per test, quarantine and fix; common causes: time, ordering, shared state, real network, async waits with sleeps); non-reproducible builds (unpinned dependencies or base images).

L5 choices: trunk-based development with short-lived branches and feature flags (strongly associated with high delivery performance in DORA research) vs long-lived release branches (needed for some on-premise products); deployment strategy (Volume 16, ch. 192); what runs on each commit vs nightly; monorepo vs polyrepo; GitOps vs push-based deploys.

Supply-chain security: pinned actions by commit SHA (tags can be moved, as the 2025 compromise of a popular GitHub Action showed), least-privilege permissions: in workflows, OIDC instead of stored cloud keys, no secrets exposed to pull requests from forks (pull_request_target misuse is a classic hole), SBOMs, signed artefacts with provenance (SLSA levels), dependency review.

L6: measuring delivery. The DORA research programme's four key metrics:

Python
# DORA's four key metrics from a month of deployment records
lead = [p(d) - p(m) for m, d, _, _ in deploys]
fails = [(p(d), p(r)) for m, d, f, r in deploys if f]
print(f"deployment frequency : {len(deploys) / working_days:.1f} per working day ({len(deploys)} in {working_days} days)")
print(f"lead time for changes: median {median(lead)}  (merge → production)")
print(f"change failure rate  : {len(fails) / len(deploys):.0%}")
print(f"time to restore      : median {median(r - d for d, r in fails)}")
Text
deployment frequency : 0.6 per working day (12 in 20 days)
lead time for changes: median 1:07:30  (merge → production)
change failure rate  : 17%
time to restore      : median 0:55:00

Two throughput metrics (frequency, lead time) and two stability metrics (change failure rate, time to restore; recent DORA reports call the latter failed deployment recovery time and add a fifth, rework rate). The research's central finding is that throughput and stability go together: teams that deploy small changes often also fail less and recover faster. Use the metrics to find constraints in your own process over time, not to compare or rank teams (Goodhart's law: a measure that becomes a target stops being a good measure).

Lab: cgroups, quotas and the throttling trap

Setup. The lab machine's Linux kernel with the cgroup v1 cpu controller; a cgroup with a 100 ms CFS period and quotas set by writing cpu.cfs_quota_us (−1 = unlimited, 100000 = 1 CPU, 50000 = 0.5 CPU, 25000 = 0.25 CPU); Python workloads moved into the cgroup by writing their PID to cgroup.procs. This is the same mechanism the kubelet configures for a container's CPU limit (cgroup v2 uses cpu.max with the same semantics).

Experiment 1: a steady single-threaded service

One thread, a 20 ms CPU-bound request every 50 ms (average 0.4 CPU), 6 s:

Quota p50 p99 max Throttled periods
unlimited 20.0 ms 22.5 ms 23.3 ms 0
0.5 CPU 20.0 ms 24.9 ms 28.1 ms 0
0.25 CPU 95.0 ms 96.5 ms 102.9 ms 96

Below the limit, steady load ran untouched. Above it (0.4 CPU needed, 0.25 allowed), every request was cut into 25 ms slices spread over several periods: a 20 ms request took 95 ms.

Experiment 2: bursty load under the limit

Four processes, each a 20 ms CPU-bound request every 200 ms, all at the same instants (average 0.4 CPU; each burst needs 80 ms of CPU at once on a 2-CPU machine):

Quota p50 p99 Throttled periods
unlimited 39.6 ms 46.8 ms 0
1 CPU 39.5 ms 45.2 ms 0
0.5 CPU 76.4 ms 83.0 ms 31

The average was 20% below the limit, yet nearly every burst was throttled (31 of ~31 bursts) and latency doubled. Real services are bursty: request spikes, GC, JIT compilation, many threads waking at once. Consequences for L5 policy:

  • For latency-sensitive services, set CPU requests (for scheduling and fair share) and consider no CPU limit, or limits well above burst needs; keep memory limits (memory isn't compressible).
  • Watch container_cpu_cfs_throttled_periods_total and alert on throttling, not average CPU.
  • Runtimes size thread pools from the CPU limit (the JVM's availableProcessors, Go's GOMAXPROCS with automaxprocs); a low limit also shrinks parallelism.

(A first attempt used four threads in one Python process; Python's GIL let only one run at a time, so the bursts never exceeded one CPU and nothing was throttled. Knowing your runtime's concurrency model is part of interpreting resource limits.)

Try it yourself

  1. Repeat Experiment 2 with cpu.cfs_period_us = 10,000 (10 ms periods): does throttling latency improve?
  2. Set cpu.cfs_burst_us (if your kernel supports it) to allow short bursts above quota and remeasure.
  3. In k3s, run the burst workload in a pod with a 500m limit and read the throttling metric from the kubelet's cAdvisor endpoint.
  4. Put a memory-hungry process in a cgroup with memory.limit_in_bytes = 100 MB and watch the OOM kill in dmesg.

Revision sheet: Docker, Kubernetes, cloud and CI/CD at L5/L6

Key ideas

  • Containers: namespaces (pid, net, mnt, uts, ipc, user, cgroup), cgroups (cpu, memory, io, pids), union filesystems, image layers, OCI runtimes.
  • Kubernetes: API server + etcd as desired state; controllers and the scheduler reconcile; kubelet runs pods; Services, kube-proxy/eBPF networking, CNI, CSI.
  • Resources: requests (scheduling, share) vs limits (CPU throttle, memory OOM); QoS classes; HPA/VPA/cluster autoscaler.
  • L4: OOMKilled, CrashLoopBackOff, Pending (unschedulable), throttling, DNS and network policy issues, IAM errors.
  • Cloud at L5/L6: account/project structure, IAM least privilege, networking, managed vs self-run, cost (FinOps), multi-region.
  • CI/CD at L5/L6: pipelines as products, OIDC to cloud, signed artefacts and provenance, progressive delivery, platform golden paths.

Numbers to remember

  • CFS period 100 ms; a 0.5 CPU limit = 50 ms of CPU per 100 ms.
  • Lab: bursty load at 0.4 CPU average under a 0.5 CPU limit: median latency 39.6 → 76.4 ms, 31 throttled periods.
  • Lab: steady load above the limit (0.4 needed, 0.25 allowed): 20 → 95 ms.

Pitfalls

  • Judging CPU limits by average utilisation.
  • No memory limits (noisy neighbours) or memory limits below real peaks (OOM loops).
  • Thread pools sized from host cores instead of container limits.
  • Long-lived cloud keys in CI.
  • Platform policies without measurement of their latency and cost effects.

Glossary

  • CFS quota: the scheduler's per-period CPU time cap.
  • Throttling: pausing a cgroup's tasks until the next period.
  • QoS class: Guaranteed, Burstable or BestEffort, from requests and limits.
  • Reconciliation loop: compare desired and actual state, act, repeat.
  • Golden path: a supported, paved way for teams to build and deploy.