-
-
Notifications
You must be signed in to change notification settings - Fork 362
Open
Labels
apiApi abstraction relatedApi abstraction relatedclient-goldgold client requirementsgold client requirementshelp wantedNot immediately prioritised, please help!Not immediately prioritised, please help!
Description
Subresources have a lot of special case logic, that is not easily derivable from k8s_openapi
. So far we have implemented (see subresources.rs):
- pods/eviction (impl in add eviction subresource - for #127 #393)
- pods/log (already implemented, used as example herein)
- pods/attach (hard - impl in Add WebSocket connection support and implement
/attach
and/exec
#360) - pods/portforward (hard How should we implement WebSocket connection? #229, sketch in Add port forward #446)
- pods/exec (hard How should we implement WebSocket connection? #229 - impl in Add WebSocket connection support and implement
/attach
and/exec
#360) - {service,node,pod}/proxy - see Proxy Subresource #1161
- pods/binding (see https://docs.rs/k8s-openapi/latest/src/k8s_openapi/v1_26/api/core/v1/binding.rs.html#79-100 )
- ephemeral containers - Implement ephemeral containers subresource #1153
- certificatesigningrequest/approval (easy - follow from Request: support arbitrary subresources #487 and see docs) - Add Api fns for arbitrary subresources and approval subresource for CertificateSigningRequest #773
- TokenRequest - for client util (same as csr approach, easy) - done in Add
create_subresource
method toApi
andcreate_token_request
method toApi<ServiceAccount>
#989 - arbitrary subresources - probably port
Request
work from Request: support arbitrary subresources #487 (comment) to API - Add Api fns for arbitrary subresources and approval subresource for CertificateSigningRequest #773
The general outline for the http based subresources:
We need a definition of what they are in subresources. The way to upgrade would be:
- Implement subresource queries straight on
Resource
without restrictions (for now):
impl Resource {
/// Get a pod logs
pub fn log(&self, name: &str, lp: &LogParams) -> Result<http::Request<Vec<u8>>> {
...
// Check https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/ for urls
}
}
- Make a marker trait for the subresource:
pub trait Loggable {}
impl<K> Api<K>
where
K: Clone + DeserializeOwned + Meta + Loggable,
{
pub async fn log(&self, name: &str, lp: &LogParams) -> Result<String> {
let req = self.api.log(name, lp)?;
Ok(self.client.request_text(req).await?)
}
pub async fn log_stream(&self, name: &str, lp: &LogParams) -> Result<impl Stream<Item = Result<Bytes>>> {
let req = self.api.log(name, lp)?;
Ok(self.client.request_text_stream(req).await?)
}
}
- Designate what resources implement this subresource:
impl Loggable for k8s_openapi::api::core::v1::Pod {}
Write one test case for one resource in examples (e.g. examples/log_openapi.rs).
EDIT (0.46.0):
Now this is not as difficult for the specialized requests requiring websockets (ws
feature).
This was discussed at length in #229, and finally implemented in #360.
Implementors of the last subresources ought to look at that PR for help.
praveenperera and ZhiHanZ
Metadata
Metadata
Assignees
Labels
apiApi abstraction relatedApi abstraction relatedclient-goldgold client requirementsgold client requirementshelp wantedNot immediately prioritised, please help!Not immediately prioritised, please help!
Type
Projects
Status
Backlog