#client #kubernetes #k8s #cri

k8s-cri

Bindings Kubernetes CRI

5 unstable releases

0.3.0 Feb 10, 2021
0.2.0 Jul 3, 2020
0.1.2 May 6, 2020
0.1.1 May 6, 2020
0.1.0 May 6, 2020

#25 in #k8s

Download history 29/week @ 2021-04-11 35/week @ 2021-04-18 31/week @ 2021-04-25 26/week @ 2021-05-02 22/week @ 2021-05-09 32/week @ 2021-05-16 65/week @ 2021-05-23 25/week @ 2021-05-30 46/week @ 2021-06-06 34/week @ 2021-06-13 29/week @ 2021-06-20 2/week @ 2021-06-27 45/week @ 2021-07-04 9/week @ 2021-07-11 9/week @ 2021-07-18 19/week @ 2021-07-25

274 downloads per month

Apache-2.0

30KB

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

~14MB
~311K SLoC