欢迎光临散文网 会员登陆 & 注册

深究Kubernetes源码-存储- 4 AttachDetachController机制流程分析

2022-09-09 15:04 作者:黑暗光影DIY  | 我要投稿

分析基于kubernetes v1.26 

2.2.2 AttachDetachController

AttachDetachController运用在kube-controller-manager中,关键启动流程如下,主要流程在reconciler.Run/pvcWorker/desiredStateOfWorldPopulator.Run三个协程中:

关键类图如下,包括核心Reconciler/ActualStateOfWorld/DesiredStateOfWorld/DesiredStateOfWorldPopuldator/OperationExecutor

其核心逻辑是调谐Pod和Volume以及Node之间的挂载关系,并执行调用VolumePlugin执行Attach/Detach

pvcWorker主要通过pvc informer调谐pvc,调谐pvc的条件是1)已绑定的pvc 2)使用pvc的pod已经调度到节点,ProcessVolume是其核心逻辑,将需要调谐的pod pvc加入到DesiredStateOfWorld volumesToAttach中,或从volumesToAttach中移除。

desiredStateOfWorldPopulator.Run主要是根据pod informer和DesriedStateOfWorld情况,通过AddPod/DeletePod,判断DesiredStateOfWorld中需要处理的volumesToAttach。

Reconciler.Run是ADController核心逻辑,主要是根据DesiredStateOfWorld和ActualStateOfWorld情况,执行Attach/Detach操作。

AttachVolume核心为《Volume Plugin机制》章节中描述,通过VolumePlugin执行Attach操作,不同Volume Plugin业务逻辑不同,例如CSI Volume Plugin会创建一个VolumeAttachment

DetachVolume与AttachVolume机制一致,最终会调用VolumePlugin执行Detach操作,不同VolumePlugin逻辑不同,CSI Plugin会删除Attach操作生成的VolumeAttachment


深究Kubernetes源码-存储- 4 AttachDetachController机制流程分析的评论 (共 条)

分享到微博请遵守国家法律