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

Kubernetes Replication Controller的结构定义是什么

149次阅读
没有评论

共计 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字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 国产三级中文字幕 | 亚洲精品久久久久久久久久久网站 | 国产成人精品综合网站 | 亚洲欧美精品一区 | 成人午夜特黄aaaaa片男男 | 四虎永久免费在线观看 | 久久久久成人精品无码中文字幕 | 久久国产精品久久精品国产 | 窝窝午夜看片七次郎青草视频 | 色综合久久88色综合天天小说 | 亚洲美女视频 | 国产色a | 性久久久久久久久 | 人妻丰满熟妇av无码片 | 日韩欧美在线播放 | 国产日韩精品欧美一区视频 | 非洲黑人性xxxx精品 | 国产日韩欧美不卡www | a中文字幕1区 | 亚洲成a人一区二区三区 | 91国内视频在线观看 | 国产一区二区在线播放 | 国产男女自拍视频 | 一区视频 | 免费高清a级毛片在线播放 免费高清不卡毛片在线看 免费高清成人性视频3p网站 | 爱逼综合| 四虎黄色网址 | 国产97色在线 | 国产 | 国产一区二区福利久久 | 亚洲男人的天堂网 | 国产精品自产拍高潮在线观看 | 精品人妻无码一区二区三区 | 久久香蕉综合精品国产 | 久久精品国产精品亚洲精品 | 国产精品白浆无码流出 | 国产成+人+综合+欧美 亚洲 | www.色噜噜| 欧美日韩在线成人免费视频大全 | 涩涩爱97| 国产精品视频一 | 久草网视频在线观看 |