diff --git a/cmd/kube-controller-manager/app/options/options.go b/cmd/kube-controller-manager/app/options/options.go index 3959fc82d5e..6c322f92521 100644 --- a/cmd/kube-controller-manager/app/options/options.go +++ b/cmd/kube-controller-manager/app/options/options.go @@ -92,7 +92,6 @@ type KubeControllerManagerOptions struct { Logs *logs.Options Master string - Kubeconfig string ShowHiddenMetricsForVersion string } @@ -260,7 +259,7 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy fs := fss.FlagSet("misc") fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).") - fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.") + fs.StringVar(&s.Generic.ClientConnection.Kubeconfig, "kubeconfig", s.Generic.ClientConnection.Kubeconfig, "Path to kubeconfig file with authorization and master location information (the master location can be overridden by the master flag).") utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic")) return fss @@ -414,7 +413,7 @@ func (s KubeControllerManagerOptions) Config(allControllers []string, disabledBy return nil, fmt.Errorf("error creating self-signed certificates: %v", err) } - kubeconfig, err := clientcmd.BuildConfigFromFlags(s.Master, s.Kubeconfig) + kubeconfig, err := clientcmd.BuildConfigFromFlags(s.Master, s.Generic.ClientConnection.Kubeconfig) if err != nil { return nil, err } diff --git a/cmd/kube-controller-manager/app/options/options_test.go b/cmd/kube-controller-manager/app/options/options_test.go index 48cd471d5e1..6220d226837 100644 --- a/cmd/kube-controller-manager/app/options/options_test.go +++ b/cmd/kube-controller-manager/app/options/options_test.go @@ -180,6 +180,7 @@ func TestAddFlags(t *testing.T) { Address: "0.0.0.0", // Note: This field should have no effect in CM now, and "0.0.0.0" is the default value. MinResyncPeriod: metav1.Duration{Duration: 8 * time.Hour}, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + Kubeconfig: "/kubeconfig", ContentType: "application/json", QPS: 50.0, Burst: 100, @@ -434,10 +435,9 @@ func TestAddFlags(t *testing.T) { AlwaysAllowPaths: []string{"/healthz", "/readyz", "/livez"}, // note: this does not match /healthz/ or /healthz/* AlwaysAllowGroups: []string{"system:masters"}, }, - Kubeconfig: "/kubeconfig", - Master: "192.168.4.20", - Metrics: &metrics.Options{}, - Logs: logs.NewOptions(), + Master: "192.168.4.20", + Metrics: &metrics.Options{}, + Logs: logs.NewOptions(), } // Sort GCIgnoredResources because it's built from a map, which means the @@ -468,6 +468,7 @@ func TestApplyTo(t *testing.T) { Address: "0.0.0.0", // Note: This field should have no effect in CM now, and "0.0.0.0" is the default value. MinResyncPeriod: metav1.Duration{Duration: 8 * time.Hour}, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + Kubeconfig: "/kubeconfig", ContentType: "application/json", QPS: 50.0, Burst: 100, diff --git a/staging/src/k8s.io/cloud-provider/options/options.go b/staging/src/k8s.io/cloud-provider/options/options.go index fdf8e65c704..e4aba1c7c7a 100644 --- a/staging/src/k8s.io/cloud-provider/options/options.go +++ b/staging/src/k8s.io/cloud-provider/options/options.go @@ -63,8 +63,7 @@ type CloudControllerManagerOptions struct { Authentication *apiserveroptions.DelegatingAuthenticationOptions Authorization *apiserveroptions.DelegatingAuthorizationOptions - Master string - Kubeconfig string + Master string // NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status NodeStatusUpdateFrequency metav1.Duration @@ -133,7 +132,7 @@ func (o *CloudControllerManagerOptions) Flags(allControllers, disabledByDefaultC fs := fss.FlagSet("misc") 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.StringVar(&o.Generic.ClientConnection.Kubeconfig, "kubeconfig", o.Generic.ClientConnection.Kubeconfig, "Path to kubeconfig file with authorization and master location information (the master location can be overridden by the master flag).") fs.DurationVar(&o.NodeStatusUpdateFrequency.Duration, "node-status-update-frequency", o.NodeStatusUpdateFrequency.Duration, "Specifies how often the controller updates nodes' status.") utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic")) @@ -148,7 +147,7 @@ func (o *CloudControllerManagerOptions) ApplyTo(c *config.Config, userAgent stri // Build kubeconfig first to so that if it fails, it doesn't cause leaking // goroutines (started from initializing secure serving - which underneath // creates a queue which in its constructor starts a goroutine). - c.Kubeconfig, err = clientcmd.BuildConfigFromFlags(o.Master, o.Kubeconfig) + c.Kubeconfig, err = clientcmd.BuildConfigFromFlags(o.Master, o.Generic.ClientConnection.Kubeconfig) if err != nil { return err } diff --git a/staging/src/k8s.io/cloud-provider/options/options_test.go b/staging/src/k8s.io/cloud-provider/options/options_test.go index b7d10ca5d2c..f47bdcb9c5c 100644 --- a/staging/src/k8s.io/cloud-provider/options/options_test.go +++ b/staging/src/k8s.io/cloud-provider/options/options_test.go @@ -44,6 +44,7 @@ func TestDefaultFlags(t *testing.T) { Address: "0.0.0.0", MinResyncPeriod: metav1.Duration{Duration: 12 * time.Hour}, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + Kubeconfig: "", ContentType: "application/vnd.kubernetes.protobuf", QPS: 20.0, Burst: 30, @@ -125,7 +126,6 @@ func TestDefaultFlags(t *testing.T) { AlwaysAllowPaths: []string{"/healthz", "/readyz", "/livez"}, // note: this does not match /healthz/ or /healthz/* AlwaysAllowGroups: []string{"system:masters"}, }, - Kubeconfig: "", Master: "", NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute}, } @@ -188,6 +188,7 @@ func TestAddFlags(t *testing.T) { Address: "0.0.0.0", MinResyncPeriod: metav1.Duration{Duration: 100 * time.Minute}, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + Kubeconfig: "/kubeconfig", ContentType: "application/vnd.kubernetes.protobuf", QPS: 50.0, Burst: 100, @@ -269,7 +270,6 @@ func TestAddFlags(t *testing.T) { AlwaysAllowPaths: []string{}, AlwaysAllowGroups: []string{"system:masters"}, }, - Kubeconfig: "/kubeconfig", Master: "192.168.4.20", NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Minute}, }