master
dongming 2 years ago
parent 3687aaf40a
commit a56cbd485f

@ -31,6 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/runtime/inject"
) )
// 和 k8s 通讯的客户端。也就是和 kube-apiserver 通讯的组件(包括但不仅仅包括 客户端,缓存,同步机制。。。)
type cluster struct { type cluster struct {
// config is the rest.config used to talk to the apiserver. Required. // config is the rest.config used to talk to the apiserver. Required.
config *rest.Config config *rest.Config

@ -88,12 +88,12 @@ type ControllerConfigurationSpec struct {
// e.g. ReplicaSet in apps group (regardless of version) would be `ReplicaSet.apps`. // e.g. ReplicaSet in apps group (regardless of version) would be `ReplicaSet.apps`.
// //
// +optional // +optional
GroupKindConcurrency map[string]int `json:"groupKindConcurrency,omitempty"` GroupKindConcurrency map[string]int `json:"groupKindConcurrency,omitempty"` // 控制并发的映射
// CacheSyncTimeout refers to the time limit set to wait for syncing caches. // CacheSyncTimeout refers to the time limit set to wait for syncing caches.
// Defaults to 2 minutes if not set. // Defaults to 2 minutes if not set.
// +optional // +optional
CacheSyncTimeout *time.Duration `json:"cacheSyncTimeout,omitempty"` CacheSyncTimeout *time.Duration `json:"cacheSyncTimeout,omitempty"` // 缓存同步超时时间
} }
// ControllerMetrics defines the metrics configs. // ControllerMetrics defines the metrics configs.

@ -67,29 +67,29 @@ type controllerManager struct {
sync.Mutex sync.Mutex
started bool started bool
stopProcedureEngaged *int64 stopProcedureEngaged *int64 // 已停止程序的计数器
errChan chan error errChan chan error // 错误通知的管道
runnables *runnables runnables *runnables // 一些 manager 维护的子进程
// cluster holds a variety of methods to interact with a cluster. Required. // cluster holds a variety of methods to interact with a cluster. Required.
cluster cluster.Cluster cluster cluster.Cluster // 和 cluster进行通讯的一组方法
// recorderProvider is used to generate event recorders that will be injected into Controllers // recorderProvider is used to generate event recorders that will be injected into Controllers
// (and EventHandlers, Sources and Predicates). // (and EventHandlers, Sources and Predicates).
recorderProvider *intrec.Provider recorderProvider *intrec.Provider // 事件记录器,负责将事件传播出去,包括 events 资源和 log
// resourceLock forms the basis for leader election // resourceLock forms the basis for leader election
resourceLock resourcelock.Interface resourceLock resourcelock.Interface // leader 选举过程中的通用方法集,用来锁定任意资源
// leaderElectionReleaseOnCancel defines if the manager should step back from the leader lease // leaderElectionReleaseOnCancel defines if the manager should step back from the leader lease
// on shutdown // on shutdown
leaderElectionReleaseOnCancel bool leaderElectionReleaseOnCancel bool
// metricsListener is used to serve prometheus metrics // metricsListener is used to serve prometheus metrics
metricsListener net.Listener metricsListener net.Listener // 监控的网络访问方法集
// metricsExtraHandlers contains extra handlers to register on http server that serves metrics. // metricsExtraHandlers contains extra handlers to register on http server that serves metrics.
metricsExtraHandlers map[string]http.Handler metricsExtraHandlers map[string]http.Handler // 监控的网络访问 handler 映射
// healthProbeListener is used to serve liveness probe // healthProbeListener is used to serve liveness probe
healthProbeListener net.Listener healthProbeListener net.Listener

@ -409,6 +409,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
} }
// 重点关注runnables。 // 重点关注runnables。
// 是一些可以运行的对象,这些对象被 manager 所管理,来完成不同任务
errChan := make(chan error) errChan := make(chan error)
runnables := newRunnables(options.BaseContext, errChan) runnables := newRunnables(options.BaseContext, errChan)

Loading…
Cancel
Save