Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes kubelet如何将事件同步到apiserver?_Kubernetes_Kubelet_Kubernetes Apiserver - Fatal编程技术网

Kubernetes kubelet如何将事件同步到apiserver?

Kubernetes kubelet如何将事件同步到apiserver?,kubernetes,kubelet,kubernetes-apiserver,Kubernetes,Kubelet,Kubernetes Apiserver,最近我研究了kubelet如何将事件同步到apiserver,但我找不到代码所在的位置。kubelet的源代码是可用的 Kubelet可以通过多种方式获得本地节点所需的Pod配置。最重要的方式是Apiserver。Kubelet还可以通过指定文件目录或访问指定的HTTP端口来获得Pod配置 启动Kubelet时,将创建一个PodConfig对象。 代码: PodConfig本质上是Pod配置的多路复用器。内置mux可以监听各种Pod配置的源,包括apiserver、文件和http,并定期同步源的

最近我研究了kubelet如何将事件同步到apiserver,但我找不到代码所在的位置。

kubelet的源代码是可用的

Kubelet可以通过多种方式获得本地节点所需的Pod配置。最重要的方式是Apiserver。Kubelet还可以通过指定文件目录或访问指定的HTTP端口来获得Pod配置

启动Kubelet时,将创建一个PodConfig对象。 代码:

PodConfig本质上是Pod配置的多路复用器。内置mux可以监听各种Pod配置的源,包括apiserver、文件和http,并定期同步源的Pod配置状态

代码:

Op定义吊舱更换类型。例如,这些值可以是ADD或REMOVE。最后,所有类型的PodUpdate都将被注入到podConfig的更新中。所以,只需要监听更新通道就可以获得本地节点的Pod配置更新

Kubelet启动完成后,将执行syncLoop功能。 代码:


下面的文章详细解释了整个过程:。

这是kubelet如何从apiserver获取配置的。但是kubelet是如何将OOM这样的消息记录到apiserver的呢?也许这会帮助您了解通信是如何工作的,
type PodConfig struct {
    pods *podStorage
    mux  *config.Mux

    // the channel of denormalized changes passed to listeners
    updates chan kubetypes.PodUpdate
    ...
}
type PodUpdate struct {
    Pods   []*v1.Pod
    Op     PodOperation
    Source string
}
// syncLoop is the main loop for processing changes. It watches for changes from
// three channels (file, apiserver, and http) and creates a union of them. For
// any new change seen, will run a sync against desired state and running state. If
// no changes are seen to the configuration, will synchronize the last known desired
// state every sync-frequency seconds. Never returns.
    func (kl *Kubelet) syncLoop(updates <-chan kubetypes.PodUpdate, handler SyncHandler) {
        ...
        for {
            ...
            if !kl.syncLoopIteration(updates, handler, syncTicker.C, housekeepingTicker.C, plegCh) {
                break
            }
            ...
    }