1.3 Setting Runtime Classes

You can create Kubernetes runtime classes to specify whether containers should be run as 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 kata-runtime. You can use any name you like.

To create a runtime class:

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

    kind: RuntimeClass
    apiVersion: node.k8s.io/v1beta1
    metadata:
        name: kata-containers
    handler: kata

    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 a container should be run as a Kata container, using the kata-containers runtime. For examples of creating pods using this runtime class, see Section 3.3, “Creating Kata Containers”.

  2. (Optional) If you want to specify a runtime for runc, you can do this in a similar way. 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/v1beta1
    metadata:
        name: native
    handler: runc 

    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 a container should be run as a runC container, using the runc runtime.

  3. You can see a list of the available runtime classes for a Kubernetes cluster using the kubectl get runtimeclass. For example:

    $ kubectl get runtimeclass
    NAME              CREATED AT
    kata-containers   2019-09-11T06:48:12Z
    native            2019-09-11T07:08:56Z