kuberneteskubernetes-podkube-apiserver

How does the Kubernetes API server start a newly scheduled pod on a node?


I'm trying to get a better view 'under the hood' of how the Kubernetes Pod scheduling and creation process works, with respect to the interaction between kubelet and kube-apiserver.

I understand that the Kubernetes scheduler chooses a node to allocate a new pod to and notifies the API server of this. However, I am unclear how the API server notifies the kubelet on the node in question to start the pod. Is there a polling process within kubelet that queries the API server for changes? Or is there an event listener / call-back type interaction?

If anyone knows the answer or could point me in the direction of some documentation that would be greatly appreciated!


Solution

  • Alibaba had a really insightful blog post on the inner workings of the scheduler. From the blog:


    The scheduler basically works like this:


    On the Kubelet polling: Actually, the API server support a "watch" mode, which uses the WebSocket protocol. In this way the Kubelet is notified of any change to Pods with the Hostname equal to the hostname of the Kubelet.