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

Respect the $KUBECONFIG env as top precedence #331

Closed
3 of 4 tasks
Dentrax opened this issue Apr 25, 2023 · 0 comments · Fixed by #340 or #335
Closed
3 of 4 tasks

Respect the $KUBECONFIG env as top precedence #331

Dentrax opened this issue Apr 25, 2023 · 0 comments · Fixed by #340 or #335
Assignees

Comments

@Dentrax
Copy link

Dentrax commented Apr 25, 2023

Checklist:

  • I've searched for similar issues and couldn't find anything matching
  • I've discussed this feature in the #k8sgpt slack channel

Is this feature request related to a problem?

  • Yes
  • No

On first try, I couldn't able to run k8sgpt:

$ k8sgpt analyze

Error initialising kubernetes client: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
Error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

Even $KUBECONFIG is set and context is correct:

$ echo $KUBECONFIG

/Users/furkan.turkal/.kube/my-foo-cluster-kubeconfig

This means that k8sgpt is inconsistent with how kubectl handle this.

Current behavior is k8sgpt does not respect $KUBECONFIG env. You should manually copy the path of kubeconfig and pass --kubeconfig flag every time when you switch the context, which significantly decrease overall UX.

export KUBECONFIG=/path/to/your/kubeconfig1
k8sgpt analyze --kubeconfig /path/to/your/kubeconfig1 -e

export KUBECONFIG=/path/to/your/kubeconfig2
k8sgpt analyze --kubeconfig /path/to/your/kubeconfig2 -e

export KUBECONFIG=/path/to/your/kubeconfig3
k8sgpt analyze --kubeconfig /path/to/your/kubeconfig3 -e

Expected behavior:

export KUBECONFIG=/path/to/your/kubeconfig1
k8sgpt analyze -e

export KUBECONFIG=/path/to/your/kubeconfig2
k8sgpt analyze -e

export KUBECONFIG=/path/to/your/kubeconfig3
k8sgpt analyze -e

Describe the solution you'd like

Respect $KUBECONFIG env (if set) and it should be first precedence. (like how kubectl did)

Benefits for the project and its users

Consistency and better UX.

Potential drawbacks

It would be a backward-incompatible behavior.

Additional context

-

@patrickpichler patrickpichler self-assigned this Apr 25, 2023
patrickpichler pushed a commit to patrickpichler/k8sgpt that referenced this issue Apr 25, 2023
Before, the default value set for the `--kubeconfig` flag prevented the
`KUBECONFIG` env variable to be ever taken into consideration. This
behavior has now been fixed.

If `--kubeconfig` flag is set, it takes precedence over the `KUBECONFIG` env
variable.

fixes k8sgpt-ai#331

Signed-off-by: Patrick Pichler <git@patrickpichler.dev>
patrickpichler pushed a commit to patrickpichler/k8sgpt that referenced this issue Apr 26, 2023
Before, the default value set for the `--kubeconfig` flag prevented the
`KUBECONFIG` env variable to be ever taken into consideration. This
behavior has now been fixed.

If `--kubeconfig` flag is set, it takes precedence over the `KUBECONFIG` env
variable.

fixes k8sgpt-ai#331

Signed-off-by: Patrick Pichler <git@patrickpichler.dev>
AlexsJones pushed a commit that referenced this issue Apr 26, 2023
Before, the default value set for the `--kubeconfig` flag prevented the
`KUBECONFIG` env variable to be ever taken into consideration. This
behavior has now been fixed.

If `--kubeconfig` flag is set, it takes precedence over the `KUBECONFIG` env
variable.

fixes #331

Signed-off-by: Patrick Pichler <git@patrickpichler.dev>
Co-authored-by: Patrick Pichler <git@patrickpichler.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants