Container Runtime Interface (CRI)

What Is Container Runtime Interface (CRI)?

The Container Runtime Interface (CRI) is an API plugin specializing in how a particular component called kubelet interacts with various container runtimes. The CRI feature allows the partitioning of the management activities of Kubernetes nodes from the processes utilized to create and run containers. In this case, many runtimes can be used by Kubernetes without the need to implement changes to kubelet every time. The CRI is only meant to serve the Kubernetes orchestra so it is not an API service that can be used to handle containers on other systems.

How Does Container Runtime Interface (CRI) Work?

When it comes to interacting with a container runtime, the kubelet is the client that incorporates a container runtime’s gRPC API to send requests. In this context, CRI is a set of processes for executing actions, including those related to initializing and launching Pods, containers, and container images. Once Kubernetes schedules a Pod to a certain node, the kubelet calls for processes offered by CRI to make a request to the runtime about preparing a Pod sandbox, as well as launching its containers. After executing all these operations, the runtime communicates back the results to the kubelet so that this latter can keep track of the workload status.

CRI consists of two key services. The first one is the Runtime Service, responsible for performing actions related to the lifecycle of Pods and containers, while the second one is the Image Service that helps to maintain container images. The services and operations are available due to the kubelet configuring endpoints for interacting with the runtime.

Key Characteristics of Container Runtime Interface (CRI)

  • API related to Kubernetes: The Container Runtime Interface provides a description of how kubelet communicates with container runtime on the node.
  • Using the gRPC protocol: The protocol utilizes gRPC API which has been created with the help of Protocol Buffers to transfer operation requests and responses.
  • Runtime Service: The Container Runtime Interface is responsible for creating and removing the Pod sandbox.
  • Image service: The Container Runtime Interface provides different image services such as pulling, listing and removing images.
  • Not bound to a specific runtime: CRI gives Kubernetes the freedom to employ different runtimes which support CRI like containerd and CRI-O.
  • Versioning available: The interface was designed to provide different versions of API whereby Kubernetes can execute the corresponding version of the runtime API.

Benefits of Container Runtime Interface (CRI)

  • Runtime flexibility: Kubernetes supports different container runtime implementations through the same interface.
  • Independent development: Runtime developers can improve their implementations without requiring Kubernetes to integrate each runtime directly.
  • Clear component boundaries: Separates workload management by the kubelet from container execution by the runtime.
  • Consistent node operations: Standardizes how Kubernetes requests container and image operations across supported runtimes.
  • Simplified integration: A runtime that implements the required CRI API integrates with Kubernetes through the defined protocol.

Container Runtime Interface (CRI) in Cloud Computing

The key idea behind the Container Runtime Interface in cloud computing is that Kubernetes clusters in the cloud implemented on worker nodes utilize the CRI to establish a connection between the kubelet and the installed container runtime. The kubelet makes requests for container operations using the CRI, while the container runtime performs operations based on these requests.

CRI is also able to detach the container runtime from the cloud provider’s infrastructure layer. The cloud service provider provides compute nodes to Kubernetes, but at the same time, CRI makes it possible for Kubernetes to communicate with the container runtime on each of the nodes. CRI neither provisions virtual machines nor registers Pods or manages cloud infrastructure.