在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

Kubernetes Replication Controller的结构定义是什么

128次阅读
没有评论

共计 5318 个字符,预计需要花费 14 分钟才能阅读完成。

本篇内容主要讲解“Kubernetes Replication Controller 的结构定义是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让丸趣 TV 小编来带大家学习“Kubernetes Replication Controller 的结构定义是什么”吧!

ReplicationManager

ReplicationManager 就是 ReplicationController 控制器对象,方便在代码中和 ReplicationController Resource API Object 进行区分。下面代码是 ReplicationManager 的结构定义。

pkg/controller/replication/replication_controller.go:75
// ReplicationManager is responsible for synchronizing ReplicationController objects stored in the system with actual running pods.
type ReplicationManager struct {
 kubeClient clientset.Interface
 podControl controller.PodControlInterface
 // internalPodInformer is used to hold a personal informer. If we re using
 // a normal shared informer, then the informer will be started for us. If
 // we have a personal informer, we must start it ourselves. If you start
 // the controller using NewReplicationManager(passing SharedInformer), this
 // will be null
 internalPodInformer cache.SharedIndexInformer
 // An rc is temporarily suspended after creating/deleting these many replicas.
 // It resumes normal action after observing the watch events for them.
 burstReplicas int
 // To allow injection of syncReplicationController for testing.
 syncHandler func(rcKey string) error
 // A TTLCache of pod creates/deletes each rc expects to see.
 expectations *controller.UIDTrackingControllerExpectations
 // A store of replication controllers, populated by the rcController
 rcStore cache.StoreToReplicationControllerLister
 // Watches changes to all replication controllers
 rcController *cache.Controller
 // A store of pods, populated by the podController
 podStore cache.StoreToPodLister
 // Watches changes to all pods
 podController cache.ControllerInterface
 // podStoreSynced returns true if the pod store has been synced at least once.
 // Added as a member to the struct to allow injection for testing.
 podStoreSynced func() bool
 lookupCache *controller.MatchingCache
 // Controllers that need to be synced
 queue workqueue.RateLimitingInterface
 // garbageCollectorEnabled denotes if the garbage collector is enabled. RC
 // manager behaves differently if GC is enabled.
 garbageCollectorEnabled bool
}

重点对下面个几个对象介绍说明:

podControl: 提供 Create/Delete Pod 的操作接口。

burstReplicas: 每次批量 Create/Delete Pods 时允许并发的最大数量。

syncHandler: 真正执行 Replica Sync 的函数。

expectation: 维护的期望状态下的 Pod 的 Uid Cache,并且提供了修正该 Cache 的接口。

rcStore: ReplicationController Resource 对象的 Indexer, 数据由 rcController 提供和维护。

rcController: 用来 watch 所有 ReplicationController Resource,watch 到的 change 更新到 rcStore 中。

podStore: Pod 的 Indexer,数据由 podController 提供和维护。

podController: 用来 watch 所有 Pod Resource,watch 到的 change 更新到 podStore 中。

queue: 用来存放待 sync 的 RC,是一个 RateLimit 类型的 queue。

lookupCache: 提供 Pod 和 RC 匹配信息的 cache,以提高查询效率。

ReplicationController 在何处启动的

看过我我的博文: Kubernetes ResourceQuota Controller 内部实现原理及源码分析的可能有印象,里面也提到了 controller manager 是如何启动 ResourceQuotaController 的,ReplicationController 也是一样的。在 kube-controller-manager 调用 newControllerInitializers 进行控制器初始化的时候,将 startReplicationController 注册进去了,用来启动 ReplicationController 控制器。

