|
|
|
@ -335,8 +335,10 @@ type LeaderElectionRunnable interface {
|
|
|
|
|
// New returns a new Manager for creating Controllers.
|
|
|
|
|
func New(config *rest.Config, options Options) (Manager, error) {
|
|
|
|
|
// Set default values for options fields
|
|
|
|
|
// 设置一些默认的选项,这里可能包含一些默认的方法。
|
|
|
|
|
options = setOptionsDefaults(options)
|
|
|
|
|
|
|
|
|
|
// 创建 cluster,里面会包含一些与 cluster 通讯的必要组件
|
|
|
|
|
cluster, err := cluster.New(config, func(clusterOptions *cluster.Options) {
|
|
|
|
|
clusterOptions.Scheme = options.Scheme
|
|
|
|
|
clusterOptions.MapperProvider = options.MapperProvider
|
|
|
|
@ -356,11 +358,13 @@ func New(config *rest.Config, options Options) (Manager, error) {
|
|
|
|
|
// Create the recorder provider to inject event recorders for the components.
|
|
|
|
|
// TODO(directxman12): the log for the event provider should have a context (name, tags, etc) specific
|
|
|
|
|
// to the particular controller that it's being injected into, rather than a generic one like is here.
|
|
|
|
|
// 创建一个记录器
|
|
|
|
|
recorderProvider, err := options.newRecorderProvider(config, cluster.GetScheme(), options.Logger.WithName("events"), options.makeBroadcaster)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 集群调度相关的数据
|
|
|
|
|
// Create the resource lock to enable leader election)
|
|
|
|
|
var leaderConfig *rest.Config
|
|
|
|
|
var leaderRecorderProvider *intrec.Provider
|
|
|
|
@ -386,6 +390,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建一个监控相关的数据
|
|
|
|
|
// Create the metrics listener. This will throw an error if the metrics bind
|
|
|
|
|
// address is invalid or already in use.
|
|
|
|
|
metricsListener, err := options.newMetricsListener(options.MetricsBindAddress)
|
|
|
|
@ -403,6 +408,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重点关注,runnables。
|
|
|
|
|
errChan := make(chan error)
|
|
|
|
|
runnables := newRunnables(options.BaseContext, errChan)
|
|
|
|
|
|
|
|
|
|