k9s icon indicating copy to clipboard operation
k9s copied to clipboard

Proxy support

Open rocketraman opened this issue 4 years ago • 7 comments




Is your feature request related to a problem? Please describe. Some clusters require proxies in order to access their APIs. Most notably, GKE clusters with private networking. When using kubectl, one can work around this by setting the https_proxy variable for specific commands. However, with k9s I don't see any way to connect to a cluster via a proxy (edit, per a comment in #371 the slightly non-standard uppercase HTTPS_PROXY does work).

However, the https_proxy / HTTPS_PROXY env var for k9s is not ideal as different clusters often need different proxies, and this approach does not allow switching contexts that need a different proxy (or no proxy) without restarting k9s with the appropriate environment.

Describe the solution you'd like I'd love a way to configure a proxy on a per-context basis. Lens supports this, for example.

Describe alternatives you've considered I don't have any alternatives.

Additional context Kubectl 1.19+ has the ability to configure proxies via kube config: https://github.com/kubernetes/client-go/issues/351. Its likely any solution in k9s should first use this setting, and only fall-back to a k9s-native proxy configuration mechanism.

rocketraman avatar Jul 28 '20 16:07 rocketraman

Looks like that this is now working out-of-the-box, tested on v0.24.15.

xens avatar Aug 09 '21 18:08 xens

After updating to v0.26.3 from v0.25.*, the proxy functionality seems broken, when choosing a cluster to connect to results in "Unable to connect to context". kubectl commands in the same terminal work fine, and v0.25 works fine too.

edit: this is for proxy set using HTTPS/HTTP_PROXY.

MichaelHindley avatar Aug 15 '22 08:08 MichaelHindley

Should we create a dedicated issue to support the proxy-url field in a kubeconfig instead?

It seems to solve this issue but is more explicit regarding the actual steps required.

thewilli avatar Nov 24 '22 11:11 thewilli

I am having this problem, too.

kubectl works just fine with the proxy settings (via env vars) in the same terminal. Any chances that this will get fixed soon?

Thank you!

nrekretep avatar Jul 21 '23 12:07 nrekretep

I'll add a "me too" to this - Defining in a kubeconfig works fine, k9s? Nope.

If I run the command with HTTPS_PROXY defined to a socks5 proxy, that works - But it would be good for k9s to support the same kubeconfig mechanism that kubectl does, i.e. proxy-url

CJCShadowsan avatar Aug 08 '23 09:08 CJCShadowsan

Not sure what the status of this issue is. But socks5:// seems to work indeed. Only socks5h:// isn't. The h means sending dns requests also via the socks5 proxy.

BlackDex avatar Feb 08 '24 08:02 BlackDex

Hello,

I'll try to work on this one. I looked at the code and so far I can make k9s to interact with a basic http proxy I hardcoded.

placintaalexandru avatar Apr 19 '24 19:04 placintaalexandru