Skip to content
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

Automatically use KUBECONFIG env var #29

Open
AdrianoKF opened this issue Jul 27, 2021 · 3 comments
Open

Automatically use KUBECONFIG env var #29

AdrianoKF opened this issue Jul 27, 2021 · 3 comments
Labels
enhancement New feature or request PM-review

Comments

@AdrianoKF
Copy link

AdrianoKF commented Jul 27, 2021

What would you like to be added:

Currently, kai will use ~/.kube/config to connect to the cluster, even if the KUBECONFIG environment variable points to a different file. This makes it necessary to manually specify the -k $KUBECONFIG option when calling kai, creating the risk of inadvertently running kai against a different cluster than kubectl.

I would propose that kai should automatically use the kubeconfig file pointed to by the KUBECONFIG enviroment variable if it is set, otherwise attempt to use the current default of ~/.kube/config as a fallback to be consistent with other k8s tools.

Why is this needed:

Some users keep multiple separate kubeconfig files and switch between them by pointing the KUBECONFIG environment variable at the active config file. Kubectl and friends automatically pick up the active config from the environment, so having kai do the same would increase consistency and reduce the surprise factor for the user.

Additional context:

@AdrianoKF AdrianoKF added the enhancement New feature or request label Jul 27, 2021
@zburstein
Copy link

Hello @AdrianoKF! Thanks for submitting the request. I have passed it along to PM for review

@dakaneye
Copy link
Contributor

dakaneye commented Sep 1, 2021

@AdrianoKF @zburstein just wanna check on something real quick here!

The environment variable to set the kubeconfig path should take precedence, but want to make sure we're setting the right one. In order for KAI to prefer a different path besides the home directory's kubeconfig, it looks in the following places:

  1. KAI_KUBECONFIG_PATH
  2. kai.yaml kubeconfig path override: kubeconfig.path
  3. kai.yaml direct kube config (i.e. translating the actual kubeconfig into the kai.yaml file)
  4. ~.kube/config

So, as you mentioned, kai is not respecting the KUBECONFIG env var directly, but it would respect KAI_KUBECONFIG_PATH. It seems that you're suggesting that the KUBECONFIG env var is used more commonly by k8s operators and that we should interpret that as well. Perhaps we could add it between options 3 and 4 above in terms of order of precedence? Would that satisfy the feature request as it's laid out in your comment?

@flickerfly
Copy link

@dakaneye Yes, I like adding it between 3 and 4. That'll allow for it to work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PM-review
Projects
None yet
Development

No branches or pull requests

4 participants