Controller is a process in k8s which runs in the background and monitors the resource config in etcd
for state changes. When the state of the resource changes, it makes necessary changes to the cluster to match the new state.
All of the k8s resource types have controllers that monitor their state in the etcd
and make necessary changes to the cluster. If a request to modify something in the cluster is approved by the kube-apiserver
, the changes are written to the etcd
store. The controller monitoring that resource is responsible to make the necessary changes.
When a deployment is created, updated or deleted in K8s, the up-to-date manifest is stored in the etcd
database. The deployment controller continuously monitors the state of the deployment objects in the etcd
store. When the deployment is first created, the deployment controller creates a ReplicaSet object in the etcd
, after which the ReplicaSet controller creates the necessary Pod objects in the etcd
.