mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
do some code clean for cloud-controller manager
This commit is contained in:
parent
9c2e51f37c
commit
be7f087ade
@ -45,6 +45,11 @@ import (
|
|||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// CloudControllerManagerUserAgent is the userAgent name when starting cloud-controller managers.
|
||||||
|
CloudControllerManagerUserAgent = "cloud-controller-manager"
|
||||||
|
)
|
||||||
|
|
||||||
// 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 {
|
||||||
CloudProvider *cmoptions.CloudProviderOptions
|
CloudProvider *cmoptions.CloudProviderOptions
|
||||||
@ -165,7 +170,7 @@ func (o *CloudControllerManagerOptions) ApplyTo(c *cloudcontrollerconfig.Config,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sync back to component config
|
// 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(o.InsecureServing.BindPort)
|
c.ComponentConfig.KubeCloudShared.Port = int32(o.InsecureServing.BindPort)
|
||||||
c.ComponentConfig.KubeCloudShared.Address = o.InsecureServing.BindAddress.String()
|
c.ComponentConfig.KubeCloudShared.Address = o.InsecureServing.BindAddress.String()
|
||||||
|
|
||||||
@ -213,13 +218,13 @@ func (o *CloudControllerManagerOptions) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Config return a cloud controller manager config objective
|
// Config return a cloud controller manager config objective
|
||||||
func (o CloudControllerManagerOptions) Config() (*cloudcontrollerconfig.Config, error) {
|
func (o *CloudControllerManagerOptions) Config() (*cloudcontrollerconfig.Config, error) {
|
||||||
if err := o.Validate(); err != nil {
|
if err := o.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &cloudcontrollerconfig.Config{}
|
c := &cloudcontrollerconfig.Config{}
|
||||||
if err := o.ApplyTo(c, "cloud-controller-manager"); err != nil {
|
if err := o.ApplyTo(c, CloudControllerManagerUserAgent); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,5 +235,6 @@ func createRecorder(kubeClient kubernetes.Interface, userAgent string) record.Ev
|
|||||||
eventBroadcaster := record.NewBroadcaster()
|
eventBroadcaster := record.NewBroadcaster()
|
||||||
eventBroadcaster.StartLogging(glog.Infof)
|
eventBroadcaster.StartLogging(glog.Infof)
|
||||||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
|
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
|
||||||
|
// TODO: remove dependence on the legacyscheme
|
||||||
return eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: userAgent})
|
return eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: userAgent})
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@ func TestAddFlags(t *testing.T) {
|
|||||||
"--contention-profiling=true",
|
"--contention-profiling=true",
|
||||||
"--controller-start-interval=2m",
|
"--controller-start-interval=2m",
|
||||||
"--http2-max-streams-per-connection=47",
|
"--http2-max-streams-per-connection=47",
|
||||||
"--min-resync-period=5m",
|
|
||||||
"--kube-api-burst=100",
|
"--kube-api-burst=100",
|
||||||
"--kube-api-content-type=application/vnd.kubernetes.protobuf",
|
"--kube-api-content-type=application/vnd.kubernetes.protobuf",
|
||||||
"--kube-api-qps=50.0",
|
"--kube-api-qps=50.0",
|
||||||
@ -122,13 +121,12 @@ func TestAddFlags(t *testing.T) {
|
|||||||
"--leader-elect-resource-lock=configmap",
|
"--leader-elect-resource-lock=configmap",
|
||||||
"--leader-elect-retry-period=5s",
|
"--leader-elect-retry-period=5s",
|
||||||
"--master=192.168.4.20",
|
"--master=192.168.4.20",
|
||||||
"--min-resync-period=8h",
|
"--min-resync-period=100m",
|
||||||
|
"--node-status-update-frequency=10m",
|
||||||
"--port=10000",
|
"--port=10000",
|
||||||
"--profiling=false",
|
"--profiling=false",
|
||||||
"--node-status-update-frequency=10m",
|
|
||||||
"--route-reconciliation-period=30s",
|
"--route-reconciliation-period=30s",
|
||||||
"--secure-port=10001",
|
"--secure-port=10001",
|
||||||
"--min-resync-period=100m",
|
|
||||||
"--use-service-account-credentials=false",
|
"--use-service-account-credentials=false",
|
||||||
}
|
}
|
||||||
f.Parse(args)
|
f.Parse(args)
|
||||||
|
Loading…
Reference in New Issue
Block a user