rust-extensions/crates/runc-shim
Tianyang Zhang 7817d7ef7b runc-shim: open read side of stdout/stderr fifo to avoid EPIPE
The "read" side of container stdout/stderr fifo has been opened
by containerd and on the other hand "write" side is opened by
container process, which is a little different with golang shim.
If containerd shutdown and closed the read fd, container process
will receive EPIPE when writing to stdout/stderr and then be
killed by SIGPIPE signal. In this commit, the "read" side is
opened again by shim so that at least there is one opened "read"
side all the time.

Signed-off-by: Tianyang Zhang <burning9699@gmail.com>
2023-07-21 17:12:16 +08:00
..
src runc-shim: open read side of stdout/stderr fifo to avoid EPIPE 2023-07-21 17:12:16 +08:00
Cargo.toml Move console to runc-shim 2023-03-16 11:16:24 -07:00
README.md runc-shim: Update README with performance test 2022-10-16 16:41:01 +08:00

README.md

Rust containerd shim v2 for runc container

Crates.io docs.rs Crates.io CI

By default containerd relies on runc shim v2 runtime (written in Go) to launch containers. This crate is an alternative Rust implementation of the shim runtime. It conforms to containerd's integration tests and can be replaced with the original Go runtime interchangeably.

Usage

To build binary, run:

cargo build --release --bin containerd-shim-runc-v2-rs

Replace it to the containerd shim dir: /usr/local/bin/containerd-shim-runc-v2-rs

In order to use it from containerd, use:

$ sudo ctr run --rm --runtime io.containerd.runc.v2-rs -t docker.io/library/hello-world:latest hello

You can run a container by ctr, crictl or kubernetes API.

Performance test

Memory overhead

Three different kinds of shim binaries are used to compare memory overhead, first is containerd-shimv2-runc-v2 compiled by golang, next is our sync containerd-shim-runc-v2-rs and the last one is our async containerd-shim-runc-v2-rs but limited to 2 work threads.

We run a busybox container inside a pod on a 16U32G Ubuntu20.04 mechine with containerd v1.6.8 and runc v1.1.4. To measure the memory size of shim process we parse the output of smaps file and add up all RSS segments. In addition, we also run 100 pods and collect the total memory overhead.

Single Process RSS 100 Processes RSS
containerd-shim-runc-v2 11.02MB 1106.52MB
containerd-shim-runc-v2-rs(sync) 3.45MB 345.39MB
containerd-shim-runc-v2-rs(async, limited to 2 work threads) 3.90MB 396.83MB