ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.85k stars 1.27k forks source link

kubens + http_proxy env #292

Closed kassner closed 3 years ago

kassner commented 3 years ago

Looks like 0.9.3 lost the ability to use the http_proxy environment variable to connect to the cluster.

Up to 0.9.2 I am able to just use:

$ echo $http_proxy
http://localhost:8888
$ kubens
default
www

On 0.9.3:

$ echo $http_proxy
http://localhost:8888
$ kubens
error: could not list namespaces (is the cluster accessible?): failed to list namespaces from k8s API: Get "https://<ip>/api/v1/namespaces?limit=500": dial tcp <ip>:443: i/o timeout

<ip> in this particular context is a GKE instance that only allows connections via a bastion. I have tinyproxy running in the bastion. localhost:8888 is provided by a SSH tunnel (ssh -f -L 8888:127.0.0.1:8888 -N my-bastion).

ahmetb commented 3 years ago

Is this the Go-based implementation or bash-based implementation of kubens? There are no code changes between the two versions mentioned https://github.com/ahmetb/kubectx/compare/v0.9.2...v0.9.3.

kassner commented 3 years ago

Golang, from the releases page: https://github.com/ahmetb/kubectx/releases/download/v0.9.3/kubens_v0.9.3_linux_x86_64.tar.gz

ahmetb commented 3 years ago

And you’re certain the same binary w/ 0.9.2 does not reproduce? If so, I have no reasonable explanation.

kassner commented 3 years ago

If you want to compare the checksums:

$ sha256sum kubens*
f479cb7c46e5e1844e57920ecc96489e1c2785c2e89e14abd8e6699b4323c0e4  kubens-0.9.2
58b9a3c4707ff39d7bed4c28afeeb1b1007bf9255c80ba6711bd3a515344baf9  kubens-0.9.3
$ ./kubens-0.9.2 
default
www
$ ./kubens-0.9.3 
error: could not list namespaces (is the cluster accessible?): failed to list namespaces from k8s API: Get "https://<ip>/api/v1/namespaces?limit=500": dial tcp <ip>:443: i/o timeout

The only other difference is that the 0.9.3 binary is 1172KB smaller, but I have no idea if that should mean something.

ahmetb commented 3 years ago

Ok here’s from Go1.16 release notes:

The ProxyFromEnvironment function no longer returns the setting of the HTTP_PROXY environment variable for https:// URLs when HTTPS_PROXY is unset.

so you need to use HTTPS_PROXY from now on.

kassner commented 3 years ago

Yeah, that was it:

$ HTTPS_PROXY=$http_proxy ./kubens-0.9.3 
default
www

Awesome. Thank you @ahmetb!