cmd/kube-controller-manager/app/controllermanager.go:224
func newControllerInitializers() map[string]InitFunc {controllers := map[string]InitFunc{}
 controllers[endpoint] = startEndpointController
 controllers[replicationcontroller] = startReplicationController
 controllers[podgc] = startPodGCController
 controllers[resourcequota] = startResourceQuotaController
 controllers[namespace] = startNamespaceController
 controllers[serviceaccount] = startServiceAccountController
 controllers[garbagecollector] = startGarbageCollectorController
 controllers[daemonset] = startDaemonSetController
 controllers[job] = startJobController
 controllers[deployment] = startDeploymentController
 controllers[replicaset] = startReplicaSetController
 controllers[horizontalpodautoscaling] = startHPAController
 controllers[disruption] = startDisruptionController
 controllers[statefuleset] = startStatefulSetController
 controllers[cronjob] = startCronJobController
 controllers[certificatesigningrequests] = startCSRController
 return controllers
}

代码继续跟到 startReplicationController,很简单,启动一个 goroutine,调用 replicationcontroller.NewReplicationManager 创建一个 ReplicationManager 并执行其中 Run 方法开始工作。

cmd/kube-controller-manager/app/core.go:55
func startReplicationController(ctx ControllerContext) (bool, error) {
 go replicationcontroller.NewReplicationManager(ctx.InformerFactory.Pods().Informer(),
 ctx.ClientBuilder.ClientOrDie(replication-controller),
 ResyncPeriod(ctx.Options),
 replicationcontroller.BurstReplicas,
 int(ctx.Options.LookupCacheSizeForRC),
 ctx.Options.EnableGarbageCollector,
 ).Run(int(ctx.Options.ConcurrentRCSyncs), ctx.Stop)
 return true, nil
}

创建 ReplicationManager

上面分析到,controller-manager 通过 NewReplicationManager 创建一个 ReplicationManager 对象,其实就是 ReplicationController 控制器。

pkg/controller/replication/replication_controller.go:122
// NewReplicationManager creates a replication manager
func NewReplicationManager(podInformer cache.SharedIndexInformer, kubeClient clientset.Interface, resyncPeriod controller.ResyncPeriodFunc, burstReplicas int, lookupCacheSize int, garbageCollectorEnabled bool) *ReplicationManager {
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(v1core.EventSinkImpl{Interface: kubeClient.Core().Events()})
return newReplicationManager(
eventBroadcaster.NewRecorder(v1.EventSource{Component:  replication-controller}),
podInformer, kubeClient, resyncPeriod, burstReplicas, lookupCacheSize, garbageCollectorEnabled)

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-16发表,共计5318字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 熟妇人妻系列av无码一区二区 | 亚洲av无码不卡在线播放 | 极品丝袜高跟91白沙发在线 | 韩国美女vip内部福利视频在线 | 国产男女猛视频在线观看网站 | 欧美爽爽爽高清免费视频 | 嫩草影院未满十八岁禁止入内 | 久久精品在线观看 | 午夜成人影视 | 午夜视频在线观看免费视频 | 伊人久久大香线蕉亚洲五月天 | 日韩理论视频 | 欧美精品成人久久网站 | 久久久久久国产视频 | 欧美啪啪网址 | 成人精品一区二区三区 | 被窝国产理论一二三影院 | 可以看毛片的网址 | 日韩操操 | 亚洲嫩草影院久久精品 | 亚洲欧洲第一页 | 成人av.com | 99视频在线免费看 | 亚洲精品卡2卡3卡4卡5卡区 | 精品亚洲成a人片在线观看 精品亚洲成a人片在线观看少妇 | 免费国产自线拍一欧美视频 | 自拍亚洲国产 | 香蕉网久久 | 国产毛片久久久久久国产毛片 | 一级电影免费看 | 夜色sese | 日本高清毛片中文视频 | 国产成人av在线影院 | 欧美性猛交ⅹxxx乱大交妖精 | 久久人人爽人人爽人人片dvd | a级毛片免费观看在线 | 国语自产拍91在线a拍拍 | 国产精品亚洲综合一区 | 国产浮力草草影院ccyy | 十八禁无遮无挡动态图 | 国产精品福利片免费看 |