Setting Runtime Classes

Create a kata-runtime runtime class to run Kata Containers in a Kubernetes cluster.

CRI-O uses the Kubernetes RuntimeClass resource in the pod configuration file to specify whether to run a pod using the default runtime runc, or using kata-runtime.

The examples in this book use the name native to specify the use of runc, and the name kata-containers to specify the use of the Kata Containers runtime, but the names aren't important.

  1. Create a runtime class file for Kata Containers.

    Create a file for a runtime class for Kata Containers named kata-runtime.yaml with the following contents:

    kind: RuntimeClass
    apiVersion: node.k8s.io/v1
    metadata:
        name: kata-containers
    handler: kata
  2. Load the runtime class file.

    Load the runtime class to the Kubernetes deployment:

    kubectl apply -f kata-runtime.yaml

    The runtime class kata-containers can now be used in pod configuration files to specify that a container is to be run as a Kata Container, using the kata-containers runtime. For examples of creating pods using this runtime class, see Creating Kata Containers.

  3. (Optional) Create a runtime class file for runc.

    Use the same approach to specify a runtime for runc. This is an optional configuration step. As runc is the default runtime, pods automatically run using runc unless you specify otherwise. This file is named runc-runtime.yaml:

    kind: RuntimeClass
    apiVersion: node.k8s.io/v1
    metadata:
        name: native
    handler: runc 
  4. (Optional) Load the runtime class file.

    Load the runtime class to the Kubernetes deployment:

    kubectl apply -f runc-runtime.yaml

    The runtime class native can be used in pod configuration files to specify that a container runs as a runC container, using the runc runtime.

  5. List the runtime classes.

    You can see a list of the available runtime classes for a Kubernetes cluster using the kubectl get runtimeclass command:

    kubectl get runtimeclass

    The output looks similar to:

    NAME              HANDLER   AGE
    kata-containers   kata      7m29s
    native            runc      7m7s