<p>I am using go-client for kubernetes to control deployments on my GKE cluster, but this client is to be run behind a proxy and needs to make all it's internet bound requests through this. But I cannot seem to find a way to configure my KubeClient to make all http requests through a proxy. </p>

<p>My code is not very different from the sample here - <a href="https://github.com/kubernetes/client-go/blob/master/examples/out-of-cluster-client-configuration/main.go" rel="nofollow noreferrer">https://github.com/kubernetes/client-go/blob/master/examples/out-of-cluster-client-configuration/main.go</a></p>

harpratap
<p>When you are setting up the new client with the config (<code>kubernetes.NewForConfig(config)</code>) you can customize your transport:</p>

<pre><code>proxyURL := url.URL{Host: proxy}
transport := http.Transport{Proxy: http.ProxyURL(&amp;proxyURL), ....}
config.Transport = config.Transport
</code></pre>

<p>Or you can make use of config.WrapTransport: </p>

<ul>
<li>Transport http.RoundTripper</li>
</ul>

<blockquote>
  <p>Transport may be used for custom HTTP behavior. This attribute may not
       be specified with the TLS client certificate options. Use WrapTransport
       for most client level operations.</p>
</blockquote>

<ul>
<li>WrapTransport func(rt http.RoundTripper) http.RoundTripper  </li>
</ul>

<blockquote>
  <p>WrapTransport will be invoked for custom HTTP behavior after the underlying
       transport is initialized (either the transport created from TLSClientConfig,
       Transport, or http.DefaultTransport). The config may layer other RoundTrippers
       on top of the returned RoundTripper.</p>
</blockquote>

<hr>

<p>Sadly it is not straightforward to make it work, and making use of <code>HTTP_PROXY</code> and <code>no_proxy</code> often is easier. </p>
