-
Hi, what’s the current state of the http proxy support? I found that it was added with this PR #246 And then removed when switchting from reqwest to hyper here 6a8e819 But since there was recently this PR #892, to support lowercase http_proxy & https_proxy environment variables, I guess proxies are somehow supported? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I did a test https://github.com/kube-rs/kube-rs/discussions?discussions_q=proxy and it did not work for me... not sure I am doing something wrong but I also would like someone from the community to give some advice on this |
Beta Was this translation helpful? Give feedback.
-
Apparently, you can get a work around like this:
with dependencies
|
Beta Was this translation helpful? Give feedback.
-
Thanks, if you need support for http proxies, you can use this code async fn get_kube_client(kube_ctx: &str) -> Result<Client>{
let config = Config::from_kubeconfig(&KubeConfigOptions{
context: Some(kube_ctx.to_string()),
..KubeConfigOptions::default()
}).await?;
let client = if let Some(proxy_uri) = &config.proxy_url {
let proxy = {
let proxy = Proxy::new(Intercept::All, proxy_uri.clone());
let mut proxy_connector = ProxyConnector::from_proxy(HttpConnector::new(), proxy)?;
proxy_connector.set_tls(Some(config.native_tls_connector()?));
proxy_connector
};
let service = ServiceBuilder::new()
.layer(config.base_uri_layer())
.service(hyper::Client::builder().build(proxy));
Client::new(service, config.default_namespace)
} else {
Client::try_from(config)?
};
Ok(client)
} with the additional dependencies hyper-proxy = {version="0.9.1", features = ["native-tls"]}
hyper = { version = "0.14.13", features = ["client"] }
tower = "0.4.13" |
Beta Was this translation helpful? Give feedback.
Thanks, if you need support for http proxies, you can use this code