diff --git a/cmd/controller-manager/app/options/BUILD b/cmd/controller-manager/app/options/BUILD index 83b848891f..26fd4c709c 100644 --- a/cmd/controller-manager/app/options/BUILD +++ b/cmd/controller-manager/app/options/BUILD @@ -3,29 +3,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = [ - "attachdetachcontroller.go", "cloudprovider.go", - "csrsigningcontroller.go", - "daemonsetcontroller.go", "debugging.go", - "deploymentcontroller.go", - "deprecatedcontroller.go", - "endpointcontroller.go", - "garbagecollectorcontroller.go", "generic.go", - "hpacontroller.go", "insecure_serving.go", - "jobcontroller.go", "kubecloudshared.go", - "namespacecontroller.go", - "nodeipamcontroller.go", - "nodelifecyclecontroller.go", - "persistentvolumebindercontroller.go", - "podgccontroller.go", - "replicasetcontroller.go", - "replicationcontroller.go", - "resourcequotacontroller.go", - "serviceaccountcontroller.go", "servicecontroller.go", ], importpath = "k8s.io/kubernetes/cmd/controller-manager/app/options", diff --git a/cmd/controller-manager/app/options/cloudprovider.go b/cmd/controller-manager/app/options/cloudprovider.go index 17541619d0..37a340e3b5 100644 --- a/cmd/controller-manager/app/options/cloudprovider.go +++ b/cmd/controller-manager/app/options/cloudprovider.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/debugging.go b/cmd/controller-manager/app/options/debugging.go index fa65caffc5..fefb015918 100644 --- a/cmd/controller-manager/app/options/debugging.go +++ b/cmd/controller-manager/app/options/debugging.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/generic.go b/cmd/controller-manager/app/options/generic.go index d32b975691..40d6631749 100644 --- a/cmd/controller-manager/app/options/generic.go +++ b/cmd/controller-manager/app/options/generic.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" "k8s.io/kubernetes/pkg/client/leaderelectionconfig" diff --git a/cmd/controller-manager/app/options/insecure_serving.go b/cmd/controller-manager/app/options/insecure_serving.go index aecb704462..ca379f1314 100644 --- a/cmd/controller-manager/app/options/insecure_serving.go +++ b/cmd/controller-manager/app/options/insecure_serving.go @@ -21,6 +21,7 @@ import ( "net" "github.com/spf13/pflag" + "k8s.io/apiserver/pkg/server/options" genericcontrollermanager "k8s.io/kubernetes/cmd/controller-manager/app" ) diff --git a/cmd/controller-manager/app/options/kubecloudshared.go b/cmd/controller-manager/app/options/kubecloudshared.go index c92c4a51b3..92135bd270 100644 --- a/cmd/controller-manager/app/options/kubecloudshared.go +++ b/cmd/controller-manager/app/options/kubecloudshared.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/servicecontroller.go b/cmd/controller-manager/app/options/servicecontroller.go index 26cdf8a3c7..b14142eca9 100644 --- a/cmd/controller-manager/app/options/servicecontroller.go +++ b/cmd/controller-manager/app/options/servicecontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/kube-controller-manager/app/BUILD b/cmd/kube-controller-manager/app/BUILD index 64c82a719a..e1a9bd54b5 100644 --- a/cmd/kube-controller-manager/app/BUILD +++ b/cmd/kube-controller-manager/app/BUILD @@ -20,7 +20,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//cmd/controller-manager/app:go_default_library", - "//cmd/controller-manager/app/options:go_default_library", "//cmd/kube-controller-manager/app/config:go_default_library", "//cmd/kube-controller-manager/app/options:go_default_library", "//pkg/apis/apps/install:go_default_library", diff --git a/cmd/kube-controller-manager/app/certificates.go b/cmd/kube-controller-manager/app/certificates.go index 9e6e70cf3f..23c1b3c1c4 100644 --- a/cmd/kube-controller-manager/app/certificates.go +++ b/cmd/kube-controller-manager/app/certificates.go @@ -27,7 +27,7 @@ import ( "github.com/golang/glog" "k8s.io/apimachinery/pkg/runtime/schema" - cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options" + kubeoptions "k8s.io/kubernetes/cmd/kube-controller-manager/app/options" "k8s.io/kubernetes/pkg/controller/certificates/approver" "k8s.io/kubernetes/pkg/controller/certificates/cleaner" "k8s.io/kubernetes/pkg/controller/certificates/signer" @@ -55,12 +55,12 @@ func startCSRSigningController(ctx ControllerContext) (bool, error) { _, err := os.Stat(ctx.ComponentConfig.CSRSigningController.ClusterSigningCertFile) certFileExists = !os.IsNotExist(err) - certUsesDefault = (ctx.ComponentConfig.CSRSigningController.ClusterSigningCertFile == cmoptions.DefaultClusterSigningCertFile) + certUsesDefault = (ctx.ComponentConfig.CSRSigningController.ClusterSigningCertFile == kubeoptions.DefaultClusterSigningCertFile) _, err = os.Stat(ctx.ComponentConfig.CSRSigningController.ClusterSigningKeyFile) keyFileExists = !os.IsNotExist(err) - keyUsesDefault = (ctx.ComponentConfig.CSRSigningController.ClusterSigningKeyFile == cmoptions.DefaultClusterSigningKeyFile) + keyUsesDefault = (ctx.ComponentConfig.CSRSigningController.ClusterSigningKeyFile == kubeoptions.DefaultClusterSigningKeyFile) switch { case (keyFileExists && keyUsesDefault) || (certFileExists && certUsesDefault): diff --git a/cmd/kube-controller-manager/app/options/BUILD b/cmd/kube-controller-manager/app/options/BUILD index 3bba70af88..9822d64a2a 100644 --- a/cmd/kube-controller-manager/app/options/BUILD +++ b/cmd/kube-controller-manager/app/options/BUILD @@ -8,7 +8,27 @@ load( go_library( name = "go_default_library", - srcs = ["options.go"], + srcs = [ + "attachdetachcontroller.go", + "csrsigningcontroller.go", + "daemonsetcontroller.go", + "deploymentcontroller.go", + "deprecatedcontroller.go", + "endpointcontroller.go", + "garbagecollectorcontroller.go", + "hpacontroller.go", + "jobcontroller.go", + "namespacecontroller.go", + "nodeipamcontroller.go", + "nodelifecyclecontroller.go", + "options.go", + "persistentvolumebindercontroller.go", + "podgccontroller.go", + "replicasetcontroller.go", + "replicationcontroller.go", + "resourcequotacontroller.go", + "serviceaccountcontroller.go", + ], importpath = "k8s.io/kubernetes/cmd/kube-controller-manager/app/options", deps = [ "//cmd/controller-manager/app/options:go_default_library", @@ -22,6 +42,7 @@ go_library( "//vendor/github.com/golang/glog:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", diff --git a/cmd/controller-manager/app/options/attachdetachcontroller.go b/cmd/kube-controller-manager/app/options/attachdetachcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/attachdetachcontroller.go rename to cmd/kube-controller-manager/app/options/attachdetachcontroller.go index f34d5ea464..8f620f4b95 100644 --- a/cmd/controller-manager/app/options/attachdetachcontroller.go +++ b/cmd/kube-controller-manager/app/options/attachdetachcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/csrsigningcontroller.go b/cmd/kube-controller-manager/app/options/csrsigningcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/csrsigningcontroller.go rename to cmd/kube-controller-manager/app/options/csrsigningcontroller.go index bf55c9df89..acd9d9be28 100644 --- a/cmd/controller-manager/app/options/csrsigningcontroller.go +++ b/cmd/kube-controller-manager/app/options/csrsigningcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/daemonsetcontroller.go b/cmd/kube-controller-manager/app/options/daemonsetcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/daemonsetcontroller.go rename to cmd/kube-controller-manager/app/options/daemonsetcontroller.go index df388edc78..2d3d3f526a 100644 --- a/cmd/controller-manager/app/options/daemonsetcontroller.go +++ b/cmd/kube-controller-manager/app/options/daemonsetcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/deploymentcontroller.go b/cmd/kube-controller-manager/app/options/deploymentcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/deploymentcontroller.go rename to cmd/kube-controller-manager/app/options/deploymentcontroller.go index 5b3db92662..481ffad448 100644 --- a/cmd/controller-manager/app/options/deploymentcontroller.go +++ b/cmd/kube-controller-manager/app/options/deploymentcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/deprecatedcontroller.go b/cmd/kube-controller-manager/app/options/deprecatedcontroller.go similarity index 97% rename from cmd/controller-manager/app/options/deprecatedcontroller.go rename to cmd/kube-controller-manager/app/options/deprecatedcontroller.go index 3b8d0a1cd0..b65683725a 100644 --- a/cmd/controller-manager/app/options/deprecatedcontroller.go +++ b/cmd/kube-controller-manager/app/options/deprecatedcontroller.go @@ -18,10 +18,12 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) // DeprecatedControllerOptions holds the DeprecatedController options, those option are deprecated. +// TODO remove these fields once the deprecated flags are removed. type DeprecatedControllerOptions struct { DeletingPodsQPS float32 DeletingPodsBurst int32 diff --git a/cmd/controller-manager/app/options/endpointcontroller.go b/cmd/kube-controller-manager/app/options/endpointcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/endpointcontroller.go rename to cmd/kube-controller-manager/app/options/endpointcontroller.go index 2457650c9e..37f7f79405 100644 --- a/cmd/controller-manager/app/options/endpointcontroller.go +++ b/cmd/kube-controller-manager/app/options/endpointcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/garbagecollectorcontroller.go b/cmd/kube-controller-manager/app/options/garbagecollectorcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/garbagecollectorcontroller.go rename to cmd/kube-controller-manager/app/options/garbagecollectorcontroller.go index 85cf45e9be..73d4e5fcd5 100644 --- a/cmd/controller-manager/app/options/garbagecollectorcontroller.go +++ b/cmd/kube-controller-manager/app/options/garbagecollectorcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/hpacontroller.go b/cmd/kube-controller-manager/app/options/hpacontroller.go similarity index 99% rename from cmd/controller-manager/app/options/hpacontroller.go rename to cmd/kube-controller-manager/app/options/hpacontroller.go index 39fae9d920..cbbb159c0d 100644 --- a/cmd/controller-manager/app/options/hpacontroller.go +++ b/cmd/kube-controller-manager/app/options/hpacontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/jobcontroller.go b/cmd/kube-controller-manager/app/options/jobcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/jobcontroller.go rename to cmd/kube-controller-manager/app/options/jobcontroller.go index 9269a3682d..97dc027728 100644 --- a/cmd/controller-manager/app/options/jobcontroller.go +++ b/cmd/kube-controller-manager/app/options/jobcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/namespacecontroller.go b/cmd/kube-controller-manager/app/options/namespacecontroller.go similarity index 99% rename from cmd/controller-manager/app/options/namespacecontroller.go rename to cmd/kube-controller-manager/app/options/namespacecontroller.go index 718e7c98bd..b6cd5e63ab 100644 --- a/cmd/controller-manager/app/options/namespacecontroller.go +++ b/cmd/kube-controller-manager/app/options/namespacecontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/nodeipamcontroller.go b/cmd/kube-controller-manager/app/options/nodeipamcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/nodeipamcontroller.go rename to cmd/kube-controller-manager/app/options/nodeipamcontroller.go index 65cea454b3..3bfad216eb 100644 --- a/cmd/controller-manager/app/options/nodeipamcontroller.go +++ b/cmd/kube-controller-manager/app/options/nodeipamcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/nodelifecyclecontroller.go b/cmd/kube-controller-manager/app/options/nodelifecyclecontroller.go similarity index 99% rename from cmd/controller-manager/app/options/nodelifecyclecontroller.go rename to cmd/kube-controller-manager/app/options/nodelifecyclecontroller.go index 0056555764..6c3ddeb09b 100644 --- a/cmd/controller-manager/app/options/nodelifecyclecontroller.go +++ b/cmd/kube-controller-manager/app/options/nodelifecyclecontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/kube-controller-manager/app/options/options.go b/cmd/kube-controller-manager/app/options/options.go index 2b26024e5e..d4149aa5ba 100644 --- a/cmd/kube-controller-manager/app/options/options.go +++ b/cmd/kube-controller-manager/app/options/options.go @@ -49,32 +49,37 @@ import ( "github.com/spf13/pflag" ) +const ( + // KubeControllerManagerUserAgent is the userAgent name when starting kube-controller managers. + KubeControllerManagerUserAgent = "kube-controller-manager" +) + // KubeControllerManagerOptions is the main context object for the kube-controller manager. type KubeControllerManagerOptions struct { - CloudProvider *cmoptions.CloudProviderOptions - Debugging *cmoptions.DebuggingOptions - GenericComponent *cmoptions.GenericComponentConfigOptions - KubeCloudShared *cmoptions.KubeCloudSharedOptions + CloudProvider *cmoptions.CloudProviderOptions + Debugging *cmoptions.DebuggingOptions + GenericComponent *cmoptions.GenericComponentConfigOptions + KubeCloudShared *cmoptions.KubeCloudSharedOptions + ServiceController *cmoptions.ServiceControllerOptions - AttachDetachController *cmoptions.AttachDetachControllerOptions - CSRSigningController *cmoptions.CSRSigningControllerOptions - DaemonSetController *cmoptions.DaemonSetControllerOptions - DeploymentController *cmoptions.DeploymentControllerOptions - DeprecatedFlags *cmoptions.DeprecatedControllerOptions - EndPointController *cmoptions.EndPointControllerOptions - GarbageCollectorController *cmoptions.GarbageCollectorControllerOptions - HPAController *cmoptions.HPAControllerOptions - JobController *cmoptions.JobControllerOptions - NamespaceController *cmoptions.NamespaceControllerOptions - NodeIpamController *cmoptions.NodeIpamControllerOptions - NodeLifecycleController *cmoptions.NodeLifecycleControllerOptions - PersistentVolumeBinderController *cmoptions.PersistentVolumeBinderControllerOptions - PodGCController *cmoptions.PodGCControllerOptions - ReplicaSetController *cmoptions.ReplicaSetControllerOptions - ReplicationController *cmoptions.ReplicationControllerOptions - ResourceQuotaController *cmoptions.ResourceQuotaControllerOptions - SAController *cmoptions.SAControllerOptions - ServiceController *cmoptions.ServiceControllerOptions + AttachDetachController *AttachDetachControllerOptions + CSRSigningController *CSRSigningControllerOptions + DaemonSetController *DaemonSetControllerOptions + DeploymentController *DeploymentControllerOptions + DeprecatedFlags *DeprecatedControllerOptions + EndPointController *EndPointControllerOptions + GarbageCollectorController *GarbageCollectorControllerOptions + HPAController *HPAControllerOptions + JobController *JobControllerOptions + NamespaceController *NamespaceControllerOptions + NodeIpamController *NodeIpamControllerOptions + NodeLifecycleController *NodeLifecycleControllerOptions + PersistentVolumeBinderController *PersistentVolumeBinderControllerOptions + PodGCController *PodGCControllerOptions + ReplicaSetController *ReplicaSetControllerOptions + ReplicationController *ReplicationControllerOptions + ResourceQuotaController *ResourceQuotaControllerOptions + SAController *SAControllerOptions Controllers []string ExternalCloudVolumePlugin string @@ -101,72 +106,72 @@ func NewKubeControllerManagerOptions() (*KubeControllerManagerOptions, error) { Debugging: &cmoptions.DebuggingOptions{}, GenericComponent: cmoptions.NewGenericComponentConfigOptions(componentConfig.GenericComponent), KubeCloudShared: cmoptions.NewKubeCloudSharedOptions(componentConfig.KubeCloudShared), - AttachDetachController: &cmoptions.AttachDetachControllerOptions{ + AttachDetachController: &AttachDetachControllerOptions{ ReconcilerSyncLoopPeriod: componentConfig.AttachDetachController.ReconcilerSyncLoopPeriod, }, - CSRSigningController: &cmoptions.CSRSigningControllerOptions{ + CSRSigningController: &CSRSigningControllerOptions{ ClusterSigningCertFile: componentConfig.CSRSigningController.ClusterSigningCertFile, ClusterSigningKeyFile: componentConfig.CSRSigningController.ClusterSigningKeyFile, ClusterSigningDuration: componentConfig.CSRSigningController.ClusterSigningDuration, }, - DaemonSetController: &cmoptions.DaemonSetControllerOptions{ + DaemonSetController: &DaemonSetControllerOptions{ ConcurrentDaemonSetSyncs: componentConfig.DaemonSetController.ConcurrentDaemonSetSyncs, }, - DeploymentController: &cmoptions.DeploymentControllerOptions{ + DeploymentController: &DeploymentControllerOptions{ ConcurrentDeploymentSyncs: componentConfig.DeploymentController.ConcurrentDeploymentSyncs, DeploymentControllerSyncPeriod: componentConfig.DeploymentController.DeploymentControllerSyncPeriod, }, - DeprecatedFlags: &cmoptions.DeprecatedControllerOptions{ + DeprecatedFlags: &DeprecatedControllerOptions{ RegisterRetryCount: componentConfig.DeprecatedController.RegisterRetryCount, }, - EndPointController: &cmoptions.EndPointControllerOptions{ + EndPointController: &EndPointControllerOptions{ ConcurrentEndpointSyncs: componentConfig.EndPointController.ConcurrentEndpointSyncs, }, - GarbageCollectorController: &cmoptions.GarbageCollectorControllerOptions{ + GarbageCollectorController: &GarbageCollectorControllerOptions{ ConcurrentGCSyncs: componentConfig.GarbageCollectorController.ConcurrentGCSyncs, EnableGarbageCollector: componentConfig.GarbageCollectorController.EnableGarbageCollector, }, - HPAController: &cmoptions.HPAControllerOptions{ + HPAController: &HPAControllerOptions{ HorizontalPodAutoscalerSyncPeriod: componentConfig.HPAController.HorizontalPodAutoscalerSyncPeriod, HorizontalPodAutoscalerUpscaleForbiddenWindow: componentConfig.HPAController.HorizontalPodAutoscalerUpscaleForbiddenWindow, HorizontalPodAutoscalerDownscaleForbiddenWindow: componentConfig.HPAController.HorizontalPodAutoscalerDownscaleForbiddenWindow, HorizontalPodAutoscalerTolerance: componentConfig.HPAController.HorizontalPodAutoscalerTolerance, HorizontalPodAutoscalerUseRESTClients: componentConfig.HPAController.HorizontalPodAutoscalerUseRESTClients, }, - JobController: &cmoptions.JobControllerOptions{ + JobController: &JobControllerOptions{ ConcurrentJobSyncs: componentConfig.JobController.ConcurrentJobSyncs, }, - NamespaceController: &cmoptions.NamespaceControllerOptions{ + NamespaceController: &NamespaceControllerOptions{ NamespaceSyncPeriod: componentConfig.NamespaceController.NamespaceSyncPeriod, ConcurrentNamespaceSyncs: componentConfig.NamespaceController.ConcurrentNamespaceSyncs, }, - NodeIpamController: &cmoptions.NodeIpamControllerOptions{ + NodeIpamController: &NodeIpamControllerOptions{ NodeCIDRMaskSize: componentConfig.NodeIpamController.NodeCIDRMaskSize, }, - NodeLifecycleController: &cmoptions.NodeLifecycleControllerOptions{ + NodeLifecycleController: &NodeLifecycleControllerOptions{ EnableTaintManager: componentConfig.NodeLifecycleController.EnableTaintManager, NodeMonitorGracePeriod: componentConfig.NodeLifecycleController.NodeMonitorGracePeriod, NodeStartupGracePeriod: componentConfig.NodeLifecycleController.NodeStartupGracePeriod, PodEvictionTimeout: componentConfig.NodeLifecycleController.PodEvictionTimeout, }, - PersistentVolumeBinderController: &cmoptions.PersistentVolumeBinderControllerOptions{ + PersistentVolumeBinderController: &PersistentVolumeBinderControllerOptions{ PVClaimBinderSyncPeriod: componentConfig.PersistentVolumeBinderController.PVClaimBinderSyncPeriod, VolumeConfiguration: componentConfig.PersistentVolumeBinderController.VolumeConfiguration, }, - PodGCController: &cmoptions.PodGCControllerOptions{ + PodGCController: &PodGCControllerOptions{ TerminatedPodGCThreshold: componentConfig.PodGCController.TerminatedPodGCThreshold, }, - ReplicaSetController: &cmoptions.ReplicaSetControllerOptions{ + ReplicaSetController: &ReplicaSetControllerOptions{ ConcurrentRSSyncs: componentConfig.ReplicaSetController.ConcurrentRSSyncs, }, - ReplicationController: &cmoptions.ReplicationControllerOptions{ + ReplicationController: &ReplicationControllerOptions{ ConcurrentRCSyncs: componentConfig.ReplicationController.ConcurrentRCSyncs, }, - ResourceQuotaController: &cmoptions.ResourceQuotaControllerOptions{ + ResourceQuotaController: &ResourceQuotaControllerOptions{ ResourceQuotaSyncPeriod: componentConfig.ResourceQuotaController.ResourceQuotaSyncPeriod, ConcurrentResourceQuotaSyncs: componentConfig.ResourceQuotaController.ConcurrentResourceQuotaSyncs, }, - SAController: &cmoptions.SAControllerOptions{ + SAController: &SAControllerOptions{ ConcurrentSATokenSyncs: componentConfig.SAController.ConcurrentSATokenSyncs, }, ServiceController: &cmoptions.ServiceControllerOptions{ @@ -263,7 +268,7 @@ func (s *KubeControllerManagerOptions) AddFlags(fs *pflag.FlagSet, allController } // ApplyTo fills up controller manager config with options. -func (s *KubeControllerManagerOptions) ApplyTo(c *kubecontrollerconfig.Config, userAgent string) error { +func (s *KubeControllerManagerOptions) ApplyTo(c *kubecontrollerconfig.Config) error { if err := s.CloudProvider.ApplyTo(&c.ComponentConfig.CloudProvider); err != nil { return err } @@ -347,32 +352,14 @@ func (s *KubeControllerManagerOptions) ApplyTo(c *kubecontrollerconfig.Config, u } // sync back to component config - // TODO: find more elegant way than synching back the values. + // TODO: find more elegant way than syncing back the values. c.ComponentConfig.KubeCloudShared.Port = int32(s.InsecureServing.BindPort) c.ComponentConfig.KubeCloudShared.Address = s.InsecureServing.BindAddress.String() - var err error - c.Kubeconfig, err = clientcmd.BuildConfigFromFlags(s.Master, s.Kubeconfig) - if err != nil { - return err - } - c.Kubeconfig.ContentConfig.ContentType = s.GenericComponent.ContentType - c.Kubeconfig.QPS = s.GenericComponent.KubeAPIQPS - c.Kubeconfig.Burst = int(s.GenericComponent.KubeAPIBurst) - - c.Client, err = clientset.NewForConfig(restclient.AddUserAgent(c.Kubeconfig, userAgent)) - if err != nil { - return err - } - - c.LeaderElectionClient = clientset.NewForConfigOrDie(restclient.AddUserAgent(c.Kubeconfig, "leader-election")) - - c.EventRecorder = createRecorder(c.Client, userAgent) - c.ComponentConfig.Controllers = s.Controllers c.ComponentConfig.ExternalCloudVolumePlugin = s.ExternalCloudVolumePlugin - return err + return nil } // Validate is used to validate the options and config before launching the controller manager @@ -432,8 +419,30 @@ func (s KubeControllerManagerOptions) Config(allControllers []string, disabledBy return nil, err } - c := &kubecontrollerconfig.Config{} - if err := s.ApplyTo(c, "kube-controller-manager"); err != nil { + kubeconfig, err := clientcmd.BuildConfigFromFlags(s.Master, s.Kubeconfig) + if err != nil { + return nil, err + } + kubeconfig.ContentConfig.ContentType = s.GenericComponent.ContentType + kubeconfig.QPS = s.GenericComponent.KubeAPIQPS + kubeconfig.Burst = int(s.GenericComponent.KubeAPIBurst) + + client, err := clientset.NewForConfig(restclient.AddUserAgent(kubeconfig, KubeControllerManagerUserAgent)) + if err != nil { + return nil, err + } + + leaderElectionClient := clientset.NewForConfigOrDie(restclient.AddUserAgent(kubeconfig, "leader-election")) + + eventRecorder := createRecorder(client, KubeControllerManagerUserAgent) + + c := &kubecontrollerconfig.Config{ + Client: client, + Kubeconfig: kubeconfig, + EventRecorder: eventRecorder, + LeaderElectionClient: leaderElectionClient, + } + if err := s.ApplyTo(c); err != nil { return nil, err } @@ -444,5 +453,6 @@ func createRecorder(kubeClient kubernetes.Interface, userAgent string) record.Ev eventBroadcaster := record.NewBroadcaster() eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")}) + // TODO: remove dependency on the legacyscheme return eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: userAgent}) } diff --git a/cmd/kube-controller-manager/app/options/options_test.go b/cmd/kube-controller-manager/app/options/options_test.go index 2fadaea9c9..d684fa7bad 100644 --- a/cmd/kube-controller-manager/app/options/options_test.go +++ b/cmd/kube-controller-manager/app/options/options_test.go @@ -150,30 +150,30 @@ func TestAddFlags(t *testing.T) { CIDRAllocatorType: "CloudAllocator", ConfigureCloudRoutes: false, }, - AttachDetachController: &cmoptions.AttachDetachControllerOptions{ + AttachDetachController: &AttachDetachControllerOptions{ ReconcilerSyncLoopPeriod: metav1.Duration{Duration: 30 * time.Second}, DisableAttachDetachReconcilerSync: true, }, - CSRSigningController: &cmoptions.CSRSigningControllerOptions{ + CSRSigningController: &CSRSigningControllerOptions{ ClusterSigningCertFile: "/cluster-signing-cert", ClusterSigningKeyFile: "/cluster-signing-key", ClusterSigningDuration: metav1.Duration{Duration: 10 * time.Hour}, }, - DaemonSetController: &cmoptions.DaemonSetControllerOptions{ + DaemonSetController: &DaemonSetControllerOptions{ ConcurrentDaemonSetSyncs: 2, }, - DeploymentController: &cmoptions.DeploymentControllerOptions{ + DeploymentController: &DeploymentControllerOptions{ ConcurrentDeploymentSyncs: 10, DeploymentControllerSyncPeriod: metav1.Duration{Duration: 45 * time.Second}, }, - DeprecatedFlags: &cmoptions.DeprecatedControllerOptions{ + DeprecatedFlags: &DeprecatedControllerOptions{ DeletingPodsQPS: 0.1, RegisterRetryCount: 10, }, - EndPointController: &cmoptions.EndPointControllerOptions{ + EndPointController: &EndPointControllerOptions{ ConcurrentEndpointSyncs: 10, }, - GarbageCollectorController: &cmoptions.GarbageCollectorControllerOptions{ + GarbageCollectorController: &GarbageCollectorControllerOptions{ ConcurrentGCSyncs: 30, GCIgnoredResources: []componentconfig.GroupResource{ {Group: "extensions", Resource: "replicationcontrollers"}, @@ -190,24 +190,24 @@ func TestAddFlags(t *testing.T) { }, EnableGarbageCollector: false, }, - HPAController: &cmoptions.HPAControllerOptions{ + HPAController: &HPAControllerOptions{ HorizontalPodAutoscalerSyncPeriod: metav1.Duration{Duration: 45 * time.Second}, HorizontalPodAutoscalerUpscaleForbiddenWindow: metav1.Duration{Duration: 1 * time.Minute}, HorizontalPodAutoscalerDownscaleForbiddenWindow: metav1.Duration{Duration: 2 * time.Minute}, HorizontalPodAutoscalerTolerance: 0.1, HorizontalPodAutoscalerUseRESTClients: true, }, - JobController: &cmoptions.JobControllerOptions{ + JobController: &JobControllerOptions{ ConcurrentJobSyncs: 5, }, - NamespaceController: &cmoptions.NamespaceControllerOptions{ + NamespaceController: &NamespaceControllerOptions{ NamespaceSyncPeriod: metav1.Duration{Duration: 10 * time.Minute}, ConcurrentNamespaceSyncs: 20, }, - NodeIpamController: &cmoptions.NodeIpamControllerOptions{ + NodeIpamController: &NodeIpamControllerOptions{ NodeCIDRMaskSize: 48, }, - NodeLifecycleController: &cmoptions.NodeLifecycleControllerOptions{ + NodeLifecycleController: &NodeLifecycleControllerOptions{ EnableTaintManager: false, NodeEvictionRate: 0.2, SecondaryNodeEvictionRate: 0.05, @@ -217,7 +217,7 @@ func TestAddFlags(t *testing.T) { LargeClusterSizeThreshold: 100, UnhealthyZoneThreshold: 0.6, }, - PersistentVolumeBinderController: &cmoptions.PersistentVolumeBinderControllerOptions{ + PersistentVolumeBinderController: &PersistentVolumeBinderControllerOptions{ PVClaimBinderSyncPeriod: metav1.Duration{Duration: 30 * time.Second}, VolumeConfiguration: componentconfig.VolumeConfiguration{ EnableDynamicProvisioning: false, @@ -232,20 +232,20 @@ func TestAddFlags(t *testing.T) { }, }, }, - PodGCController: &cmoptions.PodGCControllerOptions{ + PodGCController: &PodGCControllerOptions{ TerminatedPodGCThreshold: 12000, }, - ReplicaSetController: &cmoptions.ReplicaSetControllerOptions{ + ReplicaSetController: &ReplicaSetControllerOptions{ ConcurrentRSSyncs: 10, }, - ReplicationController: &cmoptions.ReplicationControllerOptions{ + ReplicationController: &ReplicationControllerOptions{ ConcurrentRCSyncs: 10, }, - ResourceQuotaController: &cmoptions.ResourceQuotaControllerOptions{ + ResourceQuotaController: &ResourceQuotaControllerOptions{ ResourceQuotaSyncPeriod: metav1.Duration{Duration: 10 * time.Minute}, ConcurrentResourceQuotaSyncs: 10, }, - SAController: &cmoptions.SAControllerOptions{ + SAController: &SAControllerOptions{ ServiceAccountKeyFile: "/service-account-private-key", ConcurrentSATokenSyncs: 10, }, diff --git a/cmd/controller-manager/app/options/persistentvolumebindercontroller.go b/cmd/kube-controller-manager/app/options/persistentvolumebindercontroller.go similarity index 99% rename from cmd/controller-manager/app/options/persistentvolumebindercontroller.go rename to cmd/kube-controller-manager/app/options/persistentvolumebindercontroller.go index 79aba3a2fa..ba7e05ccc0 100644 --- a/cmd/controller-manager/app/options/persistentvolumebindercontroller.go +++ b/cmd/kube-controller-manager/app/options/persistentvolumebindercontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/podgccontroller.go b/cmd/kube-controller-manager/app/options/podgccontroller.go similarity index 99% rename from cmd/controller-manager/app/options/podgccontroller.go rename to cmd/kube-controller-manager/app/options/podgccontroller.go index 8eb82f11c7..9af9c4429a 100644 --- a/cmd/controller-manager/app/options/podgccontroller.go +++ b/cmd/kube-controller-manager/app/options/podgccontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/replicasetcontroller.go b/cmd/kube-controller-manager/app/options/replicasetcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/replicasetcontroller.go rename to cmd/kube-controller-manager/app/options/replicasetcontroller.go index 23e37d28f3..67a6acdd00 100644 --- a/cmd/controller-manager/app/options/replicasetcontroller.go +++ b/cmd/kube-controller-manager/app/options/replicasetcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/replicationcontroller.go b/cmd/kube-controller-manager/app/options/replicationcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/replicationcontroller.go rename to cmd/kube-controller-manager/app/options/replicationcontroller.go index a64b4fe6f3..0b79bf3340 100644 --- a/cmd/controller-manager/app/options/replicationcontroller.go +++ b/cmd/kube-controller-manager/app/options/replicationcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/resourcequotacontroller.go b/cmd/kube-controller-manager/app/options/resourcequotacontroller.go similarity index 99% rename from cmd/controller-manager/app/options/resourcequotacontroller.go rename to cmd/kube-controller-manager/app/options/resourcequotacontroller.go index b684e6e7e3..1d89320e5a 100644 --- a/cmd/controller-manager/app/options/resourcequotacontroller.go +++ b/cmd/kube-controller-manager/app/options/resourcequotacontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/apis/componentconfig" ) diff --git a/cmd/controller-manager/app/options/serviceaccountcontroller.go b/cmd/kube-controller-manager/app/options/serviceaccountcontroller.go similarity index 99% rename from cmd/controller-manager/app/options/serviceaccountcontroller.go rename to cmd/kube-controller-manager/app/options/serviceaccountcontroller.go index 80b26fe9b5..e29099199e 100644 --- a/cmd/controller-manager/app/options/serviceaccountcontroller.go +++ b/cmd/kube-controller-manager/app/options/serviceaccountcontroller.go @@ -18,6 +18,7 @@ package options import ( "github.com/spf13/pflag" + "k8s.io/kubernetes/pkg/apis/componentconfig" )