Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 2. Deploying OpenShift sandboxed containers workloads
You can install the OpenShift sandboxed containers Operator using either the web console or OpenShift CLI (oc). Before installing the OpenShift sandboxed containers Operator, you must prepare your Red Hat OpenShift cluster.
2.1. Prerequisites Copier lienLien copié sur presse-papiers!
Before you install OpenShift sandboxed containers, ensure that your Red Hat OpenShift cluster meets the following requirements:
Your cluster must be installed on on-premise bare-metal infrastructure with Red Hat Enterprise Linux CoreOS (RHCOS) workers. You can use any installation method including user-provisioned, installer-provisioned, or assisted installer to deploy your cluster.
Note- OpenShift sandboxed containers only supports RHCOS worker nodes. RHEL nodes are not supported.
- Nested virtualization is not supported.
- You can install OpenShift sandboxed containers on Amazon Web Services (AWS) bare-metal instances. Bare-metal instances offered by other cloud providers are not supported.
2.1.1. Resource requirements for OpenShift sandboxed containers Copier lienLien copié sur presse-papiers!
OpenShift sandboxed containers lets users run workloads on their Red Hat OpenShift clusters inside a sandboxed runtime (Kata). Each pod is represented by a virtual machine (VM). Each VM runs in a QEMU process and hosts a kata-agent process that acts as a supervisor for managing container workloads, and the processes running in those containers. Two additional processes add more overhead:
-
containerd-shim-kata-v2is used to communicate with the pod. -
virtiofsdhandles host file system access on behalf of the guest.
Each VM is configured with a default amount of memory. Additional memory is hot-plugged into the VM for containers that explicitly request memory.
A container running without a memory resource consumes free memory until the total memory used by the VM reaches the default allocation. The guest and its I/O buffers also consume memory.
If a container is given a specific amount of memory, then that memory is hot-plugged into the VM before the container starts.
When a memory limit is specified, the workload is terminated if it consumes more memory than the limit. If no memory limit is specified, the kernel running on the VM might run out of memory. If the kernel runs out of memory, it might terminate other processes on the VM.
Default memory sizes
The following table lists some the default values for resource allocation.
| Resource | Value |
|---|---|
| Memory allocated by default to a virtual machine | 2Gi |
| Guest Linux kernel memory usage at boot | ~110Mi |
| Memory used by the QEMU process (excluding VM memory) | ~30Mi |
|
Memory used by the | ~10Mi |
|
Memory used by the | ~20Mi |
|
File buffer cache data after running | ~300Mi* [1] |
File buffers appear and are accounted for in multiple locations:
- In the guest where it appears as file buffer cache.
-
In the
virtiofsddaemon that maps allowed user-space file I/O operations. - In the QEMU process as guest memory.
Total memory usage is properly accounted for by the memory utilization metrics, which only count that memory once.
Pod overhead describes the amount of system resources that a pod on a node uses. You can get the current pod overhead for the Kata runtime by using oc describe runtimeclass kata as shown below.
Example
oc describe runtimeclass kata
$ oc describe runtimeclass kata
Example output
You can change the pod overhead by changing the spec.overhead field for a RuntimeClass. For example, if the configuration that you run for your containers consumes more than 350Mi of memory for the QEMU process and guest kernel data, you can alter the RuntimeClass overhead to suit your needs.
The specified default overhead values are supported by Red Hat. Changing default overhead values is not supported and can result in technical issues.
When performing any kind of file system I/O in the guest, file buffers are allocated in the guest kernel. The file buffers are also mapped in the QEMU process on the host, as well as in the virtiofsd process.
For example, if you use 300Mi of file buffer cache in the guest, both QEMU and virtiofsd appear to use 300Mi additional memory. However, the same memory is being used in all three cases. In other words, the total memory usage is only 300Mi, mapped in three different places. This is correctly accounted for when reporting the memory utilization metrics.
2.1.2. Checking whether cluster nodes are eligible to run OpenShift sandboxed containers Copier lienLien copié sur presse-papiers!
Before running OpenShift sandboxed containers, you can check whether the nodes in your cluster are eligible to run Kata containers. Some cluster nodes might not comply with sandboxed containers' minimum requirements. The most common reason for node ineligibility is the lack of virtualization support on the node. If you attempt to run sandboxed workloads on ineligible nodes, you will experience errors. You can use the Node Feature Discovery (NFD) Operator and a NodeFeatureDiscovery resource to automatically check node eligibility.
If you want to install the Kata runtime on only selected worker nodes that you know are eligible, apply the feature.node.kubernetes.io/runtime.kata=true label to the selected nodes and set checkNodeEligibility: true in the KataConfig resource.
Alternatively, to install the Kata runtime on all worker nodes, set checkNodeEligibility: false in the KataConfig resource.
In both these scenarios, you do not need to create the NodeFeatureDiscovery resource. You should only apply the feature.node.kubernetes.io/runtime.kata=true label manually if you are sure that the node is eligible to run Kata containers.
The following procedure applies the feature.node.kubernetes.io/runtime.kata=true label to all eligible nodes and configures the KataConfig resource to check for node eligibility.
Prerequisites
-
Install the OpenShift CLI (
oc). -
Log in as a user with
cluster-adminprivileges. - Install the Node Feature Discovery (NFD) Operator.
Procedure
Create a
NodeFeatureDiscoveryresource to detect node capabilities suitable for running Kata containers:Save the following YAML in the
nfd.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
NodeFeatureDiscoverycustom resource (CR):oc create -f nfd.yaml
$ oc create -f nfd.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
nodefeaturediscovery.nfd.openshift.io/nfd-kata created
nodefeaturediscovery.nfd.openshift.io/nfd-kata createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow A
feature.node.kubernetes.io/runtime.kata=truelabel is applied to all qualifying worker nodes.
Set the
checkNodeEligibilityfield totruein theKataConfigresource to enable the feature, for example:Save the following YAML in the
kata-config.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
KataConfigCR:oc create -f kata-config.yaml
$ oc create -f kata-config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
kataconfig.kataconfiguration.openshift.io/example-kataconfig created
kataconfig.kataconfiguration.openshift.io/example-kataconfig createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that qualifying nodes in the cluster have the correct label applied:
oc get nodes --selector='feature.node.kubernetes.io/runtime.kata=true'
$ oc get nodes --selector='feature.node.kubernetes.io/runtime.kata=true'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME STATUS ROLES AGE VERSION compute-3.example.com Ready worker 4h38m v1.25.0 compute-2.example.com Ready worker 4h35m v1.25.0
NAME STATUS ROLES AGE VERSION compute-3.example.com Ready worker 4h38m v1.25.0 compute-2.example.com Ready worker 4h35m v1.25.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Deploying OpenShift sandboxed containers workloads using the web console Copier lienLien copié sur presse-papiers!
You can deploy OpenShift sandboxed containers workloads from the web console. First, you must install the OpenShift sandboxed containers Operator, then create the KataConfig custom resource (CR). Once you are ready to deploy a workload in a sandboxed container, you must manually add kata as the runtimeClassName to the workload YAML file.
2.2.1. Installing the OpenShift sandboxed containers Operator using the web console Copier lienLien copié sur presse-papiers!
You can install the OpenShift sandboxed containers Operator from the Red Hat OpenShift web console.
Prerequisites
- You have Red Hat OpenShift 4.13 installed.
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
-
From the Administrator perspective in the web console, navigate to Operators
OperatorHub. -
In the Filter by keyword field, type
OpenShift sandboxed containers. - Select the OpenShift sandboxed containers tile.
- Read the information about the Operator and click Install.
On the Install Operator page:
- Select stable from the list of available Update Channel options.
Verify that Operator recommended Namespace is selected for Installed Namespace. This installs the Operator in the mandatory
openshift-sandboxed-containers-operatornamespace. If this namespace does not yet exist, it is automatically created.NoteAttempting to install the OpenShift sandboxed containers Operator in a namespace other than
openshift-sandboxed-containers-operatorcauses the installation to fail.- Verify that Automatic is selected for Approval Strategy. Automatic is the default value, and enables automatic updates to OpenShift sandboxed containers when a new z-stream release is available.
- Click Install.
The OpenShift sandboxed containers Operator is now installed on your cluster.
Verification
-
From the Administrator perspective in the web console, navigate to Operators
Installed Operators. - Verify that the OpenShift sandboxed containers Operator is listed in the in operators list.
2.2.2. Creating the KataConfig custom resource in the web console Copier lienLien copié sur presse-papiers!
You must create one KataConfig custom resource (CR) to enable installing kata as a RuntimeClass on your cluster nodes.
Creating the KataConfig CR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes. Factors that impede reboot time are as follows:
- A larger Red Hat OpenShift deployment with a greater number of worker nodes.
- Activation of the BIOS and Diagnostics utility.
- Deployment on a hard disk drive rather than an SSD.
- Deployment on physical nodes such as bare metal, rather than on virtual nodes.
- A slow CPU and network.
Prerequisites
- You have installed Red Hat OpenShift 4.13 on your cluster.
-
You have access to the cluster as a user with the
cluster-adminrole. - You have installed the OpenShift sandboxed containers Operator.
Kata is installed on all worker nodes by default. If you want to install kata as a RuntimeClass only on specific nodes, you can add labels to those nodes, then define the label in the KataConfig CR when you create it.
Procedure
-
From the Administrator perspective in the web console, navigate to Operators
Installed Operators. - Select the OpenShift sandboxed containers Operator from the list of operators.
- In the KataConfig tab, click Create KataConfig.
In the Create KataConfig page, enter the following details:
-
Name: Enter a name for the
KataConfigresource. By default, the name is defined asexample-kataconfig. -
Labels (Optional): Enter any relevant, identifying attributes to the
KataConfigresource. Each label represents a key-value pair. -
checkNodeEligibility(Optional, not relevant for peer pods): Select this checkbox to use the Node Feature Discovery Operator (NFD) to detect node eligibility to runkataas aRuntimeClass. For more information, see "Checking whether cluster nodes are eligible to run OpenShift sandboxed containers". -
enablePeerPods(For peer pods): Select this checkbox to enable peer pods and use OpenShift sandboxed containers in a public cloud environment. kataConfigPoolSelector: By default,katais installed as aRuntimeClasson all nodes. If you want to installkataas aRuntimeClassonly on selected nodes, you must add a matchExpression:-
Expand the
kataConfigPoolSelectorarea. -
In the
kataConfigPoolSelector, expand matchExpressions. This is a list of label selector requirements. - Click Add matchExpressions.
- In the key field, add the label key the selector applies to.
-
In the operator field, add the key’s relationship to the label values. Valid operators are
In,NotIn,Exists, andDoesNotExist. - Expand the values area, and then click Add value.
-
In the Value field, enter
trueorfalsefor key label value.
-
Expand the
-
logLevel: Define the level of log data retrieved for nodes runningkataas aRuntimeClass. For more information, see "Collecting OpenShift sandboxed containers data".
-
Name: Enter a name for the
- Click Create.
The new KataConfig CR is created and begins to install kata as a RuntimeClass on the worker nodes. Wait for the kata installation to complete and the worker nodes to reboot before continuing to the next step.
OpenShift sandboxed containers installs kata only as a secondary, optional runtime on the cluster and not as the primary runtime.
Verification
-
In the KataConfig tab, select the new
KataConfigCR. - In the KataConfig page, select the YAML tab.
Monitor the installationStatus field in the status.
A message appears each time there is an update. Click Reload to view the updated
KataConfigCR.Once the value of Completed nodes equals the number of worker or labeled nodes, the installation is complete. The status also contains a list of nodes where the installation is completed.
2.2.3. Deploying a workload in a sandboxed container using the web console Copier lienLien copié sur presse-papiers!
OpenShift sandboxed containers installs Kata as a secondary, optional runtime on your cluster, and not as the primary runtime.
To deploy a pod-templated workload in a sandboxed container, you must manually add kata as the runtimeClassName to the workload YAML file.
Prerequisites
- You have installed Red Hat OpenShift 4.13 on your cluster.
-
You have access to the cluster as a user with the
cluster-adminrole. - You have installed the OpenShift sandboxed containers Operator.
-
You have created a
KataConfigcustom resource (CR).
Procedure
- From the Administrator perspective in the web console, expand Workloads and select the type of workload you want to create.
- In the workload page, click to create the workload.
In the YAML file for the workload, in the spec field where the container is listed, add
runtimeClassName: kata.Example for Pod object
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click Save.
Red Hat OpenShift creates the workload and begins scheduling it.
2.3. Deploying OpenShift sandboxed containers workloads using the CLI Copier lienLien copié sur presse-papiers!
You can deploy OpenShift sandboxed containers workloads using the CLI. First, you must install the OpenShift sandboxed containers Operator, then create the KataConfig custom resource. Once you are ready to deploy a workload in a sandboxed container, you must add kata as the runtimeClassName to the workload YAML file.
2.3.1. Installing the OpenShift sandboxed containers Operator using the CLI Copier lienLien copié sur presse-papiers!
You can install the OpenShift sandboxed containers Operator using the Red Hat OpenShift CLI.
Prerequisites
- You have Red Hat OpenShift 4.13 installed on your cluster.
-
You have installed the OpenShift CLI (
oc). -
You have access to the cluster as a user with the
cluster-adminrole. You have subscribed to the OpenShift sandboxed containers catalog.
NoteSubscribing to the OpenShift sandboxed containers catalog provides
openshift-sandboxed-containers-operatornamespace access to the OpenShift sandboxed containers Operator.
Procedure
Create the
Namespaceobject for the OpenShift sandboxed containers Operator.Create a
Namespaceobject YAML file that contains the following manifest:apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
Namespaceobject:oc create -f Namespace.yaml
$ oc create -f Namespace.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create the
OperatorGroupobject for the OpenShift sandboxed containers Operator.Create an
OperatorGroupobject YAML file that contains the following manifest:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
OperatorGroupobject:oc create -f OperatorGroup.yaml
$ oc create -f OperatorGroup.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create the
Subscriptionobject to subscribe theNamespaceto the OpenShift sandboxed containers Operator.Create a
Subscriptionobject YAML file that contains the following manifest:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
Subscriptionobject:oc create -f Subscription.yaml
$ oc create -f Subscription.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The OpenShift sandboxed containers Operator is now installed on your cluster.
All the object file names listed above are suggestions. You can create the object YAML files using other names.
Verification
Ensure that the Operator is correctly installed:
oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.4.1 1.4.0 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.4.1 1.4.0 SucceededCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3.2. Creating the KataConfig custom resource using the CLI Copier lienLien copié sur presse-papiers!
You must create one KataConfig custom resource (CR) to install kata as a RuntimeClass on your nodes. Creating the KataConfig CR triggers the OpenShift sandboxed containers Operator to do the following:
-
Install the needed RHCOS extensions, such as QEMU and
kata-containers, on your RHCOS node. - Ensure that the CRI-O runtime is configured with the correct runtime handlers.
-
Create a
RuntimeClassCR namedkatawith a default configuration. This enables users to configure workloads to usekataas the runtime by referencing the CR in theRuntimeClassNamefield. This CR also specifies the resource overhead for the runtime.
Kata is installed on all worker nodes by default. If you want to install kata as a RuntimeClass only on specific nodes, you can add labels to those nodes, and then define the label in the KataConfig CR when you create it.
Prerequisites
- You have installed Red Hat OpenShift 4.13 on your cluster.
-
You have installed the OpenShift CLI (
oc). -
You have access to the cluster as a user with the
cluster-adminrole. - You have installed the OpenShift sandboxed containers Operator.
Creating the KataConfig CR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes. Factors that impede reboot time are as follows:
- A larger Red Hat OpenShift deployment with a greater number of worker nodes.
- Activation of the BIOS and Diagnostics utility.
- Deployment on a hard disk drive rather than an SSD.
- Deployment on physical nodes such as bare metal, rather than on virtual nodes.
- A slow CPU and network.
Procedure
Create a YAML file with the following manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Set`checkNodeEligibility` to
trueto detect node eligibility to runkataas aRuntimeClass. For more information, see "Checking whether cluster nodes are eligible to run OpenShift sandboxed containers".
(Optional) If you want to install
kataas aRuntimeClassonly on selected nodes, create a YAML file that includes the label in the manifest:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Labels in
kataConfigPoolSelectoronly support single values;nodeSelectorsyntax is not supported.
Create the
KataConfigresource:oc create -f cluster-kataconfig.yaml
$ oc create -f cluster-kataconfig.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The new KataConfig CR is created and begins to install kata as a RuntimeClass on the worker nodes. Wait for the kata installation to complete and the worker nodes to reboot before continuing to the next step.
OpenShift sandboxed containers installs kata only as a secondary, optional runtime on the cluster and not as the primary runtime.
Verification
Monitor the installation progress:
watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Once the value of Is In Progress appears as
false, the installation is complete.
2.3.3. Deploying a workload in a sandboxed container using the CLI Copier lienLien copié sur presse-papiers!
OpenShift sandboxed containers installs Kata as a secondary, optional runtime on your cluster, and not as the primary runtime.
To deploy a pod-templated workload in a sandboxed container, you must add kata as the runtimeClassName to the workload YAML file.
Prerequisites
- You have installed Red Hat OpenShift 4.13 on your cluster.
-
You have installed the OpenShift CLI (
oc). -
You have access to the cluster as a user with the
cluster-adminrole. - You have installed the OpenShift sandboxed containers Operator.
-
You have created a
KataConfigcustom resource (CR).
Procedure
Add
runtimeClassName: katato any pod-templated object:-
Podobjects -
ReplicaSetobjects -
ReplicationControllerobjects -
StatefulSetobjects -
Deploymentobjects -
DeploymentConfigobjects
.Example for Pod object
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Red Hat OpenShift creates the workload and begins scheduling it.
Verification
-
Inspect the
runtimeClassNamefield on a pod-templated object. If theruntimeClassNameiskata, then the workload is running on OpenShift sandboxed containers.