mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +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 {
|
||||
return &ControllerDescriptor{
|
||||
name: names.DaemonSetController,
|
||||
aliases: []string{"daemonset"},
|
||||
initFunc: startDaemonSetController,
|
||||
}
|
||||
}
|
||||
@ -60,6 +61,7 @@ func startDaemonSetController(ctx context.Context, controllerContext ControllerC
|
||||
func newStatefulSetControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.StatefulSetController,
|
||||
aliases: []string{"statefulset"},
|
||||
initFunc: startStatefulSetController,
|
||||
}
|
||||
}
|
||||
@ -78,6 +80,7 @@ func startStatefulSetController(ctx context.Context, controllerContext Controlle
|
||||
func newReplicaSetControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.ReplicaSetController,
|
||||
aliases: []string{"replicaset"},
|
||||
initFunc: startReplicaSetController,
|
||||
}
|
||||
}
|
||||
@ -96,6 +99,7 @@ func startReplicaSetController(ctx context.Context, controllerContext Controller
|
||||
func newDeploymentControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.DeploymentController,
|
||||
aliases: []string{"deployment"},
|
||||
initFunc: startDeploymentController,
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
func newHorizontalPodAutoscalerControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.HorizontalPodAutoscalerController,
|
||||
aliases: []string{"horizontalpodautoscaling"},
|
||||
initFunc: startHorizontalPodAutoscalerControllerWithRESTClient,
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
func newJobControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.JobController,
|
||||
aliases: []string{"job"},
|
||||
initFunc: startJobController,
|
||||
}
|
||||
}
|
||||
@ -53,6 +54,7 @@ func startJobController(ctx context.Context, controllerContext ControllerContext
|
||||
func newCronJobControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.CronJobController,
|
||||
aliases: []string{"cronjob"},
|
||||
initFunc: startCronJobController,
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
func newBootstrapSignerControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.BootstrapSignerController,
|
||||
aliases: []string{"bootstrapsigner"},
|
||||
initFunc: startBootstrapSignerController,
|
||||
isDisabledByDefault: true,
|
||||
}
|
||||
@ -49,6 +50,7 @@ func startBootstrapSignerController(ctx context.Context, controllerContext Contr
|
||||
func newTokenCleanerControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.TokenCleanerController,
|
||||
aliases: []string{"tokencleaner"},
|
||||
initFunc: startTokenCleanerController,
|
||||
isDisabledByDefault: true,
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import (
|
||||
func newCertificateSigningRequestSigningControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.CertificateSigningRequestSigningController,
|
||||
aliases: []string{"csrsigning"},
|
||||
initFunc: startCertificateSigningRequestSigningController,
|
||||
}
|
||||
}
|
||||
@ -159,6 +160,7 @@ func getLegacyUnknownSignerFiles(config csrsigningconfig.CSRSigningControllerCon
|
||||
func newCertificateSigningRequestApprovingControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.CertificateSigningRequestApprovingController,
|
||||
aliases: []string{"csrapproving"},
|
||||
initFunc: startCertificateSigningRequestApprovingController,
|
||||
}
|
||||
}
|
||||
@ -176,6 +178,7 @@ func startCertificateSigningRequestApprovingController(ctx context.Context, cont
|
||||
func newCertificateSigningRequestCleanerControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.CertificateSigningRequestCleanerController,
|
||||
aliases: []string{"csrcleaner"},
|
||||
initFunc: startCertificateSigningRequestCleanerController,
|
||||
}
|
||||
}
|
||||
@ -191,6 +194,7 @@ func startCertificateSigningRequestCleanerController(ctx context.Context, contro
|
||||
func newRootCACertificatePublisherControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.RootCACertificatePublisherController,
|
||||
aliases: []string{"root-ca-cert-publisher"},
|
||||
initFunc: startRootCACertificatePublisherController,
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ controller, and serviceaccounts controller.`,
|
||||
}
|
||||
cliflag.PrintFlags(cmd.Flags())
|
||||
|
||||
c, err := s.Config(KnownControllers(), ControllersDisabledByDefault(), names.KCMControllerAliases())
|
||||
c, err := s.Config(KnownControllers(), ControllersDisabledByDefault(), ControllerAliases())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -154,7 +154,7 @@ controller, and serviceaccounts controller.`,
|
||||
}
|
||||
|
||||
fs := cmd.Flags()
|
||||
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault(), names.KCMControllerAliases())
|
||||
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault(), ControllerAliases())
|
||||
verflag.AddFlags(namedFlagSets.FlagSet("global"))
|
||||
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name(), logs.SkipLoggingConfigurationFlags())
|
||||
registerLegacyGlobalFlags(namedFlagSets)
|
||||
@ -402,6 +402,7 @@ type ControllerDescriptor struct {
|
||||
name string
|
||||
initFunc InitFunc
|
||||
requiredFeatureGates []featuregate.Feature
|
||||
aliases []string
|
||||
isDisabledByDefault bool
|
||||
isCloudProviderController bool
|
||||
requiresSpecialHandling bool
|
||||
@ -419,6 +420,12 @@ func (r *ControllerDescriptor) GetRequiredFeatureGates() []featuregate.Feature {
|
||||
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 {
|
||||
return r.isDisabledByDefault
|
||||
}
|
||||
@ -437,6 +444,17 @@ func KnownControllers() []string {
|
||||
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 {
|
||||
var controllersDisabledByDefault []string
|
||||
|
||||
@ -456,8 +474,9 @@ func ControllersDisabledByDefault() []string {
|
||||
// This allows for structured downstream composition and subdivision.
|
||||
func NewControllerDescriptors() 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) {
|
||||
if controllerDesc == nil {
|
||||
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))
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@ -530,6 +557,12 @@ func NewControllerDescriptors() map[string]*ControllerDescriptor {
|
||||
register(newLegacyServiceAccountTokenCleanerControllerDescriptor())
|
||||
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
|
||||
}
|
||||
|
||||
@ -696,7 +729,8 @@ func StartControllers(ctx context.Context, controllerCtx ControllerContext, cont
|
||||
// It cannot use the "normal" client builder, so it tracks its own.
|
||||
func newServiceAccountTokenControllerDescriptor(rootClientBuilder clientbuilder.ControllerClientBuilder) *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) {
|
||||
return startServiceAccountTokenController(ctx, controllerContext, controllerName, rootClientBuilder)
|
||||
},
|
||||
|
@ -41,7 +41,7 @@ func TestControllerNamesConsistency(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestControllerNamesDeclaration(t *testing.T) {
|
||||
declaredControllers := sets.New(
|
||||
declaredControllers := sets.NewString(
|
||||
names.ServiceAccountTokenController,
|
||||
names.EndpointsController,
|
||||
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 {
|
||||
return &ControllerDescriptor{
|
||||
name: cpnames.ServiceLBController,
|
||||
aliases: []string{"service"},
|
||||
initFunc: startServiceLBController,
|
||||
isCloudProviderController: true,
|
||||
}
|
||||
@ -109,6 +110,7 @@ func startServiceLBController(ctx context.Context, controllerContext ControllerC
|
||||
func newNodeIpamControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.NodeIpamController,
|
||||
aliases: []string{"nodeipam"},
|
||||
initFunc: startNodeIpamController,
|
||||
}
|
||||
}
|
||||
@ -188,6 +190,7 @@ func startNodeIpamController(ctx context.Context, controllerContext ControllerCo
|
||||
func newNodeLifecycleControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.NodeLifecycleController,
|
||||
aliases: []string{"nodelifecycle"},
|
||||
initFunc: startNodeLifecycleController,
|
||||
}
|
||||
}
|
||||
@ -219,6 +222,7 @@ func startNodeLifecycleController(ctx context.Context, controllerContext Control
|
||||
func newCloudNodeLifecycleControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: cpnames.CloudNodeLifecycleController,
|
||||
aliases: []string{"cloud-node-lifecycle"},
|
||||
initFunc: startCloudNodeLifecycleController,
|
||||
isCloudProviderController: true,
|
||||
}
|
||||
@ -247,6 +251,7 @@ func startCloudNodeLifecycleController(ctx context.Context, controllerContext Co
|
||||
func newNodeRouteControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: cpnames.NodeRouteController,
|
||||
aliases: []string{"route"},
|
||||
initFunc: startNodeRouteController,
|
||||
isCloudProviderController: true,
|
||||
}
|
||||
@ -285,6 +290,7 @@ func startNodeRouteController(ctx context.Context, controllerContext ControllerC
|
||||
func newPersistentVolumeBinderControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.PersistentVolumeBinderController,
|
||||
aliases: []string{"persistentvolume-binder"},
|
||||
initFunc: startPersistentVolumeBinderController,
|
||||
}
|
||||
}
|
||||
@ -320,6 +326,7 @@ func startPersistentVolumeBinderController(ctx context.Context, controllerContex
|
||||
func newPersistentVolumeAttachDetachControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.PersistentVolumeAttachDetachController,
|
||||
aliases: []string{"attachdetach"},
|
||||
initFunc: startPersistentVolumeAttachDetachController,
|
||||
}
|
||||
}
|
||||
@ -363,6 +370,7 @@ func startPersistentVolumeAttachDetachController(ctx context.Context, controller
|
||||
func newPersistentVolumeExpanderControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.PersistentVolumeExpanderController,
|
||||
aliases: []string{"persistentvolume-expander"},
|
||||
initFunc: startPersistentVolumeExpanderController,
|
||||
}
|
||||
}
|
||||
@ -394,6 +402,7 @@ func startPersistentVolumeExpanderController(ctx context.Context, controllerCont
|
||||
func newEphemeralVolumeControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.EphemeralVolumeController,
|
||||
aliases: []string{"ephemeral-volume"},
|
||||
initFunc: startEphemeralVolumeController,
|
||||
}
|
||||
}
|
||||
@ -415,6 +424,7 @@ const defaultResourceClaimControllerWorkers = 10
|
||||
func newResourceClaimControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.ResourceClaimController,
|
||||
aliases: []string{"resource-claim-controller"},
|
||||
initFunc: startResourceClaimController,
|
||||
requiredFeatureGates: []featuregate.Feature{
|
||||
features.DynamicResourceAllocation,
|
||||
@ -440,6 +450,7 @@ func startResourceClaimController(ctx context.Context, controllerContext Control
|
||||
func newEndpointsControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.EndpointsController,
|
||||
aliases: []string{"endpoint"},
|
||||
initFunc: startEndpointsController,
|
||||
}
|
||||
}
|
||||
@ -458,6 +469,7 @@ func startEndpointsController(ctx context.Context, controllerContext ControllerC
|
||||
func newReplicationControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.ReplicationControllerController,
|
||||
aliases: []string{"replicationcontroller"},
|
||||
initFunc: startReplicationController,
|
||||
}
|
||||
}
|
||||
@ -476,6 +488,7 @@ func startReplicationController(ctx context.Context, controllerContext Controlle
|
||||
func newPodGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.PodGarbageCollectorController,
|
||||
aliases: []string{"podgc"},
|
||||
initFunc: startPodGarbageCollectorController,
|
||||
}
|
||||
}
|
||||
@ -494,6 +507,7 @@ func startPodGarbageCollectorController(ctx context.Context, controllerContext C
|
||||
func newResourceQuotaControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.ResourceQuotaController,
|
||||
aliases: []string{"resourcequota"},
|
||||
initFunc: startResourceQuotaController,
|
||||
}
|
||||
}
|
||||
@ -532,6 +546,7 @@ func startResourceQuotaController(ctx context.Context, controllerContext Control
|
||||
func newNamespaceControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.NamespaceController,
|
||||
aliases: []string{"namespace"},
|
||||
initFunc: startNamespaceController,
|
||||
}
|
||||
}
|
||||
@ -573,6 +588,7 @@ func startModifiedNamespaceController(ctx context.Context, controllerContext Con
|
||||
func newServiceAccountControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.ServiceAccountController,
|
||||
aliases: []string{"serviceaccount"},
|
||||
initFunc: startServiceAccountController,
|
||||
}
|
||||
}
|
||||
@ -594,6 +610,7 @@ func startServiceAccountController(ctx context.Context, controllerContext Contro
|
||||
func newTTLControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.TTLController,
|
||||
aliases: []string{"ttl"},
|
||||
initFunc: startTTLController,
|
||||
}
|
||||
}
|
||||
@ -610,6 +627,7 @@ func startTTLController(ctx context.Context, controllerContext ControllerContext
|
||||
func newGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.GarbageCollectorController,
|
||||
aliases: []string{"garbagecollector"},
|
||||
initFunc: startGarbageCollectorController,
|
||||
}
|
||||
}
|
||||
@ -661,6 +679,7 @@ func startGarbageCollectorController(ctx context.Context, controllerContext Cont
|
||||
func newPersistentVolumeClaimProtectionControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.PersistentVolumeClaimProtectionController,
|
||||
aliases: []string{"pvc-protection"},
|
||||
initFunc: startPersistentVolumeClaimProtectionController,
|
||||
}
|
||||
}
|
||||
@ -682,6 +701,7 @@ func startPersistentVolumeClaimProtectionController(ctx context.Context, control
|
||||
func newPersistentVolumeProtectionControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.PersistentVolumeProtectionController,
|
||||
aliases: []string{"pv-protection"},
|
||||
initFunc: startPersistentVolumeProtectionController,
|
||||
}
|
||||
}
|
||||
@ -698,6 +718,7 @@ func startPersistentVolumeProtectionController(ctx context.Context, controllerCo
|
||||
func newTTLAfterFinishedControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.TTLAfterFinishedController,
|
||||
aliases: []string{"ttl-after-finished"},
|
||||
initFunc: startTTLAfterFinishedController,
|
||||
}
|
||||
}
|
||||
@ -714,6 +735,7 @@ func startTTLAfterFinishedController(ctx context.Context, controllerContext Cont
|
||||
func newLegacyServiceAccountTokenCleanerControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.LegacyServiceAccountTokenCleanerController,
|
||||
aliases: []string{"legacy-service-account-token-cleaner"},
|
||||
initFunc: startLegacyServiceAccountTokenCleanerController,
|
||||
requiredFeatureGates: []featuregate.Feature{
|
||||
features.LegacyServiceAccountTokenCleanUp,
|
||||
@ -859,6 +881,7 @@ func setNodeCIDRMaskSizes(cfg nodeipamconfig.NodeIPAMControllerConfiguration, cl
|
||||
func newStorageVersionGarbageCollectorControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.StorageVersionGarbageCollectorController,
|
||||
aliases: []string{"storage-version-gc"},
|
||||
initFunc: startStorageVersionGarbageCollectorController,
|
||||
requiredFeatureGates: []featuregate.Feature{
|
||||
genericfeatures.APIServerIdentity,
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
func newEndpointSliceControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.EndpointSliceController,
|
||||
aliases: []string{"endpointslice"},
|
||||
initFunc: startEndpointSliceController,
|
||||
}
|
||||
}
|
||||
@ -52,6 +53,7 @@ func startEndpointSliceController(ctx context.Context, controllerContext Control
|
||||
func newEndpointSliceMirroringControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.EndpointSliceMirroringController,
|
||||
aliases: []string{"endpointslicemirroring"},
|
||||
initFunc: startEndpointSliceMirroringController,
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
func newDisruptionControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.DisruptionController,
|
||||
aliases: []string{"disruption"},
|
||||
initFunc: startDisruptionController,
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
func newClusterRoleAggregrationControllerDescriptor() *ControllerDescriptor {
|
||||
return &ControllerDescriptor{
|
||||
name: names.ClusterRoleAggregationController,
|
||||
aliases: []string{"clusterrole-aggregation"},
|
||||
initFunc: startClusterRoleAggregationController,
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import (
|
||||
"k8s.io/kubernetes/cmd/kube-controller-manager/app"
|
||||
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/names"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -97,7 +96,7 @@ func StartTestServer(ctx context.Context, customFlags []string) (result TestServ
|
||||
if err != nil {
|
||||
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)
|
||||
for _, f := range namedFlagSets.FlagSets {
|
||||
fs.AddFlagSet(f)
|
||||
|
@ -16,8 +16,6 @@ limitations under the License.
|
||||
|
||||
package names
|
||||
|
||||
import cpnames "k8s.io/cloud-provider/names"
|
||||
|
||||
// Canonical controller names
|
||||
//
|
||||
// NAMING CONVENTIONS
|
||||
@ -28,22 +26,21 @@ import cpnames "k8s.io/cloud-provider/names"
|
||||
// CHANGE POLICY
|
||||
// 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.
|
||||
// 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
|
||||
//
|
||||
// USE CASES
|
||||
// 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:
|
||||
// 2. defining an alias in KCMControllerAliases (for backwards compatibility only)
|
||||
// 3. used anywhere inside the controller itself:
|
||||
// 3.1. [TODO] logging should use a canonical controller name when referencing a controller (Eg. Starting X, Shutting down X)
|
||||
// 3.2. [TODO] emitted events should have an EventSource.Component set to the controller name (usually when initializing an EventRecorder)
|
||||
// 3.3. [TODO] registering ControllerManagerMetrics with ControllerStarted and ControllerStopped
|
||||
// 3.4. [TODO] calling WaitForNamedCacheSync
|
||||
// 4. defining controller options for "--help" command or generated documentation
|
||||
// 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
|
||||
// 1.2. when defined flag's help mentions a controller name
|
||||
// 5. defining a new service account for a new controller (old controllers may have inconsistent service accounts to stay backwards compatible)
|
||||
// 2. 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)
|
||||
// 2.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
|
||||
// 2.4. [TODO] calling WaitForNamedCacheSync
|
||||
// 3. 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
|
||||
// 3.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)
|
||||
const (
|
||||
ServiceAccountTokenController = "serviceaccount-token-controller"
|
||||
EndpointsController = "endpoints-controller"
|
||||
@ -85,54 +82,3 @@ const (
|
||||
LegacyServiceAccountTokenCleanerController = "legacy-serviceaccount-token-cleaner-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