kubex

Crates.iokubex
lib.rskubex
version0.2.0
created_at2025-09-17 00:30:25.578201+00
updated_at2025-09-17 03:28:14.693197+00
descriptionUtilities for Kubernetes
homepage
repositoryhttps://github.com/ynqa/kubex
max_upload_size
id1842608
size65,668
(ynqa)

documentation

README

kubex

Overview

kubex is a Rust library that provides utilities for Kubernetes. It complements kube and k8s-openapi crates, making it easier to detect contexts and explore API resources.

Installation

Add the following dependency to your Cargo.toml.

[dependencies]
kubex = "0.1.0"

Example

An example that combines DiscoverClient with the helper functions for namespaces and kube contexts.

cargo run --example main
use kubex::{determine_context, determine_namespace, discover::DiscoverClient};
use kube::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let context = determine_context(&None)?;
    println!("context={context}");
    let namespace = determine_namespace(None, &context);
    println!("namespace={namespace}");

    let client = Client::try_default().await?;
    let discover = DiscoverClient::new(client);
    let resources = discover.list_api_resources().await?;

    for resource in resources {
        println!("{} {}", resource.group.as_deref().unwrap_or("").trim(), resource.name);
    }

    Ok(())
}

License

This project is released under the MIT License.

Commit count: 8

cargo fmt