mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
controller-manager: fix a bug that the kubeconfig field of kubecontrollermanager.config.k8s.io configuration is not set correctly
This commit is contained in:
parent
b6d102d634
commit
eb541bb819
@ -92,7 +92,6 @@ type KubeControllerManagerOptions struct {
|
|||||||
Logs *logs.Options
|
Logs *logs.Options
|
||||||
|
|
||||||
Master string
|
Master string
|
||||||
Kubeconfig string
|
|
||||||
ShowHiddenMetricsForVersion string
|
ShowHiddenMetricsForVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +259,7 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
|
|||||||
|
|
||||||
fs := fss.FlagSet("misc")
|
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.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"))
|
utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic"))
|
||||||
|
|
||||||
return fss
|
return fss
|
||||||
@ -414,7 +413,7 @@ func (s KubeControllerManagerOptions) Config(allControllers []string, disabledBy
|
|||||||
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -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.
|
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},
|
MinResyncPeriod: metav1.Duration{Duration: 8 * time.Hour},
|
||||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||||
|
Kubeconfig: "/kubeconfig",
|
||||||
ContentType: "application/json",
|
ContentType: "application/json",
|
||||||
QPS: 50.0,
|
QPS: 50.0,
|
||||||
Burst: 100,
|
Burst: 100,
|
||||||
@ -434,10 +435,9 @@ func TestAddFlags(t *testing.T) {
|
|||||||
AlwaysAllowPaths: []string{"/healthz", "/readyz", "/livez"}, // note: this does not match /healthz/ or /healthz/*
|
AlwaysAllowPaths: []string{"/healthz", "/readyz", "/livez"}, // note: this does not match /healthz/ or /healthz/*
|
||||||
AlwaysAllowGroups: []string{"system:masters"},
|
AlwaysAllowGroups: []string{"system:masters"},
|
||||||
},
|
},
|
||||||
Kubeconfig: "/kubeconfig",
|
Master: "192.168.4.20",
|
||||||
Master: "192.168.4.20",
|
Metrics: &metrics.Options{},
|
||||||
Metrics: &metrics.Options{},
|
Logs: logs.NewOptions(),
|
||||||
Logs: logs.NewOptions(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort GCIgnoredResources because it's built from a map, which means the
|
// 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.
|
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},
|
MinResyncPeriod: metav1.Duration{Duration: 8 * time.Hour},
|
||||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||||
|
Kubeconfig: "/kubeconfig",
|
||||||
ContentType: "application/json",
|
ContentType: "application/json",
|
||||||
QPS: 50.0,
|
QPS: 50.0,
|
||||||
Burst: 100,
|
Burst: 100,
|
||||||
|
@ -63,8 +63,7 @@ type CloudControllerManagerOptions struct {
|
|||||||
Authentication *apiserveroptions.DelegatingAuthenticationOptions
|
Authentication *apiserveroptions.DelegatingAuthenticationOptions
|
||||||
Authorization *apiserveroptions.DelegatingAuthorizationOptions
|
Authorization *apiserveroptions.DelegatingAuthorizationOptions
|
||||||
|
|
||||||
Master string
|
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
|
||||||
@ -133,7 +132,7 @@ func (o *CloudControllerManagerOptions) Flags(allControllers, disabledByDefaultC
|
|||||||
|
|
||||||
fs := fss.FlagSet("misc")
|
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.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.")
|
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"))
|
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
|
// Build kubeconfig first to so that if it fails, it doesn't cause leaking
|
||||||
// goroutines (started from initializing secure serving - which underneath
|
// goroutines (started from initializing secure serving - which underneath
|
||||||
// creates a queue which in its constructor starts a goroutine).
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ func TestDefaultFlags(t *testing.T) {
|
|||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
MinResyncPeriod: metav1.Duration{Duration: 12 * time.Hour},
|
MinResyncPeriod: metav1.Duration{Duration: 12 * time.Hour},
|
||||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||||
|
Kubeconfig: "",
|
||||||
ContentType: "application/vnd.kubernetes.protobuf",
|
ContentType: "application/vnd.kubernetes.protobuf",
|
||||||
QPS: 20.0,
|
QPS: 20.0,
|
||||||
Burst: 30,
|
Burst: 30,
|
||||||
@ -125,7 +126,6 @@ func TestDefaultFlags(t *testing.T) {
|
|||||||
AlwaysAllowPaths: []string{"/healthz", "/readyz", "/livez"}, // note: this does not match /healthz/ or /healthz/*
|
AlwaysAllowPaths: []string{"/healthz", "/readyz", "/livez"}, // note: this does not match /healthz/ or /healthz/*
|
||||||
AlwaysAllowGroups: []string{"system:masters"},
|
AlwaysAllowGroups: []string{"system:masters"},
|
||||||
},
|
},
|
||||||
Kubeconfig: "",
|
|
||||||
Master: "",
|
Master: "",
|
||||||
NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute},
|
NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute},
|
||||||
}
|
}
|
||||||
@ -188,6 +188,7 @@ func TestAddFlags(t *testing.T) {
|
|||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
MinResyncPeriod: metav1.Duration{Duration: 100 * time.Minute},
|
MinResyncPeriod: metav1.Duration{Duration: 100 * time.Minute},
|
||||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||||
|
Kubeconfig: "/kubeconfig",
|
||||||
ContentType: "application/vnd.kubernetes.protobuf",
|
ContentType: "application/vnd.kubernetes.protobuf",
|
||||||
QPS: 50.0,
|
QPS: 50.0,
|
||||||
Burst: 100,
|
Burst: 100,
|
||||||
@ -269,7 +270,6 @@ func TestAddFlags(t *testing.T) {
|
|||||||
AlwaysAllowPaths: []string{},
|
AlwaysAllowPaths: []string{},
|
||||||
AlwaysAllowGroups: []string{"system:masters"},
|
AlwaysAllowGroups: []string{"system:masters"},
|
||||||
},
|
},
|
||||||
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},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user