Expand description
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);
}
Modules§
- API version v1, original Protocol Buffers file.
- API version v1alpha2, original Protocol Buffers file.