cri-api
本项目基于k8s-cri。 在此基础上,只支持v1规范,并完善examples,以方便用户开发使用。
快速开发
添加依赖
cargo add cri-api
cargo add tokio
cargo add tower
cargo add tonic
书写测试用例
use std::convert::TryFrom;
use tokio::main;
use cri_api::v1::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);
}