10 releases (breaking)

new 0.8.0 May 14, 2024
0.7.0 May 19, 2023
0.6.0 Oct 31, 2022
0.5.0 Aug 8, 2022
0.1.2 May 6, 2020

#878 in Development tools

Download history 232/week @ 2024-01-25 259/week @ 2024-02-01 404/week @ 2024-02-08 442/week @ 2024-02-15 552/week @ 2024-02-22 341/week @ 2024-02-29 297/week @ 2024-03-07 397/week @ 2024-03-14 243/week @ 2024-03-21 440/week @ 2024-03-28 450/week @ 2024-04-04 782/week @ 2024-04-11 636/week @ 2024-04-18 600/week @ 2024-04-25 638/week @ 2024-05-02 602/week @ 2024-05-09

2,711 downloads per month

Apache-2.0

37KB

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 tonic::transport::{Channel, Endpoint, Uri};
use tower::service_fn;

#[tokio::main]
async fn main() {
    let path = "/run/containerd/containerd.sock";
    let channel = Endpoint::try_from("http://[::]")
        .unwrap()
        .connect_with_connector(service_fn(move |_: Uri| UnixStream::connect(path)))
        .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

~4.5–8MB
~130K SLoC