docs/historical/cri/proposal.md
Author: Lantao Liu (@random-liu)
This proposal aims to integrate containerd with Kubelet against the container runtime interface (CRI).
Containerd is a core container runtime, which provides the minimum set of functionalities to manage the complete container lifecycle of its host system, including container execution and supervision, image distribution and storage, etc.
Containerd was introduced in Docker 1.11, used to manage runC containers on the node. As shown below, it creates a containerd-shim for each container, and the shim manages the lifecycle of its corresponding container.
In Dec. 2016, Docker Inc. spun it out into a standalone component, and donated it to CNCF in Mar. 2017.
Containerd is one potential alternative to Docker as the runtime for Kubernetes clusters. Compared with Docker, containerd has pros and cons.
The following sections discuss the design aspects of the containerd CRI integration. For the purposes of this doc, the containerd CRI integration will be referred to as CRI-containerd.
CRI-containerd relies on containerd to manage container lifecycle.
Ideally, CRI-containerd only needs to do api translation and information reorganization. However, CRI-containerd needs to maintain some metadata because:
PodSandboxID of a container, FinishedAt timestamp, ExitCode, Mounts etc.CRI-containerd should checkpoint these metadata itself or use containerd metadata service if available.
Containerd doesn't provide persistent container log. It redirects container STDIO into different FIFOs.
CRI-containerd should start a goroutine (process/container in the future) to:
Containerd supports creating a process in the container with Exec, and the STDIO is also exposed as FIFOs. Containerd also supports resizing console of a specific process with Pty.
CRI-containerd could reuse the streaming server, it should implement the streaming runtime interface.
For different CRI streaming functions:
ExecSync: CRI-containerd should use Exec to create the exec process, collect the stdout/stderr of the process, and wait for the process to terminate.Exec: CRI-containerd should use Exec to create the exec process, create a goroutine (process/container) to redirect streams, and wait for the process to terminate.Attach: CRI-containerd should create a goroutine (process/container) to read the existing container log to the output, redirect streams of the init process, and wait for any stream to be closed.PortForward: CRI-containerd could implement this with socat and nsenter, similar with current Docker portforward implementation.Containerd doesn't provide container networking, but OCI runtime spec supports joining a linux container into an existing network namespace.
CRI-containerd should:
Containerd provides container cgroup metrics, and plans to provide container writable layer disk usage.
CRI container metrics api needs to be defined (#27097). After that, CRI-containerd should translate containerd container metrics into CRI container metrics.
CRI-containerd relies on containerd to manage images. Containerd should provide all function and information required by CRI, and CRI-containerd only needs to do api translation and information reorganization.
Containerd plans to provide image filesystem metrics.
CRI image filesystem metrics needs to be defined (#33048). After that, we should make sure containerd provides the required metrics, and CRI-containerd should translate containerd image filesystem metrics into CRI image filesystem metrics.
Following items are out of the scope of this design, we may address them in future version as enhancement or optimization.
kubectl, cri-tools or containerd CLI.Exec with a separate container sharing the same rootfs and mount namespace with the original container. The advantage is that the Exec container could have it's own sub-cgroup, so that it will not consume the resource of application container and user could specify dedicated resource for it.Test Plan: Each feature added should have unit test and pass its corresponding cri validation test.
| Item | 1/2 Mar. | 2/2 Mar. | 1/2 Apr. | 2/2 Apr. | 1/2 May. | 2/2 May. |
|---|---|---|---|---|---|---|
| Survey | ✓ | |||||
| POC | ✓ | |||||
| Proposal | ✓ | |||||
| Containerd Feature Complete | ✓ | ✓ | ✓ | |||
| Runtime Management Integration | ✓ | ✓ | ✓ | ✓ | ||
| Image Management Integration | ✓ | ✓ | ✓ | |||
| Container Networking Integration | ✓ | ✓ |