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

Kubernetes Replication Controller的结构定义是什么

146次阅读
没有评论

共计 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字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 天堂资源最新在线 | 国产精品国产三级国产普通话 | 又大又黄又粗又爽的免费视频 | 日产免费线路一二区一去 | 男女交性视频免费播放 | 十八男男在线观看视频 | 欧美日韩亚洲精品一区 | 男女猛烈xx00免费视频试看 | 久久人妻av无码中文专区 | 美女被狂躁www离线观看视频 | 亚洲精品九色在线网站 | 亚洲第一极品精品无码久久 | 色噜噜狠狠狠狠色综合久 | 人妻美妇疯狂迎合 | 99久久99热久久精品免费看 | 黄色免费网站视频 | 国产精品嫩草影院一二三区 | 国产精品亚洲片在线 | 免费观看又色又爽又湿的视频软件 | 国产区精品一区二区不卡中文 | 欧美一级特黄aa大片视频 | 一本伊大人香蕉久久网手机 | h无码精品3d动漫在线观看 | 亚洲精品久久久口爆吞精 | 六月丁香婷婷色狠狠久久 | 精品国产成人系列 | 小说区图片区 | 在线看日本a毛片 | 国产精品va在线观看无码不卡 | 国产a级特黄的片子视频 | 欧美作爱福利免费观看视频 | 97夜夜澡人人爽人人免费 | 国产三级精品三级在线专区1 | 天天摸夜夜添狠狠添2018 | 日日摸夜夜添夜夜添特色大片 | 国产日本欧美在线观看 | 日本aⅴ在线观看 | 国产精品亚洲一区二区麻豆 | 亚洲精品久久久久久无码色欲四季 | 欧美日韩一区二区成人午夜电影 | 成人精品亚洲人成在线 |