⎈ k8s knowledge compiler

Runtime Class [page]deterministic

concepts

This page describes the RuntimeClass resource and runtime selection mechanism.

RuntimeClass is a feature for selecting the container runtime configuration. The container runtime configuration is used to run a Pod's containers.

## Motivation

You can set a different RuntimeClass between different Pods to provide a balance of performance versus security. For example, if part of your workload deserves a high level of information security assurance, you might choose to schedule those Pods so that they run in a container runtime that uses hardware virtualization. You'd then benefit from the extra isolation of the alternative runtime, at the expense of some additional overhead.

You can also use RuntimeClass to run different Pods with the same container runtime but with different settings.

## Setup

1. Configure the CRI implementation on nodes (runtime dependent) 2. Create the corresponding RuntimeClass resources

### 1. Configure the CRI implementation on nodes

The configurations available through RuntimeClass are Container Runtime Interface (CRI) implementation dependent. See the corresponding documentation ([below](#cri-configuration)) for your CRI implementation for how to configure.

> Note: RuntimeClass assumes a homogeneous node configuration across the cluster by default (which means that all nodes are configured the same way with respect to container runtimes). To support heterogeneous node configurations, see [Scheduling](#scheduling) below.

The configurations have a corresponding `handler` name, referenced by the RuntimeClass. The handler must be a valid [DNS label name](/docs/concepts/overview/working-with-objects/names/#dns-label-names).

### 2. Create the corresponding RuntimeClass resources

The configurations setup in step 1 should each have an associated `handler` name, which identifies the configuration. For each handler, create a corresponding RuntimeClass object.

The RuntimeClass resource currently only has 2 significant fields: the RuntimeClass name (`metadata.name`) and the handler (`handler`). The object definition looks like this:

```yaml # RuntimeClass is defined in the node.k8s.io API group apiVersion: node.k8s.io/v1 kind: RuntimeClass metadata: # The name the RuntimeClass will be referenced by. # RuntimeClass is a non-namespaced resource. name: myclass # The name of the corresponding CRI configuration handler: myconfiguration ```

The name of a RuntimeClass object must be a valid [DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).

> Note: It is recommended that RuntimeClass write operations (create/update/patch/delete) be restricted to the cluster administrator. This is typically the default. See [Authorization Overview](/docs/reference/access-authn-authz/authorization/) for more details.

## Usage

Once RuntimeClasses are configured for the cluster, you can specify a `runtimeClassName` in the Pod spec to use it. For example:

```yaml apiVersion: v1 kind: Pod metadata: name: mypod spec: runtimeClassName: myclass # ... ```

This will instruct the kubelet to use the named RuntimeClass to run this pod. If the named RuntimeClass does not exist, or the CRI cannot run the corresponding handler, the pod will enter the `Failed` terminal [phase](/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase). Look for a corresponding [event](/docs/tasks/debug/debug-application/debug-running-pod/) for an error message.

If no `runtimeClassName` is specified, the default RuntimeHandler will be used, which is equivalent to the behavior when the RuntimeClass feature is disabled.

### CRI Configuration

For more details on setting up CRI runtimes, see [CRI installation](/docs/setup/production-environment/container-runtimes/).

#### [containerd](#gloss:containerd)

Runtime handlers are configured through containerd's configuration at `/etc/containerd/config.toml`. Valid handlers are configured under the runtimes section:

``` [plugins."io.container …(trimmed)

Sources

concepts/containers/runtime-class.md · docRuntime Class

Related (12)

references containerdcontainerd conf=1
references CRI-Ocri-o conf=1
part_of Motivationdescribes conf=1
part_of Setupdescribes conf=1
part_of Usagedescribes conf=1
part_of Schedulingdescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
part_of CRI Configurationdescribes conf=1
part_of Pod overheaddescribes conf=1
api_for Timedocuments API object conf=1

← all Docs