mirror of https://github.com/k3s-io/k3s
[cloud-controller manager]get rid of GenericControllerManagerOptions sub-struct
parent
f47f515600
commit
2a8d258f66
|
@ -18,24 +18,49 @@ package options
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"net"
|
||||||
|
|
||||||
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
|
apiserveroptions "k8s.io/apiserver/pkg/server/options"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
|
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
|
restclient "k8s.io/client-go/rest"
|
||||||
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
"k8s.io/client-go/tools/record"
|
||||||
cloudcontrollerconfig "k8s.io/kubernetes/cmd/cloud-controller-manager/app/config"
|
cloudcontrollerconfig "k8s.io/kubernetes/cmd/cloud-controller-manager/app/config"
|
||||||
cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options"
|
cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options"
|
||||||
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||||
|
componentconfigv1alpha1 "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
|
||||||
"k8s.io/kubernetes/pkg/master/ports"
|
"k8s.io/kubernetes/pkg/master/ports"
|
||||||
|
|
||||||
// add the kubernetes feature gates
|
// add the kubernetes feature gates
|
||||||
_ "k8s.io/kubernetes/pkg/features"
|
_ "k8s.io/kubernetes/pkg/features"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CloudControllerManagerOptions is the main context object for the controller manager.
|
// CloudControllerManagerOptions is the main context object for the controller manager.
|
||||||
type CloudControllerManagerOptions struct {
|
type CloudControllerManagerOptions struct {
|
||||||
Generic *cmoptions.GenericControllerManagerOptions
|
CloudProvider *cmoptions.CloudProviderOptions
|
||||||
|
Debugging *cmoptions.DebuggingOptions
|
||||||
|
GenericComponent *cmoptions.GenericComponentConfigOptions
|
||||||
|
KubeCloudShared *cmoptions.KubeCloudSharedOptions
|
||||||
|
ServiceController *cmoptions.ServiceControllerOptions
|
||||||
|
|
||||||
|
SecureServing *apiserveroptions.SecureServingOptions
|
||||||
|
// TODO: remove insecure serving mode
|
||||||
|
InsecureServing *cmoptions.InsecureServingOptions
|
||||||
|
Authentication *apiserveroptions.DelegatingAuthenticationOptions
|
||||||
|
Authorization *apiserveroptions.DelegatingAuthorizationOptions
|
||||||
|
|
||||||
|
Master string
|
||||||
|
Kubeconfig string
|
||||||
|
|
||||||
// NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status
|
// NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status
|
||||||
NodeStatusUpdateFrequency metav1.Duration
|
NodeStatusUpdateFrequency metav1.Duration
|
||||||
|
@ -43,37 +68,125 @@ type CloudControllerManagerOptions struct {
|
||||||
|
|
||||||
// NewCloudControllerManagerOptions creates a new ExternalCMServer with a default config.
|
// NewCloudControllerManagerOptions creates a new ExternalCMServer with a default config.
|
||||||
func NewCloudControllerManagerOptions() *CloudControllerManagerOptions {
|
func NewCloudControllerManagerOptions() *CloudControllerManagerOptions {
|
||||||
componentConfig := cmoptions.NewDefaultControllerManagerComponentConfig(ports.InsecureCloudControllerManagerPort)
|
componentConfig := NewDefaultComponentConfig(ports.InsecureCloudControllerManagerPort)
|
||||||
|
|
||||||
s := CloudControllerManagerOptions{
|
s := CloudControllerManagerOptions{
|
||||||
// The common/default are kept in 'cmd/kube-controller-manager/app/options/util.go'.
|
CloudProvider: &cmoptions.CloudProviderOptions{},
|
||||||
// Please make common changes there and put anything cloud specific here.
|
Debugging: &cmoptions.DebuggingOptions{},
|
||||||
Generic: cmoptions.NewGenericControllerManagerOptions(componentConfig),
|
GenericComponent: cmoptions.NewGenericComponentConfigOptions(componentConfig.GenericComponent),
|
||||||
NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute},
|
KubeCloudShared: cmoptions.NewKubeCloudSharedOptions(componentConfig.KubeCloudShared),
|
||||||
|
ServiceController: &cmoptions.ServiceControllerOptions{
|
||||||
|
ConcurrentServiceSyncs: componentConfig.ServiceController.ConcurrentServiceSyncs,
|
||||||
|
},
|
||||||
|
SecureServing: apiserveroptions.NewSecureServingOptions(),
|
||||||
|
InsecureServing: &cmoptions.InsecureServingOptions{
|
||||||
|
BindAddress: net.ParseIP(componentConfig.KubeCloudShared.Address),
|
||||||
|
BindPort: int(componentConfig.KubeCloudShared.Port),
|
||||||
|
BindNetwork: "tcp",
|
||||||
|
},
|
||||||
|
Authentication: nil, // TODO: enable with apiserveroptions.NewDelegatingAuthenticationOptions()
|
||||||
|
Authorization: nil, // TODO: enable with apiserveroptions.NewDelegatingAuthorizationOptions()
|
||||||
|
NodeStatusUpdateFrequency: componentConfig.NodeStatusUpdateFrequency,
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Generic.SecureServing.ServerCert.CertDirectory = "/var/run/kubernetes"
|
s.SecureServing.ServerCert.CertDirectory = "/var/run/kubernetes"
|
||||||
s.Generic.SecureServing.ServerCert.PairName = "cloud-controller-manager"
|
s.SecureServing.ServerCert.PairName = "cloud-controller-manager"
|
||||||
|
|
||||||
|
// disable secure serving for now
|
||||||
|
// TODO: enable HTTPS by default
|
||||||
|
s.SecureServing.BindPort = 0
|
||||||
|
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDefaultComponentConfig returns cloud-controller manager configuration object.
|
||||||
|
func NewDefaultComponentConfig(insecurePort int32) componentconfig.CloudControllerManagerConfiguration {
|
||||||
|
scheme := runtime.NewScheme()
|
||||||
|
componentconfigv1alpha1.AddToScheme(scheme)
|
||||||
|
componentconfig.AddToScheme(scheme)
|
||||||
|
|
||||||
|
versioned := componentconfigv1alpha1.CloudControllerManagerConfiguration{}
|
||||||
|
scheme.Default(&versioned)
|
||||||
|
|
||||||
|
internal := componentconfig.CloudControllerManagerConfiguration{}
|
||||||
|
scheme.Convert(&versioned, &internal, nil)
|
||||||
|
internal.KubeCloudShared.Port = insecurePort
|
||||||
|
return internal
|
||||||
|
}
|
||||||
|
|
||||||
// AddFlags adds flags for a specific ExternalCMServer to the specified FlagSet
|
// AddFlags adds flags for a specific ExternalCMServer to the specified FlagSet
|
||||||
func (o *CloudControllerManagerOptions) AddFlags(fs *pflag.FlagSet) {
|
func (o *CloudControllerManagerOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
o.Generic.AddFlags(fs)
|
o.CloudProvider.AddFlags(fs)
|
||||||
|
o.Debugging.AddFlags(fs)
|
||||||
|
o.GenericComponent.AddFlags(fs)
|
||||||
|
o.KubeCloudShared.AddFlags(fs)
|
||||||
|
o.ServiceController.AddFlags(fs)
|
||||||
|
|
||||||
|
o.SecureServing.AddFlags(fs)
|
||||||
|
o.InsecureServing.AddFlags(fs)
|
||||||
|
o.Authentication.AddFlags(fs)
|
||||||
|
o.Authorization.AddFlags(fs)
|
||||||
|
|
||||||
|
fs.StringVar(&o.Master, "master", o.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
|
||||||
|
fs.StringVar(&o.Kubeconfig, "kubeconfig", o.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
|
||||||
fs.DurationVar(&o.NodeStatusUpdateFrequency.Duration, "node-status-update-frequency", o.NodeStatusUpdateFrequency.Duration, "Specifies how often the controller updates nodes' status.")
|
fs.DurationVar(&o.NodeStatusUpdateFrequency.Duration, "node-status-update-frequency", o.NodeStatusUpdateFrequency.Duration, "Specifies how often the controller updates nodes' status.")
|
||||||
|
|
||||||
utilfeature.DefaultFeatureGate.AddFlag(fs)
|
utilfeature.DefaultFeatureGate.AddFlag(fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyTo fills up cloud controller manager config with options.
|
// ApplyTo fills up cloud controller manager config with options.
|
||||||
func (o *CloudControllerManagerOptions) ApplyTo(c *cloudcontrollerconfig.Config) error {
|
func (o *CloudControllerManagerOptions) ApplyTo(c *cloudcontrollerconfig.Config, userAgent string) error {
|
||||||
if err := o.Generic.ApplyTo(&c.Generic, "cloud-controller-manager"); err != nil {
|
if err := o.CloudProvider.ApplyTo(&c.ComponentConfig.CloudProvider); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.Debugging.ApplyTo(&c.ComponentConfig.Debugging); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.GenericComponent.ApplyTo(&c.ComponentConfig.GenericComponent); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.KubeCloudShared.ApplyTo(&c.ComponentConfig.KubeCloudShared); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.ServiceController.ApplyTo(&c.ComponentConfig.ServiceController); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.SecureServing.ApplyTo(&c.SecureServing); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.InsecureServing.ApplyTo(&c.InsecureServing); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.Authentication.ApplyTo(&c.Authentication, c.SecureServing, nil); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := o.Authorization.ApplyTo(&c.Authorization); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Extra.NodeStatusUpdateFrequency = o.NodeStatusUpdateFrequency.Duration
|
// sync back to component config
|
||||||
|
// TODO: find more elegant way than synching back the values.
|
||||||
|
c.ComponentConfig.KubeCloudShared.Port = int32(o.InsecureServing.BindPort)
|
||||||
|
c.ComponentConfig.KubeCloudShared.Address = o.InsecureServing.BindAddress.String()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
c.Kubeconfig, err = clientcmd.BuildConfigFromFlags(o.Master, o.Kubeconfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.Kubeconfig.ContentConfig.ContentType = o.GenericComponent.ContentType
|
||||||
|
c.Kubeconfig.QPS = o.GenericComponent.KubeAPIQPS
|
||||||
|
c.Kubeconfig.Burst = int(o.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.NodeStatusUpdateFrequency = o.NodeStatusUpdateFrequency
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -81,9 +194,18 @@ func (o *CloudControllerManagerOptions) ApplyTo(c *cloudcontrollerconfig.Config)
|
||||||
// Validate is used to validate config before launching the cloud controller manager
|
// Validate is used to validate config before launching the cloud controller manager
|
||||||
func (o *CloudControllerManagerOptions) Validate() error {
|
func (o *CloudControllerManagerOptions) Validate() error {
|
||||||
errors := []error{}
|
errors := []error{}
|
||||||
errors = append(errors, o.Generic.Validate()...)
|
|
||||||
|
|
||||||
if len(o.Generic.CloudProvider.Name) == 0 {
|
errors = append(errors, o.CloudProvider.Validate()...)
|
||||||
|
errors = append(errors, o.Debugging.Validate()...)
|
||||||
|
errors = append(errors, o.GenericComponent.Validate()...)
|
||||||
|
errors = append(errors, o.KubeCloudShared.Validate()...)
|
||||||
|
errors = append(errors, o.ServiceController.Validate()...)
|
||||||
|
errors = append(errors, o.SecureServing.Validate()...)
|
||||||
|
errors = append(errors, o.InsecureServing.Validate()...)
|
||||||
|
errors = append(errors, o.Authentication.Validate()...)
|
||||||
|
errors = append(errors, o.Authorization.Validate()...)
|
||||||
|
|
||||||
|
if len(o.CloudProvider.Name) == 0 {
|
||||||
errors = append(errors, fmt.Errorf("--cloud-provider cannot be empty"))
|
errors = append(errors, fmt.Errorf("--cloud-provider cannot be empty"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +219,16 @@ func (o CloudControllerManagerOptions) Config() (*cloudcontrollerconfig.Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &cloudcontrollerconfig.Config{}
|
c := &cloudcontrollerconfig.Config{}
|
||||||
if err := o.ApplyTo(c); err != nil {
|
if err := o.ApplyTo(c, "cloud-controller-manager"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createRecorder(kubeClient kubernetes.Interface, userAgent string) record.EventRecorder {
|
||||||
|
eventBroadcaster := record.NewBroadcaster()
|
||||||
|
eventBroadcaster.StartLogging(glog.Infof)
|
||||||
|
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
|
||||||
|
return eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: userAgent})
|
||||||
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ func TestDefaultFlags(t *testing.T) {
|
||||||
s := NewCloudControllerManagerOptions()
|
s := NewCloudControllerManagerOptions()
|
||||||
|
|
||||||
expected := &CloudControllerManagerOptions{
|
expected := &CloudControllerManagerOptions{
|
||||||
Generic: &cmoptions.GenericControllerManagerOptions{
|
|
||||||
CloudProvider: &cmoptions.CloudProviderOptions{
|
CloudProvider: &cmoptions.CloudProviderOptions{
|
||||||
Name: "",
|
Name: "",
|
||||||
CloudConfigFile: "",
|
CloudConfigFile: "",
|
||||||
|
@ -68,89 +67,9 @@ func TestDefaultFlags(t *testing.T) {
|
||||||
CIDRAllocatorType: "",
|
CIDRAllocatorType: "",
|
||||||
ConfigureCloudRoutes: true,
|
ConfigureCloudRoutes: true,
|
||||||
},
|
},
|
||||||
AttachDetachController: &cmoptions.AttachDetachControllerOptions{
|
|
||||||
ReconcilerSyncLoopPeriod: metav1.Duration{Duration: 1 * time.Minute},
|
|
||||||
},
|
|
||||||
CSRSigningController: &cmoptions.CSRSigningControllerOptions{
|
|
||||||
ClusterSigningCertFile: "/etc/kubernetes/ca/ca.pem",
|
|
||||||
ClusterSigningKeyFile: "/etc/kubernetes/ca/ca.key",
|
|
||||||
ClusterSigningDuration: metav1.Duration{Duration: 8760 * time.Hour},
|
|
||||||
},
|
|
||||||
DaemonSetController: &cmoptions.DaemonSetControllerOptions{
|
|
||||||
ConcurrentDaemonSetSyncs: 2,
|
|
||||||
},
|
|
||||||
DeploymentController: &cmoptions.DeploymentControllerOptions{
|
|
||||||
ConcurrentDeploymentSyncs: 5,
|
|
||||||
DeploymentControllerSyncPeriod: metav1.Duration{Duration: 30 * time.Second},
|
|
||||||
},
|
|
||||||
DeprecatedFlags: &cmoptions.DeprecatedControllerOptions{
|
|
||||||
RegisterRetryCount: 10,
|
|
||||||
},
|
|
||||||
EndPointController: &cmoptions.EndPointControllerOptions{
|
|
||||||
ConcurrentEndpointSyncs: 5,
|
|
||||||
},
|
|
||||||
GarbageCollectorController: &cmoptions.GarbageCollectorControllerOptions{
|
|
||||||
EnableGarbageCollector: true,
|
|
||||||
ConcurrentGCSyncs: 20,
|
|
||||||
},
|
|
||||||
HPAController: &cmoptions.HPAControllerOptions{
|
|
||||||
HorizontalPodAutoscalerSyncPeriod: metav1.Duration{Duration: 30 * time.Second},
|
|
||||||
HorizontalPodAutoscalerUpscaleForbiddenWindow: metav1.Duration{Duration: 3 * time.Minute},
|
|
||||||
HorizontalPodAutoscalerDownscaleForbiddenWindow: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
HorizontalPodAutoscalerTolerance: 0.1,
|
|
||||||
HorizontalPodAutoscalerUseRESTClients: true,
|
|
||||||
},
|
|
||||||
JobController: &cmoptions.JobControllerOptions{
|
|
||||||
ConcurrentJobSyncs: 5,
|
|
||||||
},
|
|
||||||
NamespaceController: &cmoptions.NamespaceControllerOptions{
|
|
||||||
ConcurrentNamespaceSyncs: 10,
|
|
||||||
NamespaceSyncPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
},
|
|
||||||
NodeIpamController: &cmoptions.NodeIpamControllerOptions{
|
|
||||||
NodeCIDRMaskSize: 24,
|
|
||||||
},
|
|
||||||
NodeLifecycleController: &cmoptions.NodeLifecycleControllerOptions{
|
|
||||||
EnableTaintManager: true,
|
|
||||||
NodeMonitorGracePeriod: metav1.Duration{Duration: 40 * time.Second},
|
|
||||||
NodeStartupGracePeriod: metav1.Duration{Duration: 1 * time.Minute},
|
|
||||||
PodEvictionTimeout: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
},
|
|
||||||
PersistentVolumeBinderController: &cmoptions.PersistentVolumeBinderControllerOptions{
|
|
||||||
PVClaimBinderSyncPeriod: metav1.Duration{Duration: 15 * time.Second},
|
|
||||||
VolumeConfiguration: componentconfig.VolumeConfiguration{
|
|
||||||
EnableDynamicProvisioning: true,
|
|
||||||
EnableHostPathProvisioning: false,
|
|
||||||
FlexVolumePluginDir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/",
|
|
||||||
PersistentVolumeRecyclerConfiguration: componentconfig.PersistentVolumeRecyclerConfiguration{
|
|
||||||
MaximumRetry: 3,
|
|
||||||
MinimumTimeoutNFS: 300,
|
|
||||||
IncrementTimeoutNFS: 30,
|
|
||||||
MinimumTimeoutHostPath: 60,
|
|
||||||
IncrementTimeoutHostPath: 30,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
PodGCController: &cmoptions.PodGCControllerOptions{
|
|
||||||
TerminatedPodGCThreshold: 12500,
|
|
||||||
},
|
|
||||||
ReplicaSetController: &cmoptions.ReplicaSetControllerOptions{
|
|
||||||
ConcurrentRSSyncs: 5,
|
|
||||||
},
|
|
||||||
ReplicationController: &cmoptions.ReplicationControllerOptions{
|
|
||||||
ConcurrentRCSyncs: 5,
|
|
||||||
},
|
|
||||||
ResourceQuotaController: &cmoptions.ResourceQuotaControllerOptions{
|
|
||||||
ResourceQuotaSyncPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
ConcurrentResourceQuotaSyncs: 5,
|
|
||||||
},
|
|
||||||
SAController: &cmoptions.SAControllerOptions{
|
|
||||||
ConcurrentSATokenSyncs: 5,
|
|
||||||
},
|
|
||||||
ServiceController: &cmoptions.ServiceControllerOptions{
|
ServiceController: &cmoptions.ServiceControllerOptions{
|
||||||
ConcurrentServiceSyncs: 1,
|
ConcurrentServiceSyncs: 1,
|
||||||
},
|
},
|
||||||
Controllers: []string{"*"},
|
|
||||||
SecureServing: &apiserveroptions.SecureServingOptions{
|
SecureServing: &apiserveroptions.SecureServingOptions{
|
||||||
BindPort: 0,
|
BindPort: 0,
|
||||||
BindAddress: net.ParseIP("0.0.0.0"),
|
BindAddress: net.ParseIP("0.0.0.0"),
|
||||||
|
@ -167,7 +86,6 @@ func TestDefaultFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
Kubeconfig: "",
|
Kubeconfig: "",
|
||||||
Master: "",
|
Master: "",
|
||||||
},
|
|
||||||
NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute},
|
NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expected, s) {
|
if !reflect.DeepEqual(expected, s) {
|
||||||
|
@ -216,7 +134,6 @@ func TestAddFlags(t *testing.T) {
|
||||||
f.Parse(args)
|
f.Parse(args)
|
||||||
|
|
||||||
expected := &CloudControllerManagerOptions{
|
expected := &CloudControllerManagerOptions{
|
||||||
Generic: &cmoptions.GenericControllerManagerOptions{
|
|
||||||
CloudProvider: &cmoptions.CloudProviderOptions{
|
CloudProvider: &cmoptions.CloudProviderOptions{
|
||||||
Name: "gce",
|
Name: "gce",
|
||||||
CloudConfigFile: "/cloud-config",
|
CloudConfigFile: "/cloud-config",
|
||||||
|
@ -249,89 +166,9 @@ func TestAddFlags(t *testing.T) {
|
||||||
CIDRAllocatorType: "RangeAllocator",
|
CIDRAllocatorType: "RangeAllocator",
|
||||||
ConfigureCloudRoutes: false,
|
ConfigureCloudRoutes: false,
|
||||||
},
|
},
|
||||||
AttachDetachController: &cmoptions.AttachDetachControllerOptions{
|
|
||||||
ReconcilerSyncLoopPeriod: metav1.Duration{Duration: 1 * time.Minute},
|
|
||||||
},
|
|
||||||
CSRSigningController: &cmoptions.CSRSigningControllerOptions{
|
|
||||||
ClusterSigningCertFile: "/etc/kubernetes/ca/ca.pem",
|
|
||||||
ClusterSigningKeyFile: "/etc/kubernetes/ca/ca.key",
|
|
||||||
ClusterSigningDuration: metav1.Duration{Duration: 8760 * time.Hour},
|
|
||||||
},
|
|
||||||
DaemonSetController: &cmoptions.DaemonSetControllerOptions{
|
|
||||||
ConcurrentDaemonSetSyncs: 2,
|
|
||||||
},
|
|
||||||
DeploymentController: &cmoptions.DeploymentControllerOptions{
|
|
||||||
ConcurrentDeploymentSyncs: 5,
|
|
||||||
DeploymentControllerSyncPeriod: metav1.Duration{Duration: 30 * time.Second},
|
|
||||||
},
|
|
||||||
DeprecatedFlags: &cmoptions.DeprecatedControllerOptions{
|
|
||||||
RegisterRetryCount: 10,
|
|
||||||
},
|
|
||||||
EndPointController: &cmoptions.EndPointControllerOptions{
|
|
||||||
ConcurrentEndpointSyncs: 5,
|
|
||||||
},
|
|
||||||
GarbageCollectorController: &cmoptions.GarbageCollectorControllerOptions{
|
|
||||||
ConcurrentGCSyncs: 20,
|
|
||||||
EnableGarbageCollector: true,
|
|
||||||
},
|
|
||||||
HPAController: &cmoptions.HPAControllerOptions{
|
|
||||||
HorizontalPodAutoscalerSyncPeriod: metav1.Duration{Duration: 30 * time.Second},
|
|
||||||
HorizontalPodAutoscalerUpscaleForbiddenWindow: metav1.Duration{Duration: 3 * time.Minute},
|
|
||||||
HorizontalPodAutoscalerDownscaleForbiddenWindow: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
HorizontalPodAutoscalerTolerance: 0.1,
|
|
||||||
HorizontalPodAutoscalerUseRESTClients: true,
|
|
||||||
},
|
|
||||||
JobController: &cmoptions.JobControllerOptions{
|
|
||||||
ConcurrentJobSyncs: 5,
|
|
||||||
},
|
|
||||||
NamespaceController: &cmoptions.NamespaceControllerOptions{
|
|
||||||
NamespaceSyncPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
ConcurrentNamespaceSyncs: 10,
|
|
||||||
},
|
|
||||||
NodeIpamController: &cmoptions.NodeIpamControllerOptions{
|
|
||||||
NodeCIDRMaskSize: 24,
|
|
||||||
},
|
|
||||||
NodeLifecycleController: &cmoptions.NodeLifecycleControllerOptions{
|
|
||||||
EnableTaintManager: true,
|
|
||||||
NodeMonitorGracePeriod: metav1.Duration{Duration: 40 * time.Second},
|
|
||||||
NodeStartupGracePeriod: metav1.Duration{Duration: 1 * time.Minute},
|
|
||||||
PodEvictionTimeout: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
},
|
|
||||||
PersistentVolumeBinderController: &cmoptions.PersistentVolumeBinderControllerOptions{
|
|
||||||
PVClaimBinderSyncPeriod: metav1.Duration{Duration: 15 * time.Second},
|
|
||||||
VolumeConfiguration: componentconfig.VolumeConfiguration{
|
|
||||||
EnableDynamicProvisioning: true,
|
|
||||||
EnableHostPathProvisioning: false,
|
|
||||||
FlexVolumePluginDir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/",
|
|
||||||
PersistentVolumeRecyclerConfiguration: componentconfig.PersistentVolumeRecyclerConfiguration{
|
|
||||||
MaximumRetry: 3,
|
|
||||||
MinimumTimeoutNFS: 300,
|
|
||||||
IncrementTimeoutNFS: 30,
|
|
||||||
MinimumTimeoutHostPath: 60,
|
|
||||||
IncrementTimeoutHostPath: 30,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
PodGCController: &cmoptions.PodGCControllerOptions{
|
|
||||||
TerminatedPodGCThreshold: 12500,
|
|
||||||
},
|
|
||||||
ReplicaSetController: &cmoptions.ReplicaSetControllerOptions{
|
|
||||||
ConcurrentRSSyncs: 5,
|
|
||||||
},
|
|
||||||
ReplicationController: &cmoptions.ReplicationControllerOptions{
|
|
||||||
ConcurrentRCSyncs: 5,
|
|
||||||
},
|
|
||||||
ResourceQuotaController: &cmoptions.ResourceQuotaControllerOptions{
|
|
||||||
ResourceQuotaSyncPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
|
||||||
ConcurrentResourceQuotaSyncs: 5,
|
|
||||||
},
|
|
||||||
SAController: &cmoptions.SAControllerOptions{
|
|
||||||
ConcurrentSATokenSyncs: 5,
|
|
||||||
},
|
|
||||||
ServiceController: &cmoptions.ServiceControllerOptions{
|
ServiceController: &cmoptions.ServiceControllerOptions{
|
||||||
ConcurrentServiceSyncs: 1,
|
ConcurrentServiceSyncs: 1,
|
||||||
},
|
},
|
||||||
Controllers: []string{"*"},
|
|
||||||
SecureServing: &apiserveroptions.SecureServingOptions{
|
SecureServing: &apiserveroptions.SecureServingOptions{
|
||||||
BindPort: 10001,
|
BindPort: 10001,
|
||||||
BindAddress: net.ParseIP("192.168.4.21"),
|
BindAddress: net.ParseIP("192.168.4.21"),
|
||||||
|
@ -348,7 +185,6 @@ func TestAddFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
Kubeconfig: "/kubeconfig",
|
Kubeconfig: "/kubeconfig",
|
||||||
Master: "192.168.4.20",
|
Master: "192.168.4.20",
|
||||||
},
|
|
||||||
NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Minute},
|
NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Minute},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expected, s) {
|
if !reflect.DeepEqual(expected, s) {
|
||||||
|
|
|
@ -33,6 +33,22 @@ type GenericComponentConfigOptions struct {
|
||||||
LeaderElection componentconfig.LeaderElectionConfiguration
|
LeaderElection componentconfig.LeaderElectionConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewGenericComponentConfigOptions returns generic configuration default values for both
|
||||||
|
// 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.
|
||||||
|
func NewGenericComponentConfigOptions(cfg componentconfig.GenericComponentConfiguration) *GenericComponentConfigOptions {
|
||||||
|
o := &GenericComponentConfigOptions{
|
||||||
|
MinResyncPeriod: cfg.MinResyncPeriod,
|
||||||
|
ContentType: cfg.ContentType,
|
||||||
|
KubeAPIQPS: cfg.KubeAPIQPS,
|
||||||
|
KubeAPIBurst: cfg.KubeAPIBurst,
|
||||||
|
ControllerStartInterval: cfg.ControllerStartInterval,
|
||||||
|
LeaderElection: cfg.LeaderElection,
|
||||||
|
}
|
||||||
|
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
// AddFlags adds flags related to generic for controller manager to the specified FlagSet.
|
// AddFlags adds flags related to generic for controller manager to the specified FlagSet.
|
||||||
func (o *GenericComponentConfigOptions) AddFlags(fs *pflag.FlagSet) {
|
func (o *GenericComponentConfigOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
|
|
|
@ -40,6 +40,22 @@ type KubeCloudSharedOptions struct {
|
||||||
NodeSyncPeriod metav1.Duration
|
NodeSyncPeriod metav1.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewKubeCloudSharedOptions returns common/default configuration values for both
|
||||||
|
// 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.
|
||||||
|
func NewKubeCloudSharedOptions(cfg componentconfig.KubeCloudSharedConfiguration) *KubeCloudSharedOptions {
|
||||||
|
o := &KubeCloudSharedOptions{
|
||||||
|
Port: cfg.Port,
|
||||||
|
Address: cfg.Address,
|
||||||
|
RouteReconciliationPeriod: cfg.RouteReconciliationPeriod,
|
||||||
|
NodeMonitorPeriod: cfg.NodeMonitorPeriod,
|
||||||
|
ClusterName: cfg.ClusterName,
|
||||||
|
ConfigureCloudRoutes: cfg.ConfigureCloudRoutes,
|
||||||
|
}
|
||||||
|
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
// AddFlags adds flags related to shared variable for controller manager to the specified FlagSet.
|
// AddFlags adds flags related to shared variable for controller manager to the specified FlagSet.
|
||||||
func (o *KubeCloudSharedOptions) AddFlags(fs *pflag.FlagSet) {
|
func (o *KubeCloudSharedOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
|
|
Loading…
Reference in New Issue