holmesgpt icon indicating copy to clipboard operation
holmesgpt copied to clipboard

Allow to specify the kubernetes context

Open mool opened this issue 1 year ago • 12 comments

It would be nice to add support for the --context argument when holmes is executing the kubectl command. This will allow to run holmes without having to change context

mool avatar Nov 03 '24 15:11 mool

We should be able to add something.

It connects well with work we're doing on tool configuration right now (specifically how do you configure tools that require parameters or credentials to work, like pulling data from Grafana cloud or Elasticsearch?)

Would you be open to a short video chat so I can better understand your requirements and verify the solution works?

aantn avatar Nov 03 '24 16:11 aantn

For me this is a must feature. I use holmesgpt from k9s and if the context I'm using inside of k9s is different than the context in zsh(before starting k9s) then shift+h(ask holmesgpt) will not work and will say the namespace or resource does not exist but if holmes worked in the context of k9s then it will work as expected.

ahmedasmar avatar Nov 07 '24 16:11 ahmedasmar

Hi @Hax7, thanks for chiming in.

I think we'll be able to support this properly soon. Until then, could something like this be a workaround?

https://github.com/kubernetes/kubernetes/issues/27308#issuecomment-892726728

aantn avatar Nov 07 '24 18:11 aantn

I don't this "workaround" is related to this case, when 'holmes ask' command is executed from k9s it works on the current-context in the shell not the current context inside k9s. I use kubectx outside of k9s and it works fine so the alias you referred to is not gonna change anything here. I also tried this "holmes ask "why is $NAME of $RESOURCE_NAME in -n $NAMESPACE in --context CONTEXT_NAME not working as expected" but it ignores the --context here for some reason when holmes executs the kubectl command

ahmedasmar avatar Nov 07 '24 20:11 ahmedasmar

Got it, thanks. To elaborate on why this doesn't work, HolmesGPT runs commands according to permitted templates. So to fix this you can patch the templates it uses for kubectl commands and reinstall holmes from source with those changes.

But we're looking into some proper fixes that make this easier to do + a k9s specific fix that we can get to you fast.

aantn avatar Nov 08 '24 04:11 aantn

Is there any update on this issue. Just run in the same problem, Holmes works great in k9s as long as I stay in the context with which I started k9s, as soon as I switch the context inside k9s, it won't work anymore :(

hille721 avatar Jul 09 '25 06:07 hille721

Hi @hille721 and @Hax7, regarding k9s, does the new version of the k9s plugin here work? It should handle the context correctly. (Please confirm and we'll merge it.)

aantn avatar Jul 21 '25 12:07 aantn

@aantn I can confirm with this it is working. Great, thank you!

hille721 avatar Jul 21 '25 13:07 hille721

@hille721 Fantastic, thank you for confirming!

@pavangudiwada we're good to merge :)

aantn avatar Jul 21 '25 13:07 aantn

@hille721 by the way, we're planning to update the k9s plugin again soon, once we do the next release. You can try features like holmes ask in interactive mode on master. Feel free to suggest ways to improve the plugin.

aantn avatar Jul 21 '25 13:07 aantn

I have already installed from the master branch with uv as I didn't liked the excessive logging in the last release. Therefore, I am already enjoying the interactive mode :)

hille721 avatar Jul 21 '25 14:07 hille721

Wonderful, happy to hear it!

On Mon, Jul 21, 2025, 17:37 Christoph Hille @.***> wrote:

hille721 left a comment (robusta-dev/holmesgpt#175) https://github.com/robusta-dev/holmesgpt/issues/175#issuecomment-3097055413

I have already installed from the master branch with uv as I didn't liked the excessive logging in the last release. Therefore, I am already enjoying the interactive mode :)

— Reply to this email directly, view it on GitHub https://github.com/robusta-dev/holmesgpt/issues/175#issuecomment-3097055413, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADYUB7DEMY6GTJODE2WS5D3JT3MFAVCNFSM6AAAAABRC2CM26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAOJXGA2TKNBRGM . You are receiving this because you were mentioned.Message ID: @.***>

aantn avatar Jul 21 '25 14:07 aantn