> ## 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.

# Runtime Class in Kubernetes

> Guide to creating and using Kubernetes RuntimeClass to run Pods with alternative runtimes like gVisor or Kata Containers, including manifests and verification steps.

This article explains how to instruct Kubernetes Pods to use a specific container runtime implementation (for example, gVisor or Kata Containers) by creating and referencing a RuntimeClass.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/WWXuSSf_CvRt0mlY/images/Certified-Kubernetes-Security-Specialist-CKS/Minimize-Microservice-Vulnerabilities/Runtime-Class-in-Kubernetes/kubernetes-runtime-class-slide-laptop-clock.jpg?fit=max&auto=format&n=WWXuSSf_CvRt0mlY&q=85&s=fec9d8be57a82d19c2e55e456d349f2e" alt="A presentation slide titled &#x22;Runtime Class in Kubernetes&#x22; with a stylized laptop and clock icon on a dark curved background. The left side is mostly white with the title text, while the right side features the dark blue graphic and icon." width="1920" height="1080" data-path="images/Certified-Kubernetes-Security-Specialist-CKS/Minimize-Microservice-Vulnerabilities/Runtime-Class-in-Kubernetes/kubernetes-runtime-class-slide-laptop-clock.jpg" />
</Frame>

Prerequisites

* A Kubernetes cluster with nodes that have the alternative runtime installed (for example, gVisor's `runsc` or Kata Containers' `kata`).
* The node's container runtime (e.g., `containerd`) must be configured to expose the runtime handler name that you will reference in the RuntimeClass.

What is a RuntimeClass?

* RuntimeClass is a cluster-scoped object that allows you to select the container runtime configuration used to run a Pod.
* It lets you target Pods to a specific runtime handler available on nodes (for example `runsc` for gVisor).

Key RuntimeClass fields

| Field | Description | Example |
| - | - | - |
| `metadata.name` | The name you reference from Pod specs (arbitrary, cluster-scoped) | `gvisor` |
| `handler` | The runtime implementation name that must match a runtime configured on the node | `runsc` |

<Callout icon="lightbulb" color="#1CB2FE">
  Ensure the runtime (for example, [gVisor](https://gvisor.dev/) / `runsc`) is installed and configured on every node that may run Pods referring to this RuntimeClass. The `handler` value must match the runtime name configured in the node's container runtime (for example, [containerd](https://containerd.io/)).
</Callout>

Example manifests
Below are two manifests you can apply: one for the RuntimeClass itself, and one for a Pod that requests that RuntimeClass.

RuntimeClass manifest (save as e.g. `gvisor-runtimeclass.yaml`):

```yaml theme={null}
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  name: gvisor
handler: runsc
```

Pod manifest that uses the RuntimeClass (save as e.g. `gvisor-nginx.yaml`):

```yaml theme={null}
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    run: nginx
spec:
  runtimeClassName: gvisor
  containers:
  - name: nginx
    image: nginx
```

Apply the manifests with kubectl

```bash theme={null}
$ kubectl create -f gvisor-runtimeclass.yaml
runtimeclass.node.k8s.io/gvisor created

$ kubectl create -f gvisor-nginx.yaml
pod/nginx created
```

Verify the RuntimeClass and Pod

* List available RuntimeClasses:

```bash theme={null}
kubectl get runtimeclass
```

* Inspect the Pod spec to confirm it references `runtimeClassName: gvisor`:

```bash theme={null}
kubectl get pod nginx -o yaml
```

Behavior on the node
When a Pod uses a runtime handler such as `runsc` (gVisor), the container process runs inside the runtime's sandbox. Because gVisor provides a user-space kernel boundary, the containerized process is isolated from the node kernel and does not appear as a normal host process.

Example on the node:

```bash theme={null}
$ node01:~# pgrep -a nginx
$ node01:~# pgrep -a runsc
27259 runsc --root=/run/containerd/runsc/k8s.io --log=/run/containerd/io.containerd.runtime.v2.task/k8s.io/<id>/log.json --log-format=json
```

This shows the container is sandboxed (the container runtime process such as `runsc` is visible, while the container's internal process is not shown to the host kernel).

Links and references

* [gVisor — documentation](https://gvisor.dev/)
* [gVisor runsc — user guide](https://gvisor.dev/docs/user_guide/runsc/)
* [Kata Containers](https://katacontainers.io/)
* [containerd](https://containerd.io/)
* [Kubernetes RuntimeClass API](https://kubernetes.io/docs/concepts/containers/runtime-class/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/certified-kubernetes-security-specialist-cks/module/7431dd03-f5c2-4ebb-b94a-2d35615bbd8c/lesson/545940f3-49bd-4810-95f3-227913e329c1" />

  <Card title="Practice Lab" icon="flask-conical" cta="Learn more" href="https://learn.kodekloud.com/user/courses/certified-kubernetes-security-specialist-cks/module/7431dd03-f5c2-4ebb-b94a-2d35615bbd8c/lesson/00d9d823-77cb-43cb-9229-ad9faea41282" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.