mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
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. ```
This commit is contained in:
commit
33c9ab4830
@ -326,7 +326,7 @@ func (i *initFederation) Run(cmdOut io.Writer, config util.AdminConfig) error {
|
||||
|
||||
// 8. Write the federation API server endpoint info, credentials
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
@ -891,8 +891,9 @@ func printSuccess(cmdOut io.Writer, ips, hostnames []string, svc *api.Service) e
|
||||
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.LoadingRules.ExplicitPath = kubeConfigPath
|
||||
kubeconfig, err := po.GetStartingConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -114,8 +114,8 @@ func TestInitFederation(t *testing.T) {
|
||||
},
|
||||
{
|
||||
federation: "union",
|
||||
kubeconfigGlobal: fakeKubeFiles[0],
|
||||
kubeconfigExplicit: "",
|
||||
kubeconfigGlobal: fakeKubeFiles[1],
|
||||
kubeconfigExplicit: fakeKubeFiles[2],
|
||||
dnsZoneName: "example.test.",
|
||||
lbIP: lbIP,
|
||||
apiserverServiceType: v1.ServiceTypeLoadBalancer,
|
||||
|
Loading…
Reference in New Issue
Block a user