Container Runtime and Container Runtime Interface
Before we start with CRI-O, we need talk about the basics. The best place to start will be container runtimes. We already know what containers, Docker, and Kubernetes are. But how does this all work on a low level? The following diagram illustrates a high-level overview of the communications between Kubernetes and containers:
As you can see, it is not just Kubernetes talking to the container directly. There are two additional layers in the diagram. Let's discuss why we actually need them:
- Container Runtime: Each and every container technology, such as Docker, Rkt, or Windows Containers, has its own runtime. In short, Container Runtime is a set of scripts and software tools to run and maintain the work of a container.
- Container Runtime Interface (CRI): As the name implies, CRI is an interface, or a shim layer between Kubernetes and Container Runtime, if you like.
You may ask yourself, Why do I need CRI? Why can't Kubernetes talk directly to Container Runtime?. Imagine that Kubernetes and Container Runtime are a manager and an employee that speak English. No issues here. But imagine that there's a new employee—he's an expert in his field and has been contracted by an organization, so now they have to work with each other. However, this new employee speaks only Russian. Now we have a problem. Now, we need to start adding more and more employees speaking languages other than English. You can see where I'm going. In our case, we have a few solutions to this problem:
- The manager has to learn a new language every time there is a new employee speaking a new language
- An employee has to learn English
- Hire an interpreter for every language that new employees speak
- Hire an interpreter that speaks a universal language
Try to answer this question—what are the most efficient options out of the four that have been listed? I hope it makes sense that option 4 is the most efficient one. For the same reason, CRI and then CRI-O was born. Following the preceding analogy, CRI is option 3 and CRI-O is option 4 in the preceding example.