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

fix: --kubeconfig doesn't work #605

Merged
merged 1 commit into from
Aug 19, 2023
Merged

Conversation

jianzhangbjz
Copy link
Contributor

Closes #604

πŸ“‘ Description

βœ… Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

β„Ή Additional Information

@jianzhangbjz jianzhangbjz requested review from a team as code owners August 14, 2023 07:11
If user specify `--kubeconfig` when running k8sgpt, it should use the
kubeconfig file to login the corresponding cluster instead of getting auth info via SA.

Closes k8sgpt-ai#604

Signed-off-by: Jian Zhang <jiazha@redhat.com>
@jianzhangbjz jianzhangbjz changed the title use KUBECONFIG when users specify it fix: use kubeconfig file when user specify it Aug 15, 2023
@jianzhangbjz jianzhangbjz changed the title fix: use kubeconfig file when user specify it fix: --kubeconfig doesn't work Aug 15, 2023
@jianzhangbjz
Copy link
Contributor Author

Hi @AlexsJones could you help review it when you get a chance? Thanks!

Copy link
Member

@arbreezy arbreezy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jianzhangbjz
Copy link
Contributor Author

Hi @arbreezy , thanks for reviewing! But, could you help merge it manually? Or anything else I need to do? Thanks! Seems like it was blocked.
image

@arbreezy
Copy link
Member

Hi @arbreezy , thanks for reviewing! But, could you help merge it manually? Or anything else I need to do? Thanks! Seems like it was blocked. image

we need one more approval to merge it..
maybe @matthisholleville can merge this, I don't have access on this repo

@AlexsJones AlexsJones merged commit e3b21ec into k8sgpt-ai:main Aug 19, 2023
8 of 9 checks passed
AlexsJones added a commit that referenced this pull request Aug 19, 2023
AlexsJones added a commit that referenced this pull request Aug 19, 2023
@AlexsJones
Copy link
Member

I had to back this out as I realised that if no kubeconfig is set as a parameter, then it will assume incluster - which is not correct. For example on my local machine:

 οŒ’ ξ‚°  ~/Code/k8sgpt ξ‚° ο„“  main ?1 ξ‚° go run ./main.go analyze                              ξ‚² βœ” 
Error initialising kubernetes client: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined
Error: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined

@jianzhangbjz
Copy link
Contributor Author

Hi @AlexsJones , sorry, I'm a little bit confused. It works well in my local. As you know, if no kubeconfig is set, it will get KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT values from ENV variables, see https://github.com/kubernetes/client-go/blob/master/rest/config.go#L516 . So one question, did you export them on your local env? Thanks!

@jianzhangbjz
Copy link
Contributor Author

Hi @AlexsJones , this #604 issue still exists, could you help revert #608? Or anything else I missed? Thanks! cc: @arbreezy

@arbreezy
Copy link
Member

arbreezy commented Sep 6, 2023

Hey @jianzhangbjz just a heads up, we merged a fix on this issue recently.

@jianzhangbjz jianzhangbjz deleted the kubeconfig branch October 9, 2023 03:19
@jianzhangbjz
Copy link
Contributor Author

Hi @arbreezy , got it, thanks!

@jianzhangbjz jianzhangbjz restored the kubeconfig branch October 10, 2023 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug]: --kubeconfig doesn't work
3 participants