Purpose

This section documents the internal request flows and component interactions within a Kubernetes cluster as ASCII sequence diagrams. Each file traces a specific operation end-to-end — from the API client call through every component that participates, to the final observed state.

These diagrams complement the component reference sections (01–02) by showing temporal behaviour: what calls what, in what order, and what state is persisted at each step.

Index

#FileFlowKey components
01pod-creation-flow.mdkubectl apply → running podAPI server, etcd, scheduler, kubelet, CRI
02service-account-token.mdPod token request → mounted JWTAPI server, TokenRequest, projected volume
03admission-flow.mdAPI request → admission chainAuthn, Authz, MutatingWebhook, ValidatingWebhook
04scheduler-flow.mdUnscheduled pod → node bindingScheduler filter/score/bind cycle
05rolling-update-flow.mdImage bump → all pods updatedDeployment controller, ReplicaSet, kubelet
06hpa-flow.mdMetric spike → scale outHPA controller, metrics-server, Deployment
07csi-flow.mdPVC create → pod mounts volumeCSI controller, node plugin, VolumeAttachment
08network-policy-flow.mdNetworkPolicy create → eBPF rulesAPI server, CNI plugin, node datapath
09rbac-flow.mdkubectl → RBAC decisionAuthn, Authz RBAC, audit log
10garbage-collection.mdOwner deleted → cascade deleteGC controller, ownerReferences, finalizers
11leader-election.mdController startup → active leaderLease API, controller-manager leader election
12webhook-flow.mdAdmission webhook invocationAPI server → webhook server → response
13cni-setup-flow.mdPod sandbox → network namespace wiredkubelet, CNI plugin, IPAM
14volume-attach-flow.mdPVC bound → volume mounted in podattach-detach controller, kubelet, CSI node

How to Read These Diagrams

Participant notation:
  Client        — kubectl, API client, controller
  API Server    — kube-apiserver (all requests go through here)
  etcd          — persistent store (only API server talks to etcd)
  Controller    — specific controller (scheduler, HPA, GC, etc.)
  kubelet       — node agent (watches API server, drives containers)
  CRI           — Container Runtime Interface (containerd, CRI-O)

Arrow notation:
  ──►   synchronous call (caller waits for response)
  --►   asynchronous / watch event (fire and forget)
  ══►   persisted state change (write to etcd)
  ···►  background polling / reconcile loop

Component Interaction Principles

Five rules govern every flow in Kubernetes:

1. Everything goes through the API Server

No component calls another directly. The scheduler does not call kubelet. kubelet does not call etcd. All state is read from and written to the API server. This hub-and-spoke model means the API server is the source of truth.

2. Controllers watch, not poll

Controllers use the watch API (long-lived HTTP/2 streaming connection). When an object changes, the API server pushes the event to all watchers. The local informer cache makes reads free; only writes go to the API server.

3. etcd is only touched by the API server

Controllers, kubelets, and all clients communicate with the API server via REST or gRPC. The API server translates these to etcd operations. Nothing else writes to etcd directly.

4. State drives action (level-triggered, not edge-triggered)

Controllers reconcile desired state vs actual state, not events. If a controller restarts mid-operation, it re-reads the current state from the API server and continues from there. This makes all controllers idempotent.

5. Finalizers prevent premature deletion

When an object has finalizers, kubectl delete only sets deletionTimestamp. The object is not removed from etcd until all controllers have removed their finalizer entries. This ensures cleanup logic runs before garbage collection.

Watch and Informer Architecture

API Server
    │
    │  GET /api/v1/pods?watch=true&resourceVersion=12345
    │  (HTTP/2 streaming — stays open)
    │
    ▼
Controller / kubelet
    └─► Informer (client-go)
          ├─ ListWatch:    initial List + streaming Watch
          ├─ Local cache:  in-memory store of all objects
          ├─ Event queue:  Added / Modified / Deleted events
          └─ Handler:      reconcile function called per event

Benefits:
  - Reads from local cache (zero API server load)
  - Watch reconnects automatically on disconnect
  - ResourceVersion prevents replaying old events