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.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How a Simple Refrigerator Explains Kubernetes 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesControllersSharedInformerListWatcher
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.