mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
move aliases into each registrable controller
This commit is contained in:
parent
a85779b4df
commit
b768967280
@ -37,6 +37,7 @@ import (
|
|||||||
func newDaemonSetControllerDescriptor() *ControllerDescriptor {
|
func newDaemonSetControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.DaemonSetController,
|
name: names.DaemonSetController,
|
||||||
|
aliases: []string{"daemonset"},
|
||||||
initFunc: startDaemonSetController,
|
initFunc: startDaemonSetController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,6 +61,7 @@ func startDaemonSetController(ctx context.Context, controllerContext ControllerC
|
|||||||
func newStatefulSetControllerDescriptor() *ControllerDescriptor {
|
func newStatefulSetControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.StatefulSetController,
|
name: names.StatefulSetController,
|
||||||
|
aliases: []string{"statefulset"},
|
||||||
initFunc: startStatefulSetController,
|
initFunc: startStatefulSetController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,6 +80,7 @@ func startStatefulSetController(ctx context.Context, controllerContext Controlle
|
|||||||
func newReplicaSetControllerDescriptor() *ControllerDescriptor {
|
func newReplicaSetControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ReplicaSetController,
|
name: names.ReplicaSetController,
|
||||||
|
aliases: []string{"replicaset"},
|
||||||
initFunc: startReplicaSetController,
|
initFunc: startReplicaSetController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,6 +99,7 @@ func startReplicaSetController(ctx context.Context, controllerContext Controller
|
|||||||
func newDeploymentControllerDescriptor() *ControllerDescriptor {
|
func newDeploymentControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.DeploymentController,
|
name: names.DeploymentController,
|
||||||
|
aliases: []string{"deployment"},
|
||||||
initFunc: startDeploymentController,
|
initFunc: startDeploymentController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ import (
|
|||||||
func newHorizontalPodAutoscalerControllerDescriptor() *ControllerDescriptor {
|
func newHorizontalPodAutoscalerControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.HorizontalPodAutoscalerController,
|
name: names.HorizontalPodAutoscalerController,
|
||||||
|
aliases: []string{"horizontalpodautoscaling"},
|
||||||
initFunc: startHorizontalPodAutoscalerControllerWithRESTClient,
|
initFunc: startHorizontalPodAutoscalerControllerWithRESTClient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
func newJobControllerDescriptor() *ControllerDescriptor {
|
func newJobControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.JobController,
|
name: names.JobController,
|
||||||
|
aliases: []string{"job"},
|
||||||
initFunc: startJobController,
|
initFunc: startJobController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,6 +54,7 @@ func startJobController(ctx context.Context, controllerContext ControllerContext
|
|||||||
func newCronJobControllerDescriptor() *ControllerDescriptor {
|
func newCronJobControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.CronJobController,
|
name: names.CronJobController,
|
||||||
|
aliases: []string{"cronjob"},
|
||||||
initFunc: startCronJobController,
|
initFunc: startCronJobController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
func newBootstrapSignerControllerDescriptor() *ControllerDescriptor {
|
func newBootstrapSignerControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.BootstrapSignerController,
|
name: names.BootstrapSignerController,
|
||||||
|
aliases: []string{"bootstrapsigner"},
|
||||||
initFunc: startBootstrapSignerController,
|
initFunc: startBootstrapSignerController,
|
||||||
isDisabledByDefault: true,
|
isDisabledByDefault: true,
|
||||||
}
|
}
|
||||||
@ -49,6 +50,7 @@ func startBootstrapSignerController(ctx context.Context, controllerContext Contr
|
|||||||
func newTokenCleanerControllerDescriptor() *ControllerDescriptor {
|
func newTokenCleanerControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.TokenCleanerController,
|
name: names.TokenCleanerController,
|
||||||
|
aliases: []string{"tokencleaner"},
|
||||||
initFunc: startTokenCleanerController,
|
initFunc: startTokenCleanerController,
|
||||||
isDisabledByDefault: true,
|
isDisabledByDefault: true,
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
func newCertificateSigningRequestSigningControllerDescriptor() *ControllerDescriptor {
|
func newCertificateSigningRequestSigningControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.CertificateSigningRequestSigningController,
|
name: names.CertificateSigningRequestSigningController,
|
||||||
|
aliases: []string{"csrsigning"},
|
||||||
initFunc: startCertificateSigningRequestSigningController,
|
initFunc: startCertificateSigningRequestSigningController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,6 +160,7 @@ func getLegacyUnknownSignerFiles(config csrsigningconfig.CSRSigningControllerCon
|
|||||||
func newCertificateSigningRequestApprovingControllerDescriptor() *ControllerDescriptor {
|
func newCertificateSigningRequestApprovingControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.CertificateSigningRequestApprovingController,
|
name: names.CertificateSigningRequestApprovingController,
|
||||||
|
aliases: []string{"csrapproving"},
|
||||||
initFunc: startCertificateSigningRequestApprovingController,
|
initFunc: startCertificateSigningRequestApprovingController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,6 +178,7 @@ func startCertificateSigningRequestApprovingController(ctx context.Context, cont
|
|||||||
func newCertificateSigningRequestCleanerControllerDescriptor() *ControllerDescriptor {
|
func newCertificateSigningRequestCleanerControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.CertificateSigningRequestCleanerController,
|
name: names.CertificateSigningRequestCleanerController,
|
||||||
|
aliases: []string{"csrcleaner"},
|
||||||
initFunc: startCertificateSigningRequestCleanerController,
|
initFunc: startCertificateSigningRequestCleanerController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,6 +194,7 @@ func startCertificateSigningRequestCleanerController(ctx context.Context, contro
|
|||||||
func newRootCACertificatePublisherControllerDescriptor() *ControllerDescriptor {
|
func newRootCACertificatePublisherControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.RootCACertificatePublisherController,
|
name: names.RootCACertificatePublisherController,
|
||||||
|
aliases: []string{"root-ca-cert-publisher"},
|
||||||
initFunc: startRootCACertificatePublisherController,
|
initFunc: startRootCACertificatePublisherController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ controller, and serviceaccounts controller.`,
|
|||||||
}
|
}
|
||||||
cliflag.PrintFlags(cmd.Flags())
|
cliflag.PrintFlags(cmd.Flags())
|
||||||
|
|
||||||
c, err := s.Config(KnownControllers(), ControllersDisabledByDefault(), names.KCMControllerAliases())
|
c, err := s.Config(KnownControllers(), ControllersDisabledByDefault(), ControllerAliases())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ controller, and serviceaccounts controller.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs := cmd.Flags()
|
fs := cmd.Flags()
|
||||||
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault(), names.KCMControllerAliases())
|
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault(), ControllerAliases())
|
||||||
verflag.AddFlags(namedFlagSets.FlagSet("global"))
|
verflag.AddFlags(namedFlagSets.FlagSet("global"))
|
||||||
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name(), logs.SkipLoggingConfigurationFlags())
|
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name(), logs.SkipLoggingConfigurationFlags())
|
||||||
registerLegacyGlobalFlags(namedFlagSets)
|
registerLegacyGlobalFlags(namedFlagSets)
|
||||||
@ -402,6 +402,7 @@ type ControllerDescriptor struct {
|
|||||||
name string
|
name string
|
||||||
initFunc InitFunc
|
initFunc InitFunc
|
||||||
requiredFeatureGates []featuregate.Feature
|
requiredFeatureGates []featuregate.Feature
|
||||||
|
aliases []string
|
||||||
isDisabledByDefault bool
|
isDisabledByDefault bool
|
||||||
isCloudProviderController bool
|
isCloudProviderController bool
|
||||||
requiresSpecialHandling bool
|
requiresSpecialHandling bool
|
||||||
@ -419,6 +420,12 @@ func (r *ControllerDescriptor) GetRequiredFeatureGates() []featuregate.Feature {
|
|||||||
return append([]featuregate.Feature(nil), r.requiredFeatureGates...)
|
return append([]featuregate.Feature(nil), r.requiredFeatureGates...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAliases returns aliases to ensure backwards compatibility and should never be removed!
|
||||||
|
// Only addition of new aliases is allowed, and only when a canonical name is changed (please see CHANGE POLICY of controller names)
|
||||||
|
func (r *ControllerDescriptor) GetAliases() []string {
|
||||||
|
return append([]string(nil), r.aliases...)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *ControllerDescriptor) IsDisabledByDefault() bool {
|
func (r *ControllerDescriptor) IsDisabledByDefault() bool {
|
||||||
return r.isDisabledByDefault
|
return r.isDisabledByDefault
|
||||||
}
|
}
|
||||||
@ -437,6 +444,17 @@ func KnownControllers() []string {
|
|||||||
return sets.StringKeySet(NewControllerDescriptors()).List()
|
return sets.StringKeySet(NewControllerDescriptors()).List()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ControllerAliases returns a mapping of aliases to canonical controller names
|
||||||
|
func ControllerAliases() map[string]string {
|
||||||
|
aliases := map[string]string{}
|
||||||
|
for name, c := range NewControllerDescriptors() {
|
||||||
|
for _, alias := range c.GetAliases() {
|
||||||
|
aliases[alias] = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aliases
|
||||||
|
}
|
||||||
|
|
||||||
func ControllersDisabledByDefault() []string {
|
func ControllersDisabledByDefault() []string {
|
||||||
var controllersDisabledByDefault []string
|
var controllersDisabledByDefault []string
|
||||||
|
|
||||||
@ -456,8 +474,9 @@ func ControllersDisabledByDefault() []string {
|
|||||||
// This allows for structured downstream composition and subdivision.
|
// This allows for structured downstream composition and subdivision.
|
||||||
func NewControllerDescriptors() map[string]*ControllerDescriptor {
|
func NewControllerDescriptors() map[string]*ControllerDescriptor {
|
||||||
controllers := map[string]*ControllerDescriptor{}
|
controllers := map[string]*ControllerDescriptor{}
|
||||||
|
aliases := sets.NewString()
|
||||||
|
|
||||||
// All of the controllers must have unique names, or else we will explode.
|
// All the controllers must fulfil common constraints, or else we will explode.
|
||||||
register := func(controllerDesc *ControllerDescriptor) {
|
register := func(controllerDesc *ControllerDescriptor) {
|
||||||
if controllerDesc == nil {
|
if controllerDesc == nil {
|
||||||
panic("received nil controller for a registration")
|
panic("received nil controller for a registration")
|
||||||
@ -470,8 +489,16 @@ func NewControllerDescriptors() map[string]*ControllerDescriptor {
|
|||||||
panic(fmt.Sprintf("controller name %q was registered twice", name))
|
panic(fmt.Sprintf("controller name %q was registered twice", name))
|
||||||
}
|
}
|
||||||
if controllerDesc.GetInitFunc() == nil {
|
if controllerDesc.GetInitFunc() == nil {
|
||||||
panic("received controller without an init function for a registration")
|
panic(fmt.Sprintf("controller %q does not have an init function", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, alias := range controllerDesc.GetAliases() {
|
||||||
|
if aliases.Has(alias) {
|
||||||
|
panic(fmt.Sprintf("controller %q has a duplicate alias %q", name, alias))
|
||||||
|
}
|
||||||
|
aliases.Insert(alias)
|
||||||
|
}
|
||||||
|
|
||||||
controllers[name] = controllerDesc
|
controllers[name] = controllerDesc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,6 +557,12 @@ func NewControllerDescriptors() map[string]*ControllerDescriptor {
|
|||||||
register(newLegacyServiceAccountTokenCleanerControllerDescriptor())
|
register(newLegacyServiceAccountTokenCleanerControllerDescriptor())
|
||||||
register(newValidatingAdmissionPolicyStatusControllerDescriptor())
|
register(newValidatingAdmissionPolicyStatusControllerDescriptor())
|
||||||
|
|
||||||
|
for _, alias := range aliases.UnsortedList() {
|
||||||
|
if _, ok := controllers[alias]; ok {
|
||||||
|
panic(fmt.Sprintf("alias %q conflicts with a controller name", alias))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return controllers
|
return controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,6 +730,7 @@ func StartControllers(ctx context.Context, controllerCtx ControllerContext, cont
|
|||||||
func newServiceAccountTokenControllerDescriptor(rootClientBuilder clientbuilder.ControllerClientBuilder) *ControllerDescriptor {
|
func newServiceAccountTokenControllerDescriptor(rootClientBuilder clientbuilder.ControllerClientBuilder) *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ServiceAccountTokenController,
|
name: names.ServiceAccountTokenController,
|
||||||
|
aliases: []string{"serviceaccount-token"},
|
||||||
initFunc: func(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) {
|
initFunc: func(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) {
|
||||||
return startServiceAccountTokenController(ctx, controllerContext, controllerName, rootClientBuilder)
|
return startServiceAccountTokenController(ctx, controllerContext, controllerName, rootClientBuilder)
|
||||||
},
|
},
|
||||||
|
@ -41,7 +41,7 @@ func TestControllerNamesConsistency(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestControllerNamesDeclaration(t *testing.T) {
|
func TestControllerNamesDeclaration(t *testing.T) {
|
||||||
declaredControllers := sets.New(
|
declaredControllers := sets.NewString(
|
||||||
names.ServiceAccountTokenController,
|
names.ServiceAccountTokenController,
|
||||||
names.EndpointsController,
|
names.EndpointsController,
|
||||||
names.EndpointSliceController,
|
names.EndpointSliceController,
|
||||||
@ -92,3 +92,7 @@ func TestControllerNamesDeclaration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewControllerDescriptorsShouldNotPanic(t *testing.T) {
|
||||||
|
NewControllerDescriptors()
|
||||||
|
}
|
||||||
|
@ -84,6 +84,7 @@ const (
|
|||||||
func newServiceLBControllerDescriptor() *ControllerDescriptor {
|
func newServiceLBControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: cpnames.ServiceLBController,
|
name: cpnames.ServiceLBController,
|
||||||
|
aliases: []string{"service"},
|
||||||
initFunc: startServiceLBController,
|
initFunc: startServiceLBController,
|
||||||
isCloudProviderController: true,
|
isCloudProviderController: true,
|
||||||
}
|
}
|
||||||
@ -109,6 +110,7 @@ func startServiceLBController(ctx context.Context, controllerContext ControllerC
|
|||||||
func newNodeIpamControllerDescriptor() *ControllerDescriptor {
|
func newNodeIpamControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.NodeIpamController,
|
name: names.NodeIpamController,
|
||||||
|
aliases: []string{"nodeipam"},
|
||||||
initFunc: startNodeIpamController,
|
initFunc: startNodeIpamController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,6 +190,7 @@ func startNodeIpamController(ctx context.Context, controllerContext ControllerCo
|
|||||||
func newNodeLifecycleControllerDescriptor() *ControllerDescriptor {
|
func newNodeLifecycleControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.NodeLifecycleController,
|
name: names.NodeLifecycleController,
|
||||||
|
aliases: []string{"nodelifecycle"},
|
||||||
initFunc: startNodeLifecycleController,
|
initFunc: startNodeLifecycleController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,6 +222,7 @@ func startNodeLifecycleController(ctx context.Context, controllerContext Control
|
|||||||
func newCloudNodeLifecycleControllerDescriptor() *ControllerDescriptor {
|
func newCloudNodeLifecycleControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: cpnames.CloudNodeLifecycleController,
|
name: cpnames.CloudNodeLifecycleController,
|
||||||
|
aliases: []string{"cloud-node-lifecycle"},
|
||||||
initFunc: startCloudNodeLifecycleController,
|
initFunc: startCloudNodeLifecycleController,
|
||||||
isCloudProviderController: true,
|
isCloudProviderController: true,
|
||||||
}
|
}
|
||||||
@ -247,6 +251,7 @@ func startCloudNodeLifecycleController(ctx context.Context, controllerContext Co
|
|||||||
func newNodeRouteControllerDescriptor() *ControllerDescriptor {
|
func newNodeRouteControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: cpnames.NodeRouteController,
|
name: cpnames.NodeRouteController,
|
||||||
|
aliases: []string{"route"},
|
||||||
initFunc: startNodeRouteController,
|
initFunc: startNodeRouteController,
|
||||||
isCloudProviderController: true,
|
isCloudProviderController: true,
|
||||||
}
|
}
|
||||||
@ -285,6 +290,7 @@ func startNodeRouteController(ctx context.Context, controllerContext ControllerC
|
|||||||
func newPersistentVolumeBinderControllerDescriptor() *ControllerDescriptor {
|
func newPersistentVolumeBinderControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.PersistentVolumeBinderController,
|
name: names.PersistentVolumeBinderController,
|
||||||
|
aliases: []string{"persistentvolume-binder"},
|
||||||
initFunc: startPersistentVolumeBinderController,
|
initFunc: startPersistentVolumeBinderController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,6 +326,7 @@ func startPersistentVolumeBinderController(ctx context.Context, controllerContex
|
|||||||
func newPersistentVolumeAttachDetachControllerDescriptor() *ControllerDescriptor {
|
func newPersistentVolumeAttachDetachControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.PersistentVolumeAttachDetachController,
|
name: names.PersistentVolumeAttachDetachController,
|
||||||
|
aliases: []string{"attachdetach"},
|
||||||
initFunc: startPersistentVolumeAttachDetachController,
|
initFunc: startPersistentVolumeAttachDetachController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,6 +370,7 @@ func startPersistentVolumeAttachDetachController(ctx context.Context, controller
|
|||||||
func newPersistentVolumeExpanderControllerDescriptor() *ControllerDescriptor {
|
func newPersistentVolumeExpanderControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.PersistentVolumeExpanderController,
|
name: names.PersistentVolumeExpanderController,
|
||||||
|
aliases: []string{"persistentvolume-expander"},
|
||||||
initFunc: startPersistentVolumeExpanderController,
|
initFunc: startPersistentVolumeExpanderController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,6 +402,7 @@ func startPersistentVolumeExpanderController(ctx context.Context, controllerCont
|
|||||||
func newEphemeralVolumeControllerDescriptor() *ControllerDescriptor {
|
func newEphemeralVolumeControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.EphemeralVolumeController,
|
name: names.EphemeralVolumeController,
|
||||||
|
aliases: []string{"ephemeral-volume"},
|
||||||
initFunc: startEphemeralVolumeController,
|
initFunc: startEphemeralVolumeController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -415,6 +424,7 @@ const defaultResourceClaimControllerWorkers = 10
|
|||||||
func newResourceClaimControllerDescriptor() *ControllerDescriptor {
|
func newResourceClaimControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ResourceClaimController,
|
name: names.ResourceClaimController,
|
||||||
|
aliases: []string{"resource-claim-controller"},
|
||||||
initFunc: startResourceClaimController,
|
initFunc: startResourceClaimController,
|
||||||
requiredFeatureGates: []featuregate.Feature{
|
requiredFeatureGates: []featuregate.Feature{
|
||||||
features.DynamicResourceAllocation,
|
features.DynamicResourceAllocation,
|
||||||
@ -440,6 +450,7 @@ func startResourceClaimController(ctx context.Context, controllerContext Control
|
|||||||
func newEndpointsControllerDescriptor() *ControllerDescriptor {
|
func newEndpointsControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.EndpointsController,
|
name: names.EndpointsController,
|
||||||
|
aliases: []string{"endpoint"},
|
||||||
initFunc: startEndpointsController,
|
initFunc: startEndpointsController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,6 +469,7 @@ func startEndpointsController(ctx context.Context, controllerContext ControllerC
|
|||||||
func newReplicationControllerDescriptor() *ControllerDescriptor {
|
func newReplicationControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ReplicationControllerController,
|
name: names.ReplicationControllerController,
|
||||||
|
aliases: []string{"replicationcontroller"},
|
||||||
initFunc: startReplicationController,
|
initFunc: startReplicationController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,6 +488,7 @@ func startReplicationController(ctx context.Context, controllerContext Controlle
|
|||||||
func newPodGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
func newPodGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.PodGarbageCollectorController,
|
name: names.PodGarbageCollectorController,
|
||||||
|
aliases: []string{"podgc"},
|
||||||
initFunc: startPodGarbageCollectorController,
|
initFunc: startPodGarbageCollectorController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,6 +507,7 @@ func startPodGarbageCollectorController(ctx context.Context, controllerContext C
|
|||||||
func newResourceQuotaControllerDescriptor() *ControllerDescriptor {
|
func newResourceQuotaControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ResourceQuotaController,
|
name: names.ResourceQuotaController,
|
||||||
|
aliases: []string{"resourcequota"},
|
||||||
initFunc: startResourceQuotaController,
|
initFunc: startResourceQuotaController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,6 +546,7 @@ func startResourceQuotaController(ctx context.Context, controllerContext Control
|
|||||||
func newNamespaceControllerDescriptor() *ControllerDescriptor {
|
func newNamespaceControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.NamespaceController,
|
name: names.NamespaceController,
|
||||||
|
aliases: []string{"namespace"},
|
||||||
initFunc: startNamespaceController,
|
initFunc: startNamespaceController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,6 +588,7 @@ func startModifiedNamespaceController(ctx context.Context, controllerContext Con
|
|||||||
func newServiceAccountControllerDescriptor() *ControllerDescriptor {
|
func newServiceAccountControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ServiceAccountController,
|
name: names.ServiceAccountController,
|
||||||
|
aliases: []string{"serviceaccount"},
|
||||||
initFunc: startServiceAccountController,
|
initFunc: startServiceAccountController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,6 +610,7 @@ func startServiceAccountController(ctx context.Context, controllerContext Contro
|
|||||||
func newTTLControllerDescriptor() *ControllerDescriptor {
|
func newTTLControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.TTLController,
|
name: names.TTLController,
|
||||||
|
aliases: []string{"ttl"},
|
||||||
initFunc: startTTLController,
|
initFunc: startTTLController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,6 +627,7 @@ func startTTLController(ctx context.Context, controllerContext ControllerContext
|
|||||||
func newGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
func newGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.GarbageCollectorController,
|
name: names.GarbageCollectorController,
|
||||||
|
aliases: []string{"garbagecollector"},
|
||||||
initFunc: startGarbageCollectorController,
|
initFunc: startGarbageCollectorController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,6 +679,7 @@ func startGarbageCollectorController(ctx context.Context, controllerContext Cont
|
|||||||
func newPersistentVolumeClaimProtectionControllerDescriptor() *ControllerDescriptor {
|
func newPersistentVolumeClaimProtectionControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.PersistentVolumeClaimProtectionController,
|
name: names.PersistentVolumeClaimProtectionController,
|
||||||
|
aliases: []string{"pvc-protection"},
|
||||||
initFunc: startPersistentVolumeClaimProtectionController,
|
initFunc: startPersistentVolumeClaimProtectionController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -682,6 +701,7 @@ func startPersistentVolumeClaimProtectionController(ctx context.Context, control
|
|||||||
func newPersistentVolumeProtectionControllerDescriptor() *ControllerDescriptor {
|
func newPersistentVolumeProtectionControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.PersistentVolumeProtectionController,
|
name: names.PersistentVolumeProtectionController,
|
||||||
|
aliases: []string{"pv-protection"},
|
||||||
initFunc: startPersistentVolumeProtectionController,
|
initFunc: startPersistentVolumeProtectionController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -698,6 +718,7 @@ func startPersistentVolumeProtectionController(ctx context.Context, controllerCo
|
|||||||
func newTTLAfterFinishedControllerDescriptor() *ControllerDescriptor {
|
func newTTLAfterFinishedControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.TTLAfterFinishedController,
|
name: names.TTLAfterFinishedController,
|
||||||
|
aliases: []string{"ttl-after-finished"},
|
||||||
initFunc: startTTLAfterFinishedController,
|
initFunc: startTTLAfterFinishedController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -714,6 +735,7 @@ func startTTLAfterFinishedController(ctx context.Context, controllerContext Cont
|
|||||||
func newLegacyServiceAccountTokenCleanerControllerDescriptor() *ControllerDescriptor {
|
func newLegacyServiceAccountTokenCleanerControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.LegacyServiceAccountTokenCleanerController,
|
name: names.LegacyServiceAccountTokenCleanerController,
|
||||||
|
aliases: []string{"legacy-service-account-token-cleaner"},
|
||||||
initFunc: startLegacyServiceAccountTokenCleanerController,
|
initFunc: startLegacyServiceAccountTokenCleanerController,
|
||||||
requiredFeatureGates: []featuregate.Feature{
|
requiredFeatureGates: []featuregate.Feature{
|
||||||
features.LegacyServiceAccountTokenCleanUp,
|
features.LegacyServiceAccountTokenCleanUp,
|
||||||
@ -859,6 +881,7 @@ func setNodeCIDRMaskSizes(cfg nodeipamconfig.NodeIPAMControllerConfiguration, cl
|
|||||||
func newStorageVersionGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
func newStorageVersionGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.StorageVersionGarbageCollectorController,
|
name: names.StorageVersionGarbageCollectorController,
|
||||||
|
aliases: []string{"storage-version-gc"},
|
||||||
initFunc: startStorageVersionGarbageCollectorController,
|
initFunc: startStorageVersionGarbageCollectorController,
|
||||||
requiredFeatureGates: []featuregate.Feature{
|
requiredFeatureGates: []featuregate.Feature{
|
||||||
genericfeatures.APIServerIdentity,
|
genericfeatures.APIServerIdentity,
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
func newEndpointSliceControllerDescriptor() *ControllerDescriptor {
|
func newEndpointSliceControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.EndpointSliceController,
|
name: names.EndpointSliceController,
|
||||||
|
aliases: []string{"endpointslice"},
|
||||||
initFunc: startEndpointSliceController,
|
initFunc: startEndpointSliceController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,6 +53,7 @@ func startEndpointSliceController(ctx context.Context, controllerContext Control
|
|||||||
func newEndpointSliceMirroringControllerDescriptor() *ControllerDescriptor {
|
func newEndpointSliceMirroringControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.EndpointSliceMirroringController,
|
name: names.EndpointSliceMirroringController,
|
||||||
|
aliases: []string{"endpointslicemirroring"},
|
||||||
initFunc: startEndpointSliceMirroringController,
|
initFunc: startEndpointSliceMirroringController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
func newDisruptionControllerDescriptor() *ControllerDescriptor {
|
func newDisruptionControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.DisruptionController,
|
name: names.DisruptionController,
|
||||||
|
aliases: []string{"disruption"},
|
||||||
initFunc: startDisruptionController,
|
initFunc: startDisruptionController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
func newClusterRoleAggregrationControllerDescriptor() *ControllerDescriptor {
|
func newClusterRoleAggregrationControllerDescriptor() *ControllerDescriptor {
|
||||||
return &ControllerDescriptor{
|
return &ControllerDescriptor{
|
||||||
name: names.ClusterRoleAggregationController,
|
name: names.ClusterRoleAggregationController,
|
||||||
|
aliases: []string{"clusterrole-aggregation"},
|
||||||
initFunc: startClusterRoleAggregationController,
|
initFunc: startClusterRoleAggregationController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import (
|
|||||||
"k8s.io/kubernetes/cmd/kube-controller-manager/app"
|
"k8s.io/kubernetes/cmd/kube-controller-manager/app"
|
||||||
kubecontrollerconfig "k8s.io/kubernetes/cmd/kube-controller-manager/app/config"
|
kubecontrollerconfig "k8s.io/kubernetes/cmd/kube-controller-manager/app/config"
|
||||||
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
|
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
|
||||||
"k8s.io/kubernetes/cmd/kube-controller-manager/names"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -97,7 +96,7 @@ func StartTestServer(ctx context.Context, customFlags []string) (result TestServ
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return TestServer{}, err
|
return TestServer{}, err
|
||||||
}
|
}
|
||||||
all, disabled, aliases := app.KnownControllers(), app.ControllersDisabledByDefault(), names.KCMControllerAliases()
|
all, disabled, aliases := app.KnownControllers(), app.ControllersDisabledByDefault(), app.ControllerAliases()
|
||||||
namedFlagSets := s.Flags(all, disabled, aliases)
|
namedFlagSets := s.Flags(all, disabled, aliases)
|
||||||
for _, f := range namedFlagSets.FlagSets {
|
for _, f := range namedFlagSets.FlagSets {
|
||||||
fs.AddFlagSet(f)
|
fs.AddFlagSet(f)
|
||||||
|
@ -16,8 +16,6 @@ limitations under the License.
|
|||||||
|
|
||||||
package names
|
package names
|
||||||
|
|
||||||
import cpnames "k8s.io/cloud-provider/names"
|
|
||||||
|
|
||||||
// Canonical controller names
|
// Canonical controller names
|
||||||
//
|
//
|
||||||
// NAMING CONVENTIONS
|
// NAMING CONVENTIONS
|
||||||
@ -28,22 +26,21 @@ import cpnames "k8s.io/cloud-provider/names"
|
|||||||
// CHANGE POLICY
|
// CHANGE POLICY
|
||||||
// The controller names should be treated as IDs.
|
// The controller names should be treated as IDs.
|
||||||
// They can only be changed if absolutely necessary. For example if an inappropriate name was chosen in the past, or if the scope of the controller changes.
|
// They can only be changed if absolutely necessary. For example if an inappropriate name was chosen in the past, or if the scope of the controller changes.
|
||||||
// When a name is changed, the old name should be aliased in KCMControllerAliases, while preserving all old aliases.
|
// When a name is changed, the old name should be aliased in app.ControllerDescriptor#GetAliases, while preserving all old aliases.
|
||||||
// This is done to achieve backwards compatibility
|
// This is done to achieve backwards compatibility
|
||||||
//
|
//
|
||||||
// USE CASES
|
// USE CASES
|
||||||
// The following places should use the controller name constants, when:
|
// The following places should use the controller name constants, when:
|
||||||
// 1. defining a new app.ControllerDescriptor so it can be used in app.NewControllerDescriptors or app.KnownControllers:
|
// 1. defining a new app.ControllerDescriptor so it can be used in app.NewControllerDescriptors or app.KnownControllers:
|
||||||
// 2. defining an alias in KCMControllerAliases (for backwards compatibility only)
|
// 2. used anywhere inside the controller itself:
|
||||||
// 3. used anywhere inside the controller itself:
|
// 2.1. [TODO] logging should use a canonical controller name when referencing a controller (Eg. Starting X, Shutting down X)
|
||||||
// 3.1. [TODO] logging should use a canonical controller name when referencing a controller (Eg. Starting X, Shutting down X)
|
// 2.2. [TODO] emitted events should have an EventSource.Component set to the controller name (usually when initializing an EventRecorder)
|
||||||
// 3.2. [TODO] emitted events should have an EventSource.Component set to the controller name (usually when initializing an EventRecorder)
|
// 2.3. [TODO] registering ControllerManagerMetrics with ControllerStarted and ControllerStopped
|
||||||
// 3.3. [TODO] registering ControllerManagerMetrics with ControllerStarted and ControllerStopped
|
// 2.4. [TODO] calling WaitForNamedCacheSync
|
||||||
// 3.4. [TODO] calling WaitForNamedCacheSync
|
// 3. defining controller options for "--help" command or generated documentation
|
||||||
// 4. defining controller options for "--help" command or generated documentation
|
// 3.1. controller name should be used to create a pflag.FlagSet when registering controller options (the name is rendered in a controller flag group header) in options.KubeControllerManagerOptions
|
||||||
// 1.1. controller name should be used to create a pflag.FlagSet when registering controller options (the name is rendered in a controller flag group header) in options.KubeControllerManagerOptions
|
// 3.2. when defined flag's help mentions a controller name
|
||||||
// 1.2. when defined flag's help mentions a controller name
|
// 4. defining a new service account for a new controller (old controllers may have inconsistent service accounts to stay backwards compatible)
|
||||||
// 5. defining a new service account for a new controller (old controllers may have inconsistent service accounts to stay backwards compatible)
|
|
||||||
const (
|
const (
|
||||||
ServiceAccountTokenController = "serviceaccount-token-controller"
|
ServiceAccountTokenController = "serviceaccount-token-controller"
|
||||||
EndpointsController = "endpoints-controller"
|
EndpointsController = "endpoints-controller"
|
||||||
@ -85,54 +82,3 @@ const (
|
|||||||
LegacyServiceAccountTokenCleanerController = "legacy-serviceaccount-token-cleaner-controller"
|
LegacyServiceAccountTokenCleanerController = "legacy-serviceaccount-token-cleaner-controller"
|
||||||
ValidatingAdmissionPolicyStatusController = "validatingadmissionpolicy-status-controller"
|
ValidatingAdmissionPolicyStatusController = "validatingadmissionpolicy-status-controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KCMControllerAliases returns a mapping of aliases to canonical controller names
|
|
||||||
//
|
|
||||||
// These aliases ensure backwards compatibility and should never be removed!
|
|
||||||
// Only addition of new aliases is allowed, and only when a canonical name is changed (please see CHANGE POLICY of controller names)
|
|
||||||
func KCMControllerAliases() map[string]string {
|
|
||||||
// return a new reference to achieve immutability of the mapping
|
|
||||||
return map[string]string{
|
|
||||||
"serviceaccount-token": ServiceAccountTokenController,
|
|
||||||
"endpoint": EndpointsController,
|
|
||||||
"endpointslice": EndpointSliceController,
|
|
||||||
"endpointslicemirroring": EndpointSliceMirroringController,
|
|
||||||
"replicationcontroller": ReplicationControllerController,
|
|
||||||
"podgc": PodGarbageCollectorController,
|
|
||||||
"resourcequota": ResourceQuotaController,
|
|
||||||
"namespace": NamespaceController,
|
|
||||||
"serviceaccount": ServiceAccountController,
|
|
||||||
"garbagecollector": GarbageCollectorController,
|
|
||||||
"daemonset": DaemonSetController,
|
|
||||||
"job": JobController,
|
|
||||||
"deployment": DeploymentController,
|
|
||||||
"replicaset": ReplicaSetController,
|
|
||||||
"horizontalpodautoscaling": HorizontalPodAutoscalerController,
|
|
||||||
"disruption": DisruptionController,
|
|
||||||
"statefulset": StatefulSetController,
|
|
||||||
"cronjob": CronJobController,
|
|
||||||
"csrsigning": CertificateSigningRequestSigningController,
|
|
||||||
"csrapproving": CertificateSigningRequestApprovingController,
|
|
||||||
"csrcleaner": CertificateSigningRequestCleanerController,
|
|
||||||
"ttl": TTLController,
|
|
||||||
"bootstrapsigner": BootstrapSignerController,
|
|
||||||
"tokencleaner": TokenCleanerController,
|
|
||||||
"nodeipam": NodeIpamController,
|
|
||||||
"nodelifecycle": NodeLifecycleController,
|
|
||||||
"service": cpnames.ServiceLBController,
|
|
||||||
"route": cpnames.NodeRouteController,
|
|
||||||
"cloud-node-lifecycle": cpnames.CloudNodeLifecycleController,
|
|
||||||
"persistentvolume-binder": PersistentVolumeBinderController,
|
|
||||||
"attachdetach": PersistentVolumeAttachDetachController,
|
|
||||||
"persistentvolume-expander": PersistentVolumeExpanderController,
|
|
||||||
"clusterrole-aggregation": ClusterRoleAggregationController,
|
|
||||||
"pvc-protection": PersistentVolumeClaimProtectionController,
|
|
||||||
"pv-protection": PersistentVolumeProtectionController,
|
|
||||||
"ttl-after-finished": TTLAfterFinishedController,
|
|
||||||
"root-ca-cert-publisher": RootCACertificatePublisherController,
|
|
||||||
"ephemeral-volume": EphemeralVolumeController,
|
|
||||||
"storage-version-gc": StorageVersionGarbageCollectorController,
|
|
||||||
"resource-claim-controller": ResourceClaimController,
|
|
||||||
"legacy-service-account-token-cleaner": LegacyServiceAccountTokenCleanerController,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user