更多关于kubernetes的深入文章,请看我csdn或者oschina的博客主页。
libcni
cni项目提供了golang写的一个library,定义了集成cni插件的应用需调用的cni plugin接口,它就是libcni。其对应的Interface定义如下:
libcni/api.go:51
type CNI interface {
AddNetworkList(net *NetworkConfigList, rt *RuntimeConf) (types.Result, error)
DelNetworkList(net *NetworkConfigList, rt *RuntimeConf) error
AddNetwork(net *NetworkConfig, rt *RuntimeConf) (types.Result, error)
DelNetwork(net *NetworkConfig, rt *RuntimeConf) error
}
CNI Plugin在kubelet管理的PLEG中何时被调用
kubelet Run方法方法中会最终调用syncLoopIteration函数,由它通过各种channel对pod进行sync。
pkg/kubelet/kubelet.go:1794
// syncLoopIteration reads from various channels and dispatches pods to the
// given handler.
//
// Arguments:
// 1. configCh: a channel to read config events from
// 2. handler: the SyncHandler to dispatch pods to
// 3. syncCh: a channel to read periodic sync events from
// 4. houseKeepingCh: a channel to read housekeeping events from
// 5. plegCh: a channel to read PLEG updates from
//
// Events are also read from the kubelet liveness manager's update channel.
//
深入理解kubernetes与CNI Plugin交互机制

本文详细解析了kubelet如何通过CNI Plugin管理Pod的网络生命周期,包括HandlePodSyncs、HandlePodUpdates、HandlePodAdditions、HandlePodRemoves、HandlePodReconcile等关键操作,以及CNIConfig的AddNetwork和DelNetwork接口在Pod网络设置和清理中的作用。通过kubelet的代码流程图,揭示了CNI Plugin在kubernetes中的核心功能。
最低0.47元/天 解锁文章
665

被折叠的 条评论
为什么被折叠?



