Kubernetes - How does API Server / etcd know the status of each Pod? Kubernetes - How does API Server / etcd know the status of each Pod? kubernetes kubernetes

Kubernetes - How does API Server / etcd know the status of each Pod?


kubelet does everything on the node. A typical process to create a pod would be the following:

  1. By default, kubelet is hooked up to api-server through this "thing" called watch. It's a sort of pub/sub. So kubelet would be subscribed to "create pod" event, and api-server would notify it when a pod needs to be created.
  2. kubelet would get the container runtime (docker or rkt), along with other pod specifications, and would create the pod.

Note: There are more components involved here, like scheduler and controller manager (mentioned in your post as various mechanisms), but I will skip them.

  1. kubelet will make the necessary liveness and readiness probes and report back to api-server the status. Say success!
  2. api-server will update etcd (by adding the metadata of the pod) to keep the track of what is going on in the cluster.

At this point kubelet will be in charge of this pod. If the pod goes down, kubelet will report api-server, api-server will give the order to kill the pod, will spin up a new one, and again will update etcd server.

One thing to point out is that all components in k8s talk to api-server directly. So, controller manager or scheduler do not say kubelet what to do. Rather they say it to api-server, and api-server to kubelet.