kube-rs / kube

Rust Kubernetes client and controller runtime
https://kube.rs
Apache License 2.0
3.06k stars 320 forks source link

Proxy Subresource #1161

Open clux opened 1 year ago

clux commented 1 year ago

With #127 nearing completion, there's actually only one special subresource left; proxy (which has its own verb).

Described in kubernetes.io/../proxies it describes a method to connect to services from outside the cluster using the proxy verb. See also a TL;DR stackoverflow answer.

The allowed http methods are the same for Pod, Service and Node. See e.g. Node methods):

e.g. we, at the very least, need some Api methods protected by a Proxy trait and implemented by:

impl Proxy for k8s_openapi::api::core::v1::Pod {}
impl Proxy for k8s_openapi::api::core::v1::Service {}
impl Proxy for k8s_openapi::api::core::v1::Node {}

impl<K> Api<K>
where
    K: DeserializeOwned + Proxy
{
    //todo!("methods from above list")
}

in kube-client.

Prior Art

OpenEBS Mayastor control plane has a forwarding crate using the /proxy verb:

Previous proxy-like work; how to setup kube-client with a custom proxy connector, but that's more for supporting config.proxy_url.

Discussion

Not sure how to approach this in kube. My gut feel is something similar to portforward.rs, but we have also left client proxying up to custom clients (via user-supplied connectors).

There's ultimately no discussion about it currently so putting in an issue to gauge interest (plus i want to stash some tabs). If people have thoughts or ideas about this, comments are welcome.

aryan9600 commented 1 year ago

i was trying to figure out how to tackle this issue and as you said portforward seemed to be the closest thing, so i took a look there. i think we might need to go about this in two ways (note that this is very high level):