@@ -72,16 +72,19 @@ import (
72
72
)
73
73
74
74
const (
75
- // Jitter used when starting controller managers
75
+ // ControllerStartJitter is the Jitter used when starting controller managers
76
76
ControllerStartJitter = 1.0
77
77
// ConfigzName is the name used for register kube-controller manager /configz, same with GroupName.
78
78
ConfigzName = "kubecontrollermanager.config.k8s.io"
79
79
)
80
80
81
+ // ControllerLoopMode is the kube-controller-manager's mode of running controller loops that are cloud provider dependent
81
82
type ControllerLoopMode int
82
83
83
84
const (
85
+ // IncludeCloudLoops means the kube-controller-manager include the controller loops that are cloud provider dependent
84
86
IncludeCloudLoops ControllerLoopMode = iota
87
+ // ExternalLoops means the kube-controller-manager exclude the controller loops that are cloud provider dependent
85
88
ExternalLoops
86
89
)
87
90
@@ -284,6 +287,7 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
284
287
panic ("unreachable" )
285
288
}
286
289
290
+ // ControllerContext defines the context object for controller
287
291
type ControllerContext struct {
288
292
// ClientBuilder will provide a client for this controller to use
289
293
ClientBuilder controller.ControllerClientBuilder
@@ -328,6 +332,7 @@ type ControllerContext struct {
328
332
ResyncPeriod func () time.Duration
329
333
}
330
334
335
+ // IsControllerEnabled checks if the context's controllers enabled or not
331
336
func (c ControllerContext ) IsControllerEnabled (name string ) bool {
332
337
return genericcontrollermanager .IsControllerEnabled (name , ControllersDisabledByDefault , c .ComponentConfig .Generic .Controllers )
333
338
}
@@ -337,6 +342,7 @@ func (c ControllerContext) IsControllerEnabled(name string) bool {
337
342
// The bool indicates whether the controller was enabled.
338
343
type InitFunc func (ctx ControllerContext ) (debuggingHandler http.Handler , enabled bool , err error )
339
344
345
+ // KnownControllers returns all known controllers's name
340
346
func KnownControllers () []string {
341
347
ret := sets .StringKeySet (NewControllerInitializers (IncludeCloudLoops ))
342
348
@@ -351,6 +357,7 @@ func KnownControllers() []string {
351
357
return ret .List ()
352
358
}
353
359
360
+ // ControllersDisabledByDefault is the set of controllers which is disabled by default
354
361
var ControllersDisabledByDefault = sets .NewString (
355
362
"bootstrapsigner" ,
356
363
"tokencleaner" ,
@@ -405,8 +412,9 @@ func NewControllerInitializers(loopMode ControllerLoopMode) map[string]InitFunc
405
412
return controllers
406
413
}
407
414
415
+ // GetAvailableResources gets the map which contains all available resources of the apiserver
408
416
// TODO: In general, any controller checking this needs to be dynamic so
409
- // users don't have to restart their controller manager if they change the apiserver.
417
+ // users don't have to restart their controller manager if they change the apiserver.
410
418
// Until we get there, the structure here needs to be exposed for the construction of a proper ControllerContext.
411
419
func GetAvailableResources (clientBuilder controller.ControllerClientBuilder ) (map [schema.GroupVersionResource ]bool , error ) {
412
420
client := clientBuilder .ClientOrDie ("controller-discovery" )
@@ -484,6 +492,7 @@ func CreateControllerContext(s *config.CompletedConfig, rootClientBuilder, clien
484
492
return ctx , nil
485
493
}
486
494
495
+ // StartControllers starts a set of controllers with a specified ControllerContext
487
496
func StartControllers (ctx ControllerContext , startSATokenController InitFunc , controllers map [string ]InitFunc , unsecuredMux * mux.PathRecorderMux ) error {
488
497
// Always start the SA token controller first using a full-power client, since it needs to mint tokens for the rest
489
498
// If this fails, just return here and fail since other controllers won't be able to get credentials.
0 commit comments