mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 05:30:26 +00:00
Merge pull request #116219 from SataQiu/fix-kube-controller-manager-20230302
kube-controller-manager: fix a bug that the kubeconfig field of kubecontrollermanager.config.k8s.io configuration is not populated correctly
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user