Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

How a Simple Refrigerator Explains Kubernetes Controllers
Cloud Native 9 min read

How a Simple Refrigerator Explains Kubernetes Controllers

This article uses a straightforward refrigerator analogy to demystify Kubernetes controller concepts, covering core cluster components, the role of a unified entry point, controller and controller manager design, SharedInformer and ListWatcher mechanisms, and real‑world examples like Service and Route controllers.

Core Kubernetes Components

Kubernetes clusters consist of the etcd key‑value store, the API Server (cluster entry point), the Scheduler, the kube‑proxy, kubelet, and a set of Controllers that continuously reconcile desired state with actual state.

Kubernetes core components diagram
Kubernetes core components diagram

Refrigerator Analogy

A simple refrigerator is modelled with five subsystems: body, cooling system, lighting system, thermostat, and door. It provides two user‑visible functions:

Turn on the interior light when the door opens.

Adjust the cooling system temperature when the thermostat is set.

Refrigerator components
Refrigerator components

Unified Entry Point

The refrigerator exposes a single entry that offers two operations: Open/CloseDoor and SetThermostat. The entry updates the door state and thermostat configuration but cannot directly affect the light or cooling system.

Unified entry point
Unified entry point

Controller as a Bridge

A controller observes state changes on the entry and translates them into actions on the subsystems:

When the door state becomes Open, the controller turns on the interior light.

When the thermostat target temperature changes, the controller drives the cooling system to reach that temperature.

Controller logic
Controller logic

Controller Manager

Complex systems contain multiple independent controllers (e.g., lighting controller, cooling controller). A controller manager runs each controller in its own goroutine, monitors their health, and ensures they cooperate without interfering with each other.

Controller manager architecture
Controller manager architecture

SharedInformer

When many controllers need to watch the same resources, direct API Server queries create excessive load. SharedInformer acts as a proxy cache: it watches resources once, stores the latest state locally, and notifies each controller of events that match its interest. This reduces API Server traffic and latency.

SharedInformer diagram
SharedInformer diagram

ListWatcher

The core of SharedInformer is the ListWatcher mechanism, which combines:

List : an initial HTTP GET that retrieves the full set of objects.

Watch : a long‑running HTTP request using chunked transfer encoding. The API Server streams incremental changes as JSON objects in separate chunks, allowing controllers to react in near real‑time without re‑polling.

ListWatcher flow
ListWatcher flow
Chunked watch example
Chunked watch example

Real‑World Kubernetes Controllers

Typical in‑cluster controllers (Pod, Deployment, Service, ReplicaSet) are managed by kube-controller-manager. Cloud‑specific controllers (e.g., LoadBalancer Service, Route) are implemented in the cloud-controller-manager and interact with external APIs.

Service Controller

Workflow for a LoadBalancer Service:

User creates a Service of type LoadBalancer via the API Server.

API Server persists the Service object in etcd.

Service Controller watches the Service resource, detects the new LoadBalancer Service.

It calls the cloud provider’s OpenAPI to provision a cloud SLB (or equivalent).

It creates a corresponding Endpoints object that points to the SLB’s backend IPs.

Service controller flow
Service controller flow

Route Controller

When a new node joins the cluster, the Route Controller updates the VPC routing table to route traffic to the node’s Pod CIDR. The steps mirror the Service Controller: watch node events, invoke cloud‑provider APIs, and ensure the routing table reflects the current cluster topology.

Route controller flow
Route controller flow

Key Takeaways

Kubernetes controllers embody the “brain” of the cluster: they continuously observe desired state (stored in etcd), compute the required actions, and drive the actual state toward the goal. The controller manager orchestrates multiple controllers, while SharedInformer and ListWatcher provide efficient, scalable event delivery, preventing the API Server from becoming a bottleneck.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Report an issue with this article
KubernetesControllersSharedInformerListWatcher

Reader feedback

Was this useful?

Useful0

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion