13 releases (breaking)

Uses new Rust 2024

0.11.0 Feb 20, 2026
0.10.0 Jan 11, 2025
0.9.0 Oct 4, 2024
0.8.0 May 14, 2024
0.2.0 Jul 3, 2020

#1967 in Network programming

Download history 4576/week @ 2025-12-28 6920/week @ 2026-01-04 7620/week @ 2026-01-11 8521/week @ 2026-01-18 7806/week @ 2026-01-25 8112/week @ 2026-02-01 9060/week @ 2026-02-08 6984/week @ 2026-02-15 11011/week @ 2026-02-22 8779/week @ 2026-03-01 10449/week @ 2026-03-08 9398/week @ 2026-03-15 8843/week @ 2026-03-22 8451/week @ 2026-03-29 9690/week @ 2026-04-05 13149/week @ 2026-04-12

40,507 downloads per month

Apache-2.0

49KB

k8s-cri

Automatically generated Rust types, clients, and servers from Kubernetes CRI Protobuf spec using tonic.

API Documentation


lib.rs:

Automatically generated types, clients, and servers from Kubernetes CRI Protobuf definitions.

Examples

Connecting over TCP:

use k8s_cri::v1alpha2::runtime_service_client::RuntimeServiceClient;
use k8s_cri::v1alpha2::ListContainersRequest;
use tokio::main;

#[tokio::main]
async fn main() {
    let mut client = RuntimeServiceClient::connect("http://[::1]:50051")
        .await
        .expect("Could not create client.");

    let request = tonic::Request::new(ListContainersRequest { filter: None });
    let response = client
        .list_containers(request)
        .await
        .expect("Request failed.");
    println!("{:?}", response);
}

Connecting to a Unix domain socket:

use std::convert::TryFrom;
use tokio::main;

use k8s_cri::v1alpha2::runtime_service_client::RuntimeServiceClient;
use tokio::net::UnixStream;
use hyper_util::rt::TokioIo;
use tonic::transport::{Channel, Endpoint, Uri};
use tower::service_fn;

#[tokio::main]
async fn main() {
    let channel = Endpoint::try_from("http://[::]")
        .unwrap()
        .connect_with_connector(service_fn(|_: Uri| async {
            let path = "/run/containerd/containerd.sock";
            Ok::<_, std::io::Error>(TokioIo::new(UnixStream::connect(path).await?))
}))
        .await
        .expect("Could not create client.");

    let mut client = RuntimeServiceClient::new(channel);
}

API version v1, original Protocol Buffers file. API version v1alpha2, original Protocol Buffers file.

Dependencies

~8–13MB
~157K SLoC