Function kube_client::discovery::oneshot::pinned_kind

source ยท
pub async fn pinned_kind(
    client: &Client,
    gvk: &GroupVersionKind,
) -> Result<(ApiResource, ApiCapabilities)>
Expand description

Single discovery for a single GVK

This is an optimized function that avoids the unnecessary listing of api groups. It merely requests the api group resources for the specified apigroup, and then resolves the kind.

use kube::{Client, api::{Api, DynamicObject, GroupVersionKind}, discovery, ResourceExt};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::try_default().await?;
    let gvk = GroupVersionKind::gvk("apiregistration.k8s.io", "v1", "APIService");
    let (ar, caps) = discovery::pinned_kind(&client, &gvk).await?;
    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(())
}