Rust client for Kubernetes API forking ynqa/kubernetes-rust.
This version has more error handling and a Reflector
for easy caching of CRD state. It aims to cater to the more common operator case, but allows you sticking in dependencies like k8s-openapi.
See operator-rs for ideas.
Main ideas, depending on how complicated your need is:
You probably want a reflector? See operator-rs.
Use the exposed APIClient
herein, and write Request functions directly:
rust
pub fn list_all_crd_entries(r: &ApiResource) -> Result<http::Request<Vec<u8>>> {
let urlstr = format!("/apis/{group}/v1/namespaces/{ns}/{resource}?",
group = r.group, resource = r.resource, ns = r.namespace);
let urlstr = url::form_urlencoded::Serializer::new(urlstr).finish();
let mut req = http::Request::get(urlstr);
req.body(vec![]).map_err(Error::from)
}
Then call them with:
rust
let res = client.request::<ResourceList<Resource<T>>>(req)?;
where Resource
+ ResourceList
can be constructed analogously to what's in ./src/api.
You can also look at the documentation for k8s-openapi is generating. The functions that return http::Request
are compatible.
Pull in k8s-openapi and call it from the client herein. Note that not everything is available from k8s-openapi anyway. Watching Crd entries (not the core definitions) was missing in 0.4.0.