diff --git a/pkg/apis/componentconfig/types.go b/pkg/apis/componentconfig/types.go index e7460df3773..7ca6a224445 100644 --- a/pkg/apis/componentconfig/types.go +++ b/pkg/apis/componentconfig/types.go @@ -244,6 +244,28 @@ type KubeControllerManagerConfiguration struct { ExternalCloudVolumePlugin string } +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type CloudControllerManagerConfiguration struct { + metav1.TypeMeta + + // CloudProviderConfiguration holds configuration for CloudProvider related features. + CloudProvider CloudProviderConfiguration + // DebuggingConfiguration holds configuration for Debugging related features. + Debugging DebuggingConfiguration + // GenericComponentConfiguration holds configuration for GenericComponent + // related features both in cloud controller manager and kube-controller manager. + GenericComponent GenericComponentConfiguration + // KubeCloudSharedConfiguration holds configuration for shared related features + // both in cloud controller manager and kube-controller manager. + KubeCloudShared KubeCloudSharedConfiguration + // ServiceControllerConfiguration holds configuration for ServiceController + // related features. + ServiceController ServiceControllerConfiguration + // NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status + NodeStatusUpdateFrequency metav1.Duration +} + type CloudProviderConfiguration struct { // Name is the provider for cloud services. Name string diff --git a/pkg/apis/componentconfig/v1alpha1/defaults.go b/pkg/apis/componentconfig/v1alpha1/defaults.go index 925412c7138..225b279a03c 100644 --- a/pkg/apis/componentconfig/v1alpha1/defaults.go +++ b/pkg/apis/componentconfig/v1alpha1/defaults.go @@ -33,15 +33,21 @@ func addDefaultingFuncs(scheme *kruntime.Scheme) error { return RegisterDefaults(scheme) } +func SetDefaults_CloudControllerManagerConfiguration(obj *CloudControllerManagerConfiguration) { + zero := metav1.Duration{} + if obj.ServiceController.ConcurrentServiceSyncs == 0 { + obj.ServiceController.ConcurrentServiceSyncs = 1 + } + if obj.NodeStatusUpdateFrequency == zero { + obj.NodeStatusUpdateFrequency = metav1.Duration{Duration: 5 * time.Minute} + } +} + func SetDefaults_KubeControllerManagerConfiguration(obj *KubeControllerManagerConfiguration) { zero := metav1.Duration{} if len(obj.Controllers) == 0 { obj.Controllers = []string{"*"} } - // Port - if obj.KubeCloudShared.Address == "" { - obj.KubeCloudShared.Address = "0.0.0.0" - } if obj.EndPointController.ConcurrentEndpointSyncs == 0 { obj.EndPointController.ConcurrentEndpointSyncs = 5 } @@ -72,9 +78,6 @@ func SetDefaults_KubeControllerManagerConfiguration(obj *KubeControllerManagerCo if obj.SAController.ConcurrentSATokenSyncs == 0 { obj.SAController.ConcurrentSATokenSyncs = 5 } - if obj.KubeCloudShared.RouteReconciliationPeriod == zero { - obj.KubeCloudShared.RouteReconciliationPeriod = metav1.Duration{Duration: 10 * time.Second} - } if obj.ResourceQuotaController.ResourceQuotaSyncPeriod == zero { obj.ResourceQuotaController.ResourceQuotaSyncPeriod = metav1.Duration{Duration: 5 * time.Minute} } @@ -99,9 +102,6 @@ func SetDefaults_KubeControllerManagerConfiguration(obj *KubeControllerManagerCo if obj.DeploymentController.DeploymentControllerSyncPeriod == zero { obj.DeploymentController.DeploymentControllerSyncPeriod = metav1.Duration{Duration: 30 * time.Second} } - if obj.GenericComponent.MinResyncPeriod == zero { - obj.GenericComponent.MinResyncPeriod = metav1.Duration{Duration: 12 * time.Hour} - } if obj.DeprecatedController.RegisterRetryCount == 0 { obj.DeprecatedController.RegisterRetryCount = 10 } @@ -114,33 +114,12 @@ func SetDefaults_KubeControllerManagerConfiguration(obj *KubeControllerManagerCo if obj.NodeLifecycleController.NodeStartupGracePeriod == zero { obj.NodeLifecycleController.NodeStartupGracePeriod = metav1.Duration{Duration: 60 * time.Second} } - if obj.KubeCloudShared.NodeMonitorPeriod == zero { - obj.KubeCloudShared.NodeMonitorPeriod = metav1.Duration{Duration: 5 * time.Second} - } - if obj.KubeCloudShared.ClusterName == "" { - obj.KubeCloudShared.ClusterName = "kubernetes" - } if obj.NodeIpamController.NodeCIDRMaskSize == 0 { obj.NodeIpamController.NodeCIDRMaskSize = 24 } - if obj.KubeCloudShared.ConfigureCloudRoutes == nil { - obj.KubeCloudShared.ConfigureCloudRoutes = utilpointer.BoolPtr(true) - } if obj.PodGCController.TerminatedPodGCThreshold == 0 { obj.PodGCController.TerminatedPodGCThreshold = 12500 } - if obj.GenericComponent.ContentType == "" { - obj.GenericComponent.ContentType = "application/vnd.kubernetes.protobuf" - } - if obj.GenericComponent.KubeAPIQPS == 0 { - obj.GenericComponent.KubeAPIQPS = 20.0 - } - if obj.GenericComponent.KubeAPIBurst == 0 { - obj.GenericComponent.KubeAPIBurst = 30 - } - if obj.GenericComponent.ControllerStartInterval == zero { - obj.GenericComponent.ControllerStartInterval = metav1.Duration{Duration: 0 * time.Second} - } if obj.GarbageCollectorController.EnableGarbageCollector == nil { obj.GarbageCollectorController.EnableGarbageCollector = utilpointer.BoolPtr(true) } @@ -167,6 +146,45 @@ func SetDefaults_KubeControllerManagerConfiguration(obj *KubeControllerManagerCo } } +func SetDefaults_GenericComponentConfiguration(obj *GenericComponentConfiguration) { + zero := metav1.Duration{} + if obj.MinResyncPeriod == zero { + obj.MinResyncPeriod = metav1.Duration{Duration: 12 * time.Hour} + } + if obj.ContentType == "" { + obj.ContentType = "application/vnd.kubernetes.protobuf" + } + if obj.KubeAPIQPS == 0 { + obj.KubeAPIQPS = 20.0 + } + if obj.KubeAPIBurst == 0 { + obj.KubeAPIBurst = 30 + } + if obj.ControllerStartInterval == zero { + obj.ControllerStartInterval = metav1.Duration{Duration: 0 * time.Second} + } +} + +func SetDefaults_KubeCloudSharedConfiguration(obj *KubeCloudSharedConfiguration) { + zero := metav1.Duration{} + // Port + if obj.Address == "" { + obj.Address = "0.0.0.0" + } + if obj.RouteReconciliationPeriod == zero { + obj.RouteReconciliationPeriod = metav1.Duration{Duration: 10 * time.Second} + } + if obj.NodeMonitorPeriod == zero { + obj.NodeMonitorPeriod = metav1.Duration{Duration: 5 * time.Second} + } + if obj.ClusterName == "" { + obj.ClusterName = "kubernetes" + } + if obj.ConfigureCloudRoutes == nil { + obj.ConfigureCloudRoutes = utilpointer.BoolPtr(true) + } +} + func SetDefaults_PersistentVolumeRecyclerConfiguration(obj *PersistentVolumeRecyclerConfiguration) { if obj.MaximumRetry == 0 { obj.MaximumRetry = 3 diff --git a/pkg/apis/componentconfig/v1alpha1/types.go b/pkg/apis/componentconfig/v1alpha1/types.go index ccf81061dc6..129f5d650c5 100644 --- a/pkg/apis/componentconfig/v1alpha1/types.go +++ b/pkg/apis/componentconfig/v1alpha1/types.go @@ -286,6 +286,28 @@ type KubeControllerManagerConfiguration struct { ExternalCloudVolumePlugin string `json:"externalCloudVolumePlugin"` } +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type CloudControllerManagerConfiguration struct { + metav1.TypeMeta `json:",inline"` + + // CloudProviderConfiguration holds configuration for CloudProvider related features. + CloudProvider CloudProviderConfiguration + // DebuggingConfiguration holds configuration for Debugging related features. + Debugging DebuggingConfiguration + // GenericComponentConfiguration holds configuration for GenericComponent + // related features both in cloud controller manager and kube-controller manager. + GenericComponent GenericComponentConfiguration + // KubeCloudSharedConfiguration holds configuration for shared related features + // both in cloud controller manager and kube-controller manager. + KubeCloudShared KubeCloudSharedConfiguration + // ServiceControllerConfiguration holds configuration for ServiceController + // related features. + ServiceController ServiceControllerConfiguration + // NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status + NodeStatusUpdateFrequency metav1.Duration +} + type CloudProviderConfiguration struct { // Name is the provider for cloud services. Name string `json:"cloudProvider"`