Skip to main content

k8s_cri/
lib.rs

1//! Automatically generated types, clients, and servers from [Kubernetes CRI Protobuf definitions](https://github.com/kubernetes/cri-api/tree/7d8ade91836419c9dd49d059bda1fe4a7dc283f5/pkg/apis/runtime).
2//!
3//! ## Examples
4//!
5//! Connecting over TCP:
6//!
7//! ```no_run
8//! use k8s_cri::v1alpha2::runtime_service_client::RuntimeServiceClient;
9//! use k8s_cri::v1alpha2::ListContainersRequest;
10//! use tokio::main;
11//!
12//! #[tokio::main]
13//! async fn main() {
14//!     let mut client = RuntimeServiceClient::connect("http://[::1]:50051")
15//!         .await
16//!         .expect("Could not create client.");
17//!
18//!     let request = tonic::Request::new(ListContainersRequest { filter: None });
19//!     let response = client
20//!         .list_containers(request)
21//!         .await
22//!         .expect("Request failed.");
23//!     println!("{:?}", response);
24//! }
25//! ```
26//!
27//! Connecting to a Unix domain socket:
28//!
29//! ```no_run
30//! use std::convert::TryFrom;
31//! use tokio::main;
32//!
33//! use k8s_cri::v1alpha2::runtime_service_client::RuntimeServiceClient;
34//! use tokio::net::UnixStream;
35//! use hyper_util::rt::TokioIo;
36//! use tonic::transport::{Channel, Endpoint, Uri};
37//! use tower::service_fn;
38//!
39//! #[tokio::main]
40//! async fn main() {
41//!     let channel = Endpoint::try_from("http://[::]")
42//!         .unwrap()
43//!         .connect_with_connector(service_fn(|_: Uri| async {
44//!             let path = "/run/containerd/containerd.sock";
45//!             Ok::<_, std::io::Error>(TokioIo::new(UnixStream::connect(path).await?))
46//! }))
47//!         .await
48//!         .expect("Could not create client.");
49//!
50//!     let mut client = RuntimeServiceClient::new(channel);
51//! }
52//! ```
53
54#[allow(clippy::doc_lazy_continuation)]
55pub mod v1 {
56    //! API version v1, [original Protocol Buffers file](https://github.com/kubernetes/cri-api/tree/7d8ade91836419c9dd49d059bda1fe4a7dc283f5/pkg/apis/runtime/v1/api.proto).
57    tonic::include_proto!("runtime.v1");
58}
59
60pub mod v1alpha2 {
61    //! API version v1alpha2, [original Protocol Buffers file](https://github.com/kubernetes/cri-api/tree/7d8ade91836419c9dd49d059bda1fe4a7dc283f5/pkg/apis/runtime/v1alpha2/api.proto).
62    tonic::include_proto!("runtime.v1alpha2");
63}