8

Kubernetes Client Shared Informer 架构设计源码阅读 | 云原生社区

 3 years ago
source link: https://cloudnative.to/blog/kubernetes-client-sharedinformer/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Kubernetes Client Shared Informer 架构设计源码阅读
kubernetes-client-sharedinformer

Kubernetes client shared informer 架构设计源码阅读

本文研究了 Kubernetes 中 Client Shared Informer 部分的源码,配备源码进行进一步理解,可以加深理解,增强相关设计能力。

作者 杨鼎睿 发表于 2021年4月27日

本文研究了 Kubernetes 中 Client Shared Informer 部分的源码,配备源码进行进一步理解,可以加深理解,增强相关设计能力。

Workflow

从接口间关系可以看出,SharedInformer 是核心组件,它通过 Controller 执行操作,并将结果存入 Store 中。SharedIndexInformer 为 SharedInformer 添加了 Index 功能。

shared-informer-workflow.svg

Procedure

shared-informer-procedures.svg

image.png

Add Handler

shared-informer-processor-listener.svg

ListAndWatch

shared-informer-list-and-watch.svg

image.png

Indexer

shared-informer-indexer.svg

[1] cache 根据 Object 生成 Key 的方式如下

image.png

[2] items 根据 Key 获取老对象,并设置新对象

image.png

[3] updateIndices 代码如下

image.png

[4] sharedIndexInformer 在创建 processorListener 时,如果处于工作状态,会调用 indexer 的 List 方法将全部缓存的 object 取出,并发送给新添加的 processorListener。

image.png

最终获取全部事件对象位置

image.png

本文研究了 Kubernetes 中 Client Shared Informer 部分的源码,是 Client 篇的第一部分,下面是全系列的链接。

暂时只有 Client 和 Scheduler 部分

[1] Others

[2] Basics

[3] API Server

[4] Client

[5] Proxy

[6] Controllers

[7] Scheduler

0 comments

Be the first person to leave a comment!

云原生社区是一个中立的云原生终端用户社区,由 CNCF 大使、开源意见领袖共同发起成立于 2020 年 5 月 12 日,旨在推广云原生技术,构建开发者生态。

北京|上海|成都|深圳|杭州|广州|武汉|南京|西安|大连|长沙|苏州|珠海|重庆|济南|厦门|无锡|青岛|郑州|合肥

关注云原生社区微信公众号,加入社区并获取最新资讯。

wechat-qrcode.png

Copyright © 2021 云原生社区


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK