get rid of copied fields in the options and using wraped componentconfig fields

pull/564/head
stewart-yu 2019-01-12 19:13:05 +08:00
parent 3478647333
commit 5b43a24318
24 changed files with 37 additions and 99 deletions

View File

@ -24,8 +24,7 @@ import (
// CloudProviderOptions holds the cloudprovider options. // CloudProviderOptions holds the cloudprovider options.
type CloudProviderOptions struct { type CloudProviderOptions struct {
CloudConfigFile string *kubectrlmgrconfig.CloudProviderConfiguration
Name string
} }
// Validate checks validation of cloudprovider options. // Validate checks validation of cloudprovider options.

View File

@ -24,8 +24,7 @@ import (
// DebuggingOptions holds the Debugging options. // DebuggingOptions holds the Debugging options.
type DebuggingOptions struct { type DebuggingOptions struct {
EnableProfiling bool *componentbaseconfig.DebuggingConfiguration
EnableContentionProfiling bool
} }
// AddFlags adds flags related to debugging for controller manager to the specified FlagSet. // AddFlags adds flags related to debugging for controller manager to the specified FlagSet.

View File

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"strings" "strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
apiserverflag "k8s.io/apiserver/pkg/util/flag" apiserverflag "k8s.io/apiserver/pkg/util/flag"
componentbaseconfig "k8s.io/component-base/config" componentbaseconfig "k8s.io/component-base/config"
@ -30,29 +29,19 @@ import (
// GenericControllerManagerConfigurationOptions holds the options which are generic. // GenericControllerManagerConfigurationOptions holds the options which are generic.
type GenericControllerManagerConfigurationOptions struct { type GenericControllerManagerConfigurationOptions struct {
Port int32 *kubectrlmgrconfig.GenericControllerManagerConfiguration
Address string Debugging *DebuggingOptions
MinResyncPeriod metav1.Duration
ClientConnection componentbaseconfig.ClientConnectionConfiguration
ControllerStartInterval metav1.Duration
LeaderElection componentbaseconfig.LeaderElectionConfiguration
Debugging *DebuggingOptions
Controllers []string
} }
// NewGenericControllerManagerConfigurationOptions returns generic configuration default values for both // NewGenericControllerManagerConfigurationOptions returns generic configuration default values for both
// the kube-controller-manager and the cloud-contoller-manager. Any common changes should // the kube-controller-manager and the cloud-contoller-manager. Any common changes should
// be made here. Any individual changes should be made in that controller. // be made here. Any individual changes should be made in that controller.
func NewGenericControllerManagerConfigurationOptions(cfg kubectrlmgrconfig.GenericControllerManagerConfiguration) *GenericControllerManagerConfigurationOptions { func NewGenericControllerManagerConfigurationOptions(cfg *kubectrlmgrconfig.GenericControllerManagerConfiguration) *GenericControllerManagerConfigurationOptions {
o := &GenericControllerManagerConfigurationOptions{ o := &GenericControllerManagerConfigurationOptions{
Port: cfg.Port, GenericControllerManagerConfiguration: cfg,
Address: cfg.Address, Debugging: &DebuggingOptions{
MinResyncPeriod: cfg.MinResyncPeriod, DebuggingConfiguration: &componentbaseconfig.DebuggingConfiguration{},
ClientConnection: cfg.ClientConnection, },
ControllerStartInterval: cfg.ControllerStartInterval,
LeaderElection: cfg.LeaderElection,
Debugging: &DebuggingOptions{},
Controllers: cfg.Controllers,
} }
return o return o

View File

@ -19,39 +19,25 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// KubeCloudSharedOptions holds the options shared between kube-controller-manager // KubeCloudSharedOptions holds the options shared between kube-controller-manager
// and cloud-controller-manager. // and cloud-controller-manager.
type KubeCloudSharedOptions struct { type KubeCloudSharedOptions struct {
CloudProvider *CloudProviderOptions *kubectrlmgrconfig.KubeCloudSharedConfiguration
ExternalCloudVolumePlugin string CloudProvider *CloudProviderOptions
UseServiceAccountCredentials bool
AllowUntaggedCloud bool
RouteReconciliationPeriod metav1.Duration
NodeMonitorPeriod metav1.Duration
ClusterName string
ClusterCIDR string
AllocateNodeCIDRs bool
CIDRAllocatorType string
ConfigureCloudRoutes bool
NodeSyncPeriod metav1.Duration
} }
// NewKubeCloudSharedOptions returns common/default configuration values for both // NewKubeCloudSharedOptions returns common/default configuration values for both
// the kube-controller-manager and the cloud-contoller-manager. Any common changes should // the kube-controller-manager and the cloud-contoller-manager. Any common changes should
// be made here. Any individual changes should be made in that controller. // be made here. Any individual changes should be made in that controller.
func NewKubeCloudSharedOptions(cfg kubectrlmgrconfig.KubeCloudSharedConfiguration) *KubeCloudSharedOptions { func NewKubeCloudSharedOptions(cfg *kubectrlmgrconfig.KubeCloudSharedConfiguration) *KubeCloudSharedOptions {
o := &KubeCloudSharedOptions{ o := &KubeCloudSharedOptions{
CloudProvider: &CloudProviderOptions{}, KubeCloudSharedConfiguration: cfg,
ExternalCloudVolumePlugin: cfg.ExternalCloudVolumePlugin, CloudProvider: &CloudProviderOptions{
UseServiceAccountCredentials: cfg.UseServiceAccountCredentials, CloudProviderConfiguration: &kubectrlmgrconfig.CloudProviderConfiguration{},
RouteReconciliationPeriod: cfg.RouteReconciliationPeriod, },
NodeMonitorPeriod: cfg.NodeMonitorPeriod,
ClusterName: cfg.ClusterName,
ConfigureCloudRoutes: cfg.ConfigureCloudRoutes,
} }
return o return o
@ -92,6 +78,7 @@ func (o *KubeCloudSharedOptions) ApplyTo(cfg *kubectrlmgrconfig.KubeCloudSharedC
if err := o.CloudProvider.ApplyTo(&cfg.CloudProvider); err != nil { if err := o.CloudProvider.ApplyTo(&cfg.CloudProvider); err != nil {
return err return err
} }
cfg.ExternalCloudVolumePlugin = o.ExternalCloudVolumePlugin cfg.ExternalCloudVolumePlugin = o.ExternalCloudVolumePlugin
cfg.UseServiceAccountCredentials = o.UseServiceAccountCredentials cfg.UseServiceAccountCredentials = o.UseServiceAccountCredentials
cfg.AllowUntaggedCloud = o.AllowUntaggedCloud cfg.AllowUntaggedCloud = o.AllowUntaggedCloud

View File

@ -24,7 +24,7 @@ import (
// ServiceControllerOptions holds the ServiceController options. // ServiceControllerOptions holds the ServiceController options.
type ServiceControllerOptions struct { type ServiceControllerOptions struct {
ConcurrentServiceSyncs int32 *kubectrlmgrconfig.ServiceControllerConfiguration
} }
// AddFlags adds flags related to ServiceController for controller manager to the specified FlagSet. // AddFlags adds flags related to ServiceController for controller manager to the specified FlagSet.

View File

@ -19,14 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// AttachDetachControllerOptions holds the AttachDetachController options. // AttachDetachControllerOptions holds the AttachDetachController options.
type AttachDetachControllerOptions struct { type AttachDetachControllerOptions struct {
ReconcilerSyncLoopPeriod metav1.Duration *kubectrlmgrconfig.AttachDetachControllerConfiguration
DisableAttachDetachReconcilerSync bool
} }
// AddFlags adds flags related to AttachDetachController for controller manager to the specified FlagSet. // AddFlags adds flags related to AttachDetachController for controller manager to the specified FlagSet.

View File

@ -19,7 +19,6 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
@ -35,9 +34,7 @@ const (
// CSRSigningControllerOptions holds the CSRSigningController options. // CSRSigningControllerOptions holds the CSRSigningController options.
type CSRSigningControllerOptions struct { type CSRSigningControllerOptions struct {
ClusterSigningDuration metav1.Duration *kubectrlmgrconfig.CSRSigningControllerConfiguration
ClusterSigningKeyFile string
ClusterSigningCertFile string
} }
// AddFlags adds flags related to CSRSigningController for controller manager to the specified FlagSet. // AddFlags adds flags related to CSRSigningController for controller manager to the specified FlagSet.

View File

@ -24,7 +24,7 @@ import (
// DaemonSetControllerOptions holds the DaemonSetController options. // DaemonSetControllerOptions holds the DaemonSetController options.
type DaemonSetControllerOptions struct { type DaemonSetControllerOptions struct {
ConcurrentDaemonSetSyncs int32 *kubectrlmgrconfig.DaemonSetControllerConfiguration
} }
// AddFlags adds flags related to DaemonSetController for controller manager to the specified FlagSet. // AddFlags adds flags related to DaemonSetController for controller manager to the specified FlagSet.

View File

@ -19,14 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// DeploymentControllerOptions holds the DeploymentController options. // DeploymentControllerOptions holds the DeploymentController options.
type DeploymentControllerOptions struct { type DeploymentControllerOptions struct {
ConcurrentDeploymentSyncs int32 *kubectrlmgrconfig.DeploymentControllerConfiguration
DeploymentControllerSyncPeriod metav1.Duration
} }
// AddFlags adds flags related to DeploymentController for controller manager to the specified FlagSet. // AddFlags adds flags related to DeploymentController for controller manager to the specified FlagSet.

View File

@ -25,9 +25,7 @@ import (
// DeprecatedControllerOptions holds the DeprecatedController options, those option are deprecated. // DeprecatedControllerOptions holds the DeprecatedController options, those option are deprecated.
// TODO remove these fields once the deprecated flags are removed. // TODO remove these fields once the deprecated flags are removed.
type DeprecatedControllerOptions struct { type DeprecatedControllerOptions struct {
DeletingPodsQPS float32 *kubectrlmgrconfig.DeprecatedControllerConfiguration
DeletingPodsBurst int32
RegisterRetryCount int32
} }
// AddFlags adds flags related to DeprecatedController for controller manager to the specified FlagSet. // AddFlags adds flags related to DeprecatedController for controller manager to the specified FlagSet.

View File

@ -24,7 +24,7 @@ import (
// EndpointControllerOptions holds the EndPointController options. // EndpointControllerOptions holds the EndPointController options.
type EndpointControllerOptions struct { type EndpointControllerOptions struct {
ConcurrentEndpointSyncs int32 *kubectrlmgrconfig.EndpointControllerConfiguration
} }
// AddFlags adds flags related to EndPointController for controller manager to the specified FlagSet. // AddFlags adds flags related to EndPointController for controller manager to the specified FlagSet.

View File

@ -24,9 +24,7 @@ import (
// GarbageCollectorControllerOptions holds the GarbageCollectorController options. // GarbageCollectorControllerOptions holds the GarbageCollectorController options.
type GarbageCollectorControllerOptions struct { type GarbageCollectorControllerOptions struct {
ConcurrentGCSyncs int32 *kubectrlmgrconfig.GarbageCollectorControllerConfiguration
GCIgnoredResources []kubectrlmgrconfig.GroupResource
EnableGarbageCollector bool
} }
// AddFlags adds flags related to GarbageCollectorController for controller manager to the specified FlagSet. // AddFlags adds flags related to GarbageCollectorController for controller manager to the specified FlagSet.

View File

@ -19,20 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// HPAControllerOptions holds the HPAController options. // HPAControllerOptions holds the HPAController options.
type HPAControllerOptions struct { type HPAControllerOptions struct {
HorizontalPodAutoscalerUseRESTClients bool *kubectrlmgrconfig.HPAControllerConfiguration
HorizontalPodAutoscalerTolerance float64
HorizontalPodAutoscalerDownscaleStabilizationWindow metav1.Duration
HorizontalPodAutoscalerDownscaleForbiddenWindow metav1.Duration
HorizontalPodAutoscalerUpscaleForbiddenWindow metav1.Duration
HorizontalPodAutoscalerSyncPeriod metav1.Duration
HorizontalPodAutoscalerCPUInitializationPeriod metav1.Duration
HorizontalPodAutoscalerInitialReadinessDelay metav1.Duration
} }
// AddFlags adds flags related to HPAController for controller manager to the specified FlagSet. // AddFlags adds flags related to HPAController for controller manager to the specified FlagSet.

View File

@ -24,7 +24,7 @@ import (
// JobControllerOptions holds the JobController options. // JobControllerOptions holds the JobController options.
type JobControllerOptions struct { type JobControllerOptions struct {
ConcurrentJobSyncs int32 *kubectrlmgrconfig.JobControllerConfiguration
} }
// AddFlags adds flags related to JobController for controller manager to the specified FlagSet. // AddFlags adds flags related to JobController for controller manager to the specified FlagSet.

View File

@ -19,14 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// NamespaceControllerOptions holds the NamespaceController options. // NamespaceControllerOptions holds the NamespaceController options.
type NamespaceControllerOptions struct { type NamespaceControllerOptions struct {
NamespaceSyncPeriod metav1.Duration *kubectrlmgrconfig.NamespaceControllerConfiguration
ConcurrentNamespaceSyncs int32
} }
// AddFlags adds flags related to NamespaceController for controller manager to the specified FlagSet. // AddFlags adds flags related to NamespaceController for controller manager to the specified FlagSet.

View File

@ -24,8 +24,7 @@ import (
// NodeIPAMControllerOptions holds the NodeIpamController options. // NodeIPAMControllerOptions holds the NodeIpamController options.
type NodeIPAMControllerOptions struct { type NodeIPAMControllerOptions struct {
ServiceCIDR string *kubectrlmgrconfig.NodeIPAMControllerConfiguration
NodeCIDRMaskSize int32
} }
// AddFlags adds flags related to NodeIpamController for controller manager to the specified FlagSet. // AddFlags adds flags related to NodeIpamController for controller manager to the specified FlagSet.

View File

@ -19,20 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// NodeLifecycleControllerOptions holds the NodeLifecycleController options. // NodeLifecycleControllerOptions holds the NodeLifecycleController options.
type NodeLifecycleControllerOptions struct { type NodeLifecycleControllerOptions struct {
EnableTaintManager bool *kubectrlmgrconfig.NodeLifecycleControllerConfiguration
NodeEvictionRate float32
SecondaryNodeEvictionRate float32
NodeStartupGracePeriod metav1.Duration
NodeMonitorGracePeriod metav1.Duration
PodEvictionTimeout metav1.Duration
LargeClusterSizeThreshold int32
UnhealthyZoneThreshold float32
} }
// AddFlags adds flags related to NodeLifecycleController for controller manager to the specified FlagSet. // AddFlags adds flags related to NodeLifecycleController for controller manager to the specified FlagSet.

View File

@ -19,14 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// PersistentVolumeBinderControllerOptions holds the PersistentVolumeBinderController options. // PersistentVolumeBinderControllerOptions holds the PersistentVolumeBinderController options.
type PersistentVolumeBinderControllerOptions struct { type PersistentVolumeBinderControllerOptions struct {
PVClaimBinderSyncPeriod metav1.Duration *kubectrlmgrconfig.PersistentVolumeBinderControllerConfiguration
VolumeConfiguration kubectrlmgrconfig.VolumeConfiguration
} }
// AddFlags adds flags related to PersistentVolumeBinderController for controller manager to the specified FlagSet. // AddFlags adds flags related to PersistentVolumeBinderController for controller manager to the specified FlagSet.

View File

@ -24,7 +24,7 @@ import (
// PodGCControllerOptions holds the PodGCController options. // PodGCControllerOptions holds the PodGCController options.
type PodGCControllerOptions struct { type PodGCControllerOptions struct {
TerminatedPodGCThreshold int32 *kubectrlmgrconfig.PodGCControllerConfiguration
} }
// AddFlags adds flags related to PodGCController for controller manager to the specified FlagSet. // AddFlags adds flags related to PodGCController for controller manager to the specified FlagSet.

View File

@ -24,7 +24,7 @@ import (
// ReplicaSetControllerOptions holds the ReplicaSetController options. // ReplicaSetControllerOptions holds the ReplicaSetController options.
type ReplicaSetControllerOptions struct { type ReplicaSetControllerOptions struct {
ConcurrentRSSyncs int32 *kubectrlmgrconfig.ReplicaSetControllerConfiguration
} }
// AddFlags adds flags related to ReplicaSetController for controller manager to the specified FlagSet. // AddFlags adds flags related to ReplicaSetController for controller manager to the specified FlagSet.

View File

@ -24,7 +24,7 @@ import (
// ReplicationControllerOptions holds the ReplicationController options. // ReplicationControllerOptions holds the ReplicationController options.
type ReplicationControllerOptions struct { type ReplicationControllerOptions struct {
ConcurrentRCSyncs int32 *kubectrlmgrconfig.ReplicationControllerConfiguration
} }
// AddFlags adds flags related to ReplicationController for controller manager to the specified FlagSet. // AddFlags adds flags related to ReplicationController for controller manager to the specified FlagSet.

View File

@ -19,14 +19,12 @@ package options
import ( import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
) )
// ResourceQuotaControllerOptions holds the ResourceQuotaController options. // ResourceQuotaControllerOptions holds the ResourceQuotaController options.
type ResourceQuotaControllerOptions struct { type ResourceQuotaControllerOptions struct {
ResourceQuotaSyncPeriod metav1.Duration *kubectrlmgrconfig.ResourceQuotaControllerConfiguration
ConcurrentResourceQuotaSyncs int32
} }
// AddFlags adds flags related to ResourceQuotaController for controller manager to the specified FlagSet. // AddFlags adds flags related to ResourceQuotaController for controller manager to the specified FlagSet.

View File

@ -24,9 +24,7 @@ import (
// SAControllerOptions holds the ServiceAccountController options. // SAControllerOptions holds the ServiceAccountController options.
type SAControllerOptions struct { type SAControllerOptions struct {
ServiceAccountKeyFile string *kubectrlmgrconfig.SAControllerConfiguration
ConcurrentSATokenSyncs int32
RootCAFile string
} }
// AddFlags adds flags related to ServiceAccountController for controller manager to the specified FlagSet // AddFlags adds flags related to ServiceAccountController for controller manager to the specified FlagSet

View File

@ -24,7 +24,7 @@ import (
// TTLAfterFinishedControllerOptions holds the TTLAfterFinishedController options. // TTLAfterFinishedControllerOptions holds the TTLAfterFinishedController options.
type TTLAfterFinishedControllerOptions struct { type TTLAfterFinishedControllerOptions struct {
ConcurrentTTLSyncs int32 *kubectrlmgrconfig.TTLAfterFinishedControllerConfiguration
} }
// AddFlags adds flags related to TTLAfterFinishedController for controller manager to the specified FlagSet. // AddFlags adds flags related to TTLAfterFinishedController for controller manager to the specified FlagSet.