Kubernetes Blog
Follow
Container Runtime Interface streaming explained
The Kubernetes Container Runtime Interface (CRI) defines a protocol for communication between the kubelet and container runtimes.The CRI includes three notable Remote Procedure Calls (RPCs): Exec, Attach, and PortForward.These RPCs allow for command execution, terminal attachment, and port forwarding to containers, respectively.Uniquely, these RPCs return URLs to streaming servers instead of traditional server responses.This design allows runtimes flexibility in implementing these features and avoids bottlenecks in the kubelet.Exec and Attach follow a similar streaming protocol, while PortForward uses a different internal protocol.Runtimes implement the streaming server methods using the kubelet library, which provides protocol interpretation and runtime-specific logic.PortForwarding requires entering the container's network namespace and allocating ports.Kubernetes is transitioning to WebSockets for these RPCs, requiring updates from runtimes and clients.CRI-O is exploring experimental implementations using Rust for direct WebSocket streaming.These RPCs provide significant flexibility and innovation in container management, enabling advanced interactions with workloads.