In this lesson, we demonstrate how to configure a specific runtime for Kubernetes pods. Previously, we introduced gVisor—which leverages the runsc runtime to create containers. In this guide, we assume that gVisor is already installed on your Kubernetes nodes, and we will now explicitly configure pods to use this runtime.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Create a RuntimeClass
To use gVisor with Kubernetes, you need to create a RuntimeClass object. This object contains two important fields:- Name: An identifier for the RuntimeClass (in this example, “gvisor”).
- Handler: Specifies the runtime to use (for gVisor, this is
runsc).
gvisor.yaml), and then create the RuntimeClass by running:
You can assign any name you prefer to the RuntimeClass, but the
handler must always be a valid runtime (e.g., runsc for gVisor or kata for Kata Containers).Deploying a Pod with the gVisor Runtime
Next, create a pod that uses the gVisor runtime. The pod definition below launches an Nginx container with the specified runtime by including theruntimeClassName field in the pod spec:
Verifying the Configuration
To ensure that the Nginx container is isolated from the host Linux kernel:-
Check for the Nginx process on the node by running:
If the command returns no results, it indicates that gVisor is effectively sandboxing the container.
-
You may also notice a
runscruntime process running on the node, confirming that the container is using the specified runtime.
Proceed to the Hands-on Labs to practice working with container runtimes and further enhance your Kubernetes skills.
