vscode-openshift-tools icon indicating copy to clipboard operation
vscode-openshift-tools copied to clipboard

Support proxy-url from `~/.kube/config`

Open flybyray opened this issue 3 years ago • 12 comments

Environment VS Code version: 1.68.1 OS: win32 Extension version: 0.4.0 Description

I have setup proxy-url in ~/.kube/config.

apiVersion: v1
clusters:
- cluster:
    proxy-url: socks5://localhost:1080

Usage description: https://kubernetes.io/docs/tasks/extend-kubernetes/socks5-proxy-access-api/#client-configuration

This works as it should with oc from command line.

~ $ oc version
Client Version: 4.10.0-0.okd-2022-06-10-131327
Server Version: 4.8.17
Kubernetes Version: v1.21.1+6438632

But the extension is not using this property.

flybyray avatar Jun 23 '22 12:06 flybyray

@flybyray thank you for reporting this. I tested kubectl, oc and odo in exactly the same environment.

oc and odo does not support proxy-url in ~/.kube/config as you mentioned above, but they do support https_proxy env variable. kubectl supports both ways.

Workaround: set https_proxy env manually and then restart vscode.

Fix: set https_proxy env var when running oc or odo if current context has proxy-url property set.

dgolovin avatar Jun 30 '22 04:06 dgolovin

@dgolovin thx i know such workarround but it is not applicable for all use cases, because in this case even vscode + extensions use it and hence things do not work as expected anymore. with proxy-url the proxy will only be used selective for this specific tool.

flybyray avatar Jul 01 '22 19:07 flybyray

@flybyray thank you for pointing that out. I'm setting higher priority for this issue.

dgolovin avatar Jul 03 '22 04:07 dgolovin

Fixed by #2502

mohitsuman avatar Aug 07 '22 06:08 mohitsuman

@mohitsuman no it it was related to the issue, but not an actual fix.

dgolovin avatar Aug 09 '22 08:08 dgolovin

@flybyray @mohitsuman It cannot be fixed for several reasons. I did my best to workaround what I could, but it didn't work. Here are the problems:

  1. Official @kubernetes/nodejs-client does not aware of proxy-url property for a cluster and when I use it to load configuration the proxy-url property is just ignored and not loaded.
  2. I was developing workaround for it which would just search for this property through the config files, but 'oc' and 'odo' removes it during login command call.

Basically nether official javascript client nor openshift oc/odo cli are supporting this use case.

dgolovin avatar Aug 09 '22 08:08 dgolovin

oc supports it see the description. I tested it.

Hence i understand that this extension will not support it if it is not base on oc.

flybyray avatar Aug 10 '22 14:08 flybyray

@flybyray let me check latest oc version to confirm.

dgolovin avatar Aug 10 '22 17:08 dgolovin

@flybyray this issue #1925534 describes what I see locally.

dgolovin avatar Aug 10 '22 17:08 dgolovin

@flybyray probably I can workaround oc login issue, by getting proxy-url before 'oc login' then adding it back. But any 'oc login' calls outside of vscode will remove proxy-url anyway.

dgolovin avatar Aug 10 '22 17:08 dgolovin

@flybyray this issue #1925534 describes what I see locally.

ok now i understand. than it is only possible to have oc invocation modification to add https_proxy environmentvariable to the process all the time. :-( maybe some path to a wrapper oc

flybyray avatar Aug 10 '22 20:08 flybyray

Related issue in @kubernetes/nodejs-client package https://github.com/kubernetes-client/javascript/issues/853.

dgolovin avatar Aug 15 '22 20:08 dgolovin