Kubernetes: from kubectl apply to a running container

Nothing calls the next step. Every component watches the API server and writes back what it did.

Source
kubernetes/kubernetes @ 22faa13
Checked
8 boxes, 11 arrows, 24 source lines
Drawn
, by an AI agent
Press play to watch the page being drawn. The video has no sound.

What it shows

Nothing in Kubernetes tells anything else what to do. Every component watches the API server for the objects it cares about and writes back what it did. The diagram follows one kubectl apply of a Deployment through that loop.

  1. kubectl apply sends the Deployment to the API server, which stores it in etcd. The API server is the only component that talks to etcd.
  2. The Deployment controller is watching Deployments. It sees the new one and creates a ReplicaSet for it.
  3. The ReplicaSet controller is watching ReplicaSets. It finds one with fewer Pods than it should have and creates the missing Pods.
  4. The scheduler is watching Pods. It picks a node for each Pod that has none and records the choice as a binding.
  5. The kubelet on that node is watching the Pods assigned to it. Through the Container Runtime Interface it asks the container runtime to create the Pod's sandbox and start its containers, then reports the Pod's status.

No step calls the next. Each one is a separate loop that would do the same whoever created the object. That is why you can create a ReplicaSet by hand, or run a different scheduler, and the rest keeps working.

Where every box and arrow comes from

Before this drawing was accepted, a script looked up each box and each arrow in kubernetes/kubernetes at commit 22faa13 (20 November 2026) and failed if one was missing. These are the lines it found.

Arrows
From, toProof in the source
kubectl apply → API server1 apply
API server → etcdstore
API server → Deployment controllerwatch
Deployment controller → API server2 create ReplicaSet
  • pkg/controller/deployment/sync.go:245it creates the ReplicaSet for the new versioncreatedRS, err := dc.client.AppsV1().ReplicaSets(d.Namespace).Create(ctx, &newRS, metav1.CreateOptions{})
API server → ReplicaSet controllerwatch
ReplicaSet controller → API server3 create Pods
API server → Schedulerwatch
  • pkg/scheduler/eventhandlers.go:724the scheduler is told about Pods, including those that have no node yetif handlerRegistration, err = informerFactory.Core().V1().Pods().Informer().AddEventHandlerWithOptions(cache.ResourceEventHandlerFuncs{
Scheduler → API server4 bind to node
  • pkg/scheduler/schedule_one.go:436once a node is chosen the Pod is bound to itif status := sched.bind(ctx, schedFramework, assumedPod, scheduleResult.SuggestedHost, state); !status.IsSuccess() {
  • pkg/scheduler/util/utils.go:110by recording the choice through the API serverreturn cs.CoreV1().Pods(binding.Namespace).Bind(ctx, binding, metav1.CreateOptions{})
API server → Kubeletwatch
  • pkg/kubelet/config/apiserver.go:37the kubelet watches the Pods assigned to its own nodelw := cache.NewListWatchFromClient(c.CoreV1().RESTClient(), "pods", metav1.NamespaceAll, fields.OneTermEqualSelector("spec.nodeName", string(nodeName)))
Kubelet → API serverstatus
  • pkg/kubelet/status/status_manager.go:1408and reports the state of each Pod backnewPod, patchBytes, unchanged, err := statusutil.PatchPodStatus(ctx, m.kubeClient, pod.Namespace, pod.Name, pod.UID, pod.Status, mergedStatus)
Kubelet → Container runtime5 start containers
Boxes
BoxProof in the source
kubectl apply
API server
etcd

A separate project. The API server is the only component that talks to it.

Deployment controller
ReplicaSet controller
Scheduler
Kubelet
  • pkg/kubelet/kubelet.go:2183makes one Pod on this node match its descriptionfunc (kl *Kubelet) SyncPod(ctx context.Context, updateType kubetypes.SyncPodType, pod, mirrorPod *v1.Pod, podStatus *kubecontainer.PodStatus, allocatedGeneratio
Container runtime

A separate program on the node, reached through the Container Runtime Interface.

How it was made

An AI agent read the project's source at the commit above and drew this page on a WireMagic canvas through Agent Bridge, the same tools any agent gets when you connect it to the app. The result is an ordinary WireMagic file: download it, open it, and move things around.

You can have your own agent do this for a codebase you know. Connect it, then ask it to draw the architecture of the repository.