Controllers

184

Controllers are control loops that watch the state of your cluster, then make or request changes where needed.

Stuff you wanna know:

  • A controller tracks at least one Kubernetes resource type. These objects have a spec field that represents the desired state. The controller(s) for that resource are responsible for making the current state come closer to that desired state.
  • Kubernetes uses lots of controllers that each manage a particular aspect of cluster state. Most commonly, a particular control loop (controller) uses one kind of resource as its desired state, and has a different kind of resource that it manages to make that desired state happen.
  • It’s useful to have simple controllers rather than one, monolithic set of control loops that are interlinked. Controllers can fail, so Kubernetes is designed to allow for that.
  • Controllers watch the shared state of your cluster through the apiserver (part of the Control Plane).
  • Controllers also update the objects that configure them. For example: once the work is done for a Job, the Job controller updates that Job object to mark it Finished.
  • Controllers run inside the control plane, providing control loops that are core to Kubernetes’ operations. For example: the deployment controller, the daemonset controller, the namespace controller, and the persistent volume controller (and others) all run within the kube-controller-manager.
  • You can find controllers that run outside the control plane, to extend Kubernetes. Or, if you want, you can write a new controller yourself.
  • You can run your own controller as a set of Pods, or externally to Kubernetes.
  • There can be several controllers that create or update the same kind of object. Behind the scenes, Kubernetes controllers make sure that they only pay attention to the resources linked to their controlling resource.
  • Kubernetes comes with a set of built-in controllers that run inside the kube-controller-manager. These built-in controllers provide important core behaviors. The Deployment controller and Job controller are examples of controllers that come as part of Kubernetes itself (“built-in” controllers).
  • Kubernetes lets you run a resilient control plane, so that if any of the built-in controllers were to fail, another part of the control plane will take over the work.

Ref: