Stage 3 · Build
Kubernetes Controllers in Go
Controller-runtime Deep Dive
Manager, client, cache, and builder API for production-ready Kubernetes controllers.
The Manager
The Manager coordinates all controllers and webhooks in a process. It handles shared concerns: API server connections, caches, health checks, leader election, and graceful shutdown.
Client API
The client.Client provides a unified interface for reading and writing Kubernetes resources. It automatically handles caching, serialization, and API version negotiation.
Cache and Indexes
The cache stores Kubernetes resources in memory. Reads are fast because they hit the local cache, not the API server. You can configure which resources are cached and add custom indexes.
Builder API
The builder API provides a fluent interface for configuring controller watches. It chains For, Owns, Watches, and Complete to set up the event pipeline.
Leader Election
Leader election ensures only one instance of your controller runs at a time. Multiple replicas compete for a lock, and only the leader processes reconcile events.
Health Probes
The manager exposes health endpoints for Kubernetes probes. These tell Kubernetes whether your controller is ready to receive traffic and whether it is still alive.
Without health probes, Kubernetes cannot detect when your controller is stuck or degraded. A controller with an unsynced cache will process stale data. The readyz check ensures traffic only reaches healthy instances.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.