-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DefaultPath is not always path used for kubeconfig #228
Comments
Great spot @kschumy. My take on this is that we should have the same behaviour as kubectl. With kubectl the With just the env var:
With the env var and flag:
Would you agree @errordeveloper and @christopherhein ? |
I would agree, resolving down to the typical |
@kschumy this is a very nice and detailed bug report, I apologies for a belated response... I'd be keen to see a PR that fixes it, if you need any help - let's chat on Slack. |
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` ome is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` one is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` one is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` one is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` one is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` one is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
This commit aims to make aware `eksctl` of the `KUBECONFIG` environment variable, especially during cluster creation and kubeconfig retrieval via the `eksctl utils write-kubeconfig` command. To avoid conflicts and keep the actual convention, the variable `DefaultPath` has been declared using a simple _func_ in order to don't perform an invasive refactoring requested by a switch to function declaration. Actually, using the standard library to retrieve the environment variable and not using the `viper` helper (although already a dependency) since the `KUBECONFIG` one is considered as a global one, so totally unbounded from `eksctl`. Code coverage is going to decrease since during the test suite setup, the environment variable is evaluated before the execution of tests: to provide further coverage, the conversion from variable to function has to be performed, although this requires some changes in the following files and should be considered and approved by maintainers: - pkg/ctl/cmdutils/cmdutils.go - pkg/ctl/create/cluster.go - pkg/ctl/utils/write_kubeconfig.go - pkg/utils/kubeconfig/kubeconfig.go Closes eksctl-io#228
What happened?
I'm not sure if this is a bug or intentionally designed this way, but I figured I'd bring it up just in case.
doCreateCluster()
usesDefaultPath
as the kubeconfig path when callingkubeconfig.Write()
.DefaultPath
is set to$HOME/.kube/config
. However, when it goes to actually write the config file withModifyConfig()
in clientcmd/config.go, precidence is given to theKUBECONFIG
env variable(s) and$HOME/.kube/config
(ieDefaultPath
) is used only if there is nothing assigned toKUBECONFIG
.DefaultPath seems to imply that is the path that will be used, but this isn't always the case. While it seems that most people have
$HOME/.kube/config
assigned toKUBECONFIG
and thus this issue doesn't visibly impact them, having it set to this path is not a requirement.What you expected to happen?
I expected DefaultPath to be the path that will be used for the kubeconfig.
How to reproduce it?
See gist for possibly too many details and printed logger statements to demonstrate this.
Anything else we need to know?
I discovered this while working on a PR to delete the cluster from the kubeconfig file. Since I was unsure of if this was actually a bug, I opted to treat it as intentional and used the same logic as doCreateCluster() to delete the cluster. Since the logic is similar, removing the cluster from the kubeconfig will have the same impact as described above
Versions
NOTE: I was using a branch off my fork of master
Logs
See gist in "How to reproduce it?" section
The text was updated successfully, but these errors were encountered: