Commit 33c9ab48 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #41410 from irfanurrehman/fed-bug-fix-1

Automatic merge from submit-queue (batch tested with PRs 41134, 41410, 40177, 41049, 41313) [Federation][Kubefed] Bug fix relating kubeconfig path in kubefed init **What this PR does / why we need it**: Fixes https://github.com/kubernetes/kubernetes/issues/41305 **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # https://github.com/kubernetes/kubernetes/issues/41305 The kubeconfig explicit path is not updated correctly when supplied through the --kubeconfig flag in kubefed init. This leads to the details about the initialised federation control plane not getting updated in the correct kubeconfig file. **Special notes for your reviewer**: @madhusudancs **Release note**: ``` Fixed a bug that caused the kubeconfig entry for the initialized federation control plane to be not written to the supplied kubeconfig file when the file was supplied through the --kubeconfig flag. ```
parents 5cc2f73b c71fd732
...@@ -326,7 +326,7 @@ func (i *initFederation) Run(cmdOut io.Writer, config util.AdminConfig) error { ...@@ -326,7 +326,7 @@ func (i *initFederation) Run(cmdOut io.Writer, config util.AdminConfig) error {
// 8. Write the federation API server endpoint info, credentials // 8. Write the federation API server endpoint info, credentials
// and context to kubeconfig // and context to kubeconfig
err = updateKubeconfig(config, i.commonOptions.Name, endpoint, entKeyPairs, i.options.dryRun) err = updateKubeconfig(config, i.commonOptions.Name, endpoint, i.commonOptions.Kubeconfig, entKeyPairs, i.options.dryRun)
if err != nil { if err != nil {
return err return err
} }
...@@ -891,8 +891,9 @@ func printSuccess(cmdOut io.Writer, ips, hostnames []string, svc *api.Service) e ...@@ -891,8 +891,9 @@ func printSuccess(cmdOut io.Writer, ips, hostnames []string, svc *api.Service) e
return err return err
} }
func updateKubeconfig(config util.AdminConfig, name, endpoint string, entKeyPairs *entityKeyPairs, dryRun bool) error { func updateKubeconfig(config util.AdminConfig, name, endpoint, kubeConfigPath string, entKeyPairs *entityKeyPairs, dryRun bool) error {
po := config.PathOptions() po := config.PathOptions()
po.LoadingRules.ExplicitPath = kubeConfigPath
kubeconfig, err := po.GetStartingConfig() kubeconfig, err := po.GetStartingConfig()
if err != nil { if err != nil {
return err return err
......
...@@ -114,8 +114,8 @@ func TestInitFederation(t *testing.T) { ...@@ -114,8 +114,8 @@ func TestInitFederation(t *testing.T) {
}, },
{ {
federation: "union", federation: "union",
kubeconfigGlobal: fakeKubeFiles[0], kubeconfigGlobal: fakeKubeFiles[1],
kubeconfigExplicit: "", kubeconfigExplicit: fakeKubeFiles[2],
dnsZoneName: "example.test.", dnsZoneName: "example.test.",
lbIP: lbIP, lbIP: lbIP,
apiserverServiceType: v1.ServiceTypeLoadBalancer, apiserverServiceType: v1.ServiceTypeLoadBalancer,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment