Function kube_client::discovery::oneshot::group

source ยท
pub async fn group(client: &Client, apigroup: &str) -> Result<ApiGroup>
Expand description

Discovers all APIs available under a certain group at all versions

This is recommended if you work with one group, but do not want to pin the version of the apigroup. You can instead work with a recommended version (preferred or latest).

use kube::{Client, api::{Api, DynamicObject}, discovery, ResourceExt};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::try_default().await?;
    let apigroup = discovery::group(&client, "apiregistration.k8s.io").await?;
    let (ar, caps) = apigroup.recommended_kind("APIService").unwrap();
    let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
    for service in api.list(&Default::default()).await? {
        println!("Found APIService: {}", service.name_any());
    }
    Ok(())
}