Deploying OpenShift sandboxed containers on AWS
Enhanced security and isolation for container workloads
Abstract
Preface
Red Hat OpenShift sandboxed containers provide enhanced security and isolation by running containerized applications in lightweight virtual machines. You install the OpenShift sandboxed containers Operator on an OpenShift Container Platform cluster. Then, you configure your workload pods to use the optional "kata" runtime.
Chapter 1. Provide feedback on Red Hat documentation
You can provide feedback or report an error by submitting the Create Issue form in Jira.
Procedure
- Ensure that you are logged in to Jira. If you do not have a Jira account, you must create a This content is not included.Red Hat Jira account.
- Launch the Content from redhat.atlassian.net is not included.Create Issue form.
- Replace the pre-filled Summary text with a short title that describes your specific issue.
- In the Description field, include the documentation URL, chapter or section number, and a detailed description of the issue.
- Click Create.
Chapter 2. OpenShift sandboxed containers workload isolation
You can deploy Red Hat OpenShift sandboxed containers workloads on a Red Hat OpenShift Container Platform cluster running on Amazon Web Services. OpenShift sandboxed containers integrates Kata containers as an optional runtime, providing enhanced security and isolation by running containerized applications in lightweight virtual machines.
This integration provides a more secure runtime environment for sensitive workloads without significant changes to existing OpenShift Container Platform workflows. This runtime supports containers in dedicated virtual machines (VMs), providing improved workload isolation.
2.1. Features
OpenShift sandboxed containers provides the following features:
- Run privileged or untrusted workloads
You can safely run workloads that require specific privileges, without the risk of compromising cluster nodes by running privileged containers. Workloads that require special privileges include the following:
- Workloads that require special capabilities from the kernel, beyond the default ones granted by standard container runtimes such as CRI-O, for example to access low-level networking features.
- Workloads that need elevated root privileges, for example to access a specific physical device. With OpenShift sandboxed containers, it is possible to pass only a specific device through to the virtual machines (VM), ensuring that the workload cannot access or misconfigure the rest of the system.
Workloads for installing or using
set-uidroot binaries. These binaries grant special privileges and, as such, can present a security risk. With OpenShift sandboxed containers, additional privileges are restricted to the virtual machines, and grant no special access to the cluster nodes.Some workloads require privileges specifically for configuring the cluster nodes. Such workloads should still use privileged containers, because running on a virtual machine would prevent them from functioning.
- Ensure isolation for sensitive workloads
- The OpenShift sandboxed containers for Red Hat OpenShift Container Platform integrates Kata containers as an optional runtime, providing enhanced security and isolation by running containerized applications in lightweight virtual machines. This integration provides a more secure runtime environment for sensitive workloads without significant changes to existing OpenShift workflows. This runtime supports containers in dedicated virtual machines (VMs), providing improved workload isolation.
- Ensure kernel isolation for each workload
-
You can run workloads that require custom kernel tuning (such as
sysctl, scheduler changes, or cache tuning) and the creation of custom kernel modules (such asout of treeor special arguments). - Share the same workload across tenants
-
You can run workloads that support many users (tenants) from different organizations sharing the same OpenShift Container Platform cluster. The system also supports running third-party workloads from multiple vendors, such as container network functions (CNFs) and enterprise applications. Third-party CNFs, for example, might not want their custom settings interfering with packet tuning or with
sysctlvariables set by other applications. Running inside a completely isolated kernel is helpful in preventing "noisy neighbor" configuration problems. - Ensure proper isolation and sandboxing for testing software
-
You can run containerized workloads with known vulnerabilities or handle issues in an existing application. This isolation enables administrators to give developers administrative control over pods, which is useful when the developer wants to test or validate configurations beyond those an administrator would typically grant. Administrators can, for example, safely and securely delegate kernel packet filtering (eBPF) to developers. eBPF requires
CAP_ADMINorCAP_BPFprivileges, and is therefore not allowed under a standard CRI-O configuration, as this would grant access to every process on the Container Host worker node. Similarly, administrators can grant access to intrusive tools such asSystemTap, or support the loading of custom kernel modules during their development. - Ensure default resource containment through VM boundaries
- By default, OpenShift sandboxed containers manages resources such as the central processing unit (CPU), memory, storage, and networking in a robust and secure way. Since OpenShift sandboxed containers deploys on VMs, additional layers of isolation and security give a finer-grained access control to the resource. For example, an errant container will not be able to assign more memory than is available to the VM. Conversely, a container that needs dedicated access to a network card or to a disk can take complete control over that device without getting any access to other devices.
2.2. OpenShift sandboxed containers compatibility with OpenShift Container Platform
You must ensure that your Red Hat OpenShift Container Platform version supports the features you require.
The required functionality for OpenShift Container Platform is supported by two main components:
- Kata runtime
- The Kata runtime is included with Red Hat Enterprise Linux CoreOS (RHCOS) and receives updates with every OpenShift Container Platform release. When enabling peer pods with the Kata runtime, the OpenShift sandboxed containers Operator requires external network connectivity to pull the necessary image components and helper utilities to create the pod virtual machine (VM) image.
- OpenShift sandboxed containers Operator
- The OpenShift sandboxed containers Operator is a Rolling Stream Operator, which means the latest version is the only supported version. It works with all currently supported versions of OpenShift Container Platform.
The Operator depends on the features that come with the RHCOS host and the environment it runs in.
You must install RHCOS on the worker nodes. Red Hat Enterprise Linux (RHEL) nodes are not supported.
The following compatibility matrix for OpenShift sandboxed containers and OpenShift Container Platform releases identifies compatible features and environments.
Table 2.1. Supported architectures
| Architecture | OpenShift Container Platform version (without GPU) | OpenShift Container Platform version (with GPU) |
|---|---|---|
| x86_64 | 4.19.38+ | 4.21.24+ |
| s390x | 4.19.38+ | — |
There are two ways to deploy the Kata containers runtime:
- Bare metal
- Peer pods
You can deploy OpenShift sandboxed containers by using peer pods on Microsoft Azure, Amazon Web Services, or Google Cloud. With the release of OpenShift sandboxed containers 1.13.1, the OpenShift sandboxed containers Operator requires OpenShift Container Platform version 4.19.38 or later for deployments without support for a graphics processing unit (GPU).
The following table describes OpenShift Container Platform versions and features with the following support levels:
- GA: General Availability
- TP: Technology Preview
The version numbers in the table represent the minimum supported version. For example, "4.21.24+" means version 4.21.24 or any later version.
For Microsoft Azure Red Hat OpenShift, the minimum OpenShift Container Platform version listed in the table is supported only after the corresponding z-stream release is available on the Azure Red Hat OpenShift managed service.
Table 2.2. Standalone Control Plane (SCP) mode: feature availability by OpenShift Container Platform version
| Platform | GPU | 4.19.38+ | 4.20.29+ | 4.21.24+ | 4.22.5+ |
|---|---|---|---|---|---|
| Bare metal | No | GA | GA | GA | GA |
| NVIDIA H100 or DGX B200 | — | — | GA | GA | |
| IBM Z bare metal | No | GA | GA | GA | GA |
| IBM Z peer pods | No | GA | GA | GA | GA |
| Microsoft Azure | No | GA | GA | GA | GA |
| NVIDIA H100 | — | — | TP | TP | |
| Microsoft Azure Red Hat OpenShift | No | GA | GA | GA | GA |
| Amazon Web Services | No | GA | GA | GA | GA |
| Google Cloud | No | GA | GA | GA | GA |
GPU support with Kata requires the KubeletPodResourcesGet feature gate to be enabled. This feature gate is available only in OpenShift Container Platform 4.21 and later. Additionally, the CRI-O fix for extending the timeout that is required for peer pods GPU support is available only in OpenShift Container Platform 4.22 and later.
2.3. Common terms
The following terms are used throughout the documentation.
- Attestation
- The process of verifying the integrity and trustworthiness of a Trusted Execution Environment (TEE) and the confidential containers workloads running within it, ensuring that only trusted code and data are executed. Red Hat build of Trustee performs this function.
- Confidential containers
- A technology that provides a confidential computing environment to protect containers and data by leveraging Trusted Execution Environments.
- Initdata
- A specification used to securely initialize a pod with workload-specific data (such as certificates, cryptographic keys, or an optional Kata Agent policy) at runtime, preventing the need to embed this data directly in the virtual machine (VM) image.
- Kata Agent
- A component within the pod Virtual Machine (VM) that enforces runtime policies and manages the lifecycle of the containers running inside the VM. Its policy controls application programming interface (API) requests for peer pods.
- Kata containers
- Kata containers is a core upstream project that is used to build OpenShift sandboxed containers. OpenShift sandboxed containers integrates Kata containers with OpenShift Container Platform.
kataruntime- The optional runtime installed by the OpenShift sandboxed containers Operator when configuring bare metal deployments.
kata-ccruntime- The runtime class used specifically for confidential containers deployments on bare-metal servers.
kata-remoteruntime- The runtime class used for peer pod deployments on cloud platforms or remote hypervisors.
KataConfig- A custom resource used to configure and launch OpenShift sandboxed containers.
TrusteeConfig- A custom resource used to configure and launch Red Hat build of Trustee.
- OpenShift sandboxed containers
- OpenShift sandboxed containers integrates Kata containers as an optional runtime to provide enhanced security and isolation for container workloads by running applications in lightweight virtual machines.
- OpenShift sandboxed containers Operator
- The OpenShift sandboxed containers Operator manages the lifecycle of OpenShift sandboxed containers and confidential containers on a cluster.
- Peer pod
A peer pod in OpenShift sandboxed containers extends the concept of a standard pod. Unlike a standard sandboxed container, where the virtual machine is created on the worker node itself, in a peer pod, the virtual machine is created through a remote hypervisor using any supported hypervisor or cloud provider API.
The peer pod acts as a regular pod on the worker node, with its corresponding VM running elsewhere. The remote location of the VM is transparent to the user and is specified by the runtime class in the pod specification. The peer pod design circumvents the need for nested virtualization.
- Pod
A pod is a construct that is inherited from Kubernetes and OpenShift Container Platform. It represents resources where containers can be deployed. Containers run inside pods, and pods are used to specify resources that can be shared between multiple containers.
In the context of OpenShift sandboxed containers, a pod is implemented as a virtual machine. Several containers can run in the same pod on the same virtual machine.
- Red Hat build of Trustee
- Red Hat build of Trustee is an attestation service that verifies the trustworthiness of the location where you plan to run your workload or where you plan to send confidential information. Red Hat build of Trustee includes components deployed on a trusted side and used to verify whether the remote workload is running in a Trusted Execution Environment (TEE).
- Red Hat build of Trustee Operator
- The Red Hat build of Trustee Operator manages the installation, lifecycle, and configuration of Red Hat build of Trustee.
- Runtime class
- An object that describes the specific runtime configuration used to run a workload.
- Sandbox
A sandbox is an isolated environment where programs can run. In a sandbox, you can run untested or untrusted programs without risking harm to the host machine or the operating system.
In the context of OpenShift sandboxed containers, sandboxing is achieved by running workloads in a different kernel using virtualization, providing enhanced control over the interactions between multiple workloads that run on the same host.
- Trusted Execution Environment (TEE)
- Hardware-based security technology leveraged by confidential containers to protect containers and data. Examples: Intel® TDX, AMD SEV-SNP.
2.4. OpenShift sandboxed containers Operator
The OpenShift sandboxed containers Operator encapsulates all of the components from Kata containers. It manages installation, lifecycle, and configuration tasks.
The OpenShift sandboxed containers Operator is packaged in the Operator bundle format as two container images:
- The bundle image contains metadata and is required to make the Operator ready for Operator Lifecycle Manager (OLM).
-
The second container image contains the actual controller that monitors and manages the
KataConfigresource.
The OpenShift sandboxed containers Operator is based on the Red Hat Enterprise Linux CoreOS (RHCOS) extensions concept. RHCOS extensions are a mechanism to install optional OpenShift Container Platform software. The OpenShift sandboxed containers Operator uses this mechanism to deploy sandboxed containers on a cluster.
The sandboxed containers RHCOS extension contains RPMs for Kata, Quick Emulator (QEMU), and its dependencies. You can enable them by using the MachineConfig resources that the Machine Config Operator provides.
2.5. OpenShift Virtualization
You can deploy OpenShift sandboxed containers on clusters with OpenShift Virtualization.
To run OpenShift Virtualization and OpenShift sandboxed containers at the same time, your virtual machines must be live migratable so that they do not block node reboots.
Additional resources
Chapter 3. Installation
You install OpenShift sandboxed containers on Amazon Web Services by installing the OpenShift sandboxed containers Operator.
Perform the following steps:
- Optional: If your cluster uses Security Token Service (STS), configure an IAM role for STS authentication.
- Install the OpenShift sandboxed containers Operator.
3.1. STS authentication
When an OpenShift Container Platform cluster running on Amazon Web Services uses Security Token Service (STS), the cluster uses IAM Roles for Service Accounts (IRSA) for component authentication. In this mode, OpenShift sandboxed containers uses an IAM role to authenticate with AWS by using short-lived, federated tokens instead of static secrets. This approach improves security by eliminating the need to store and manage long-lived cloud provider credentials.
STS authentication on AWS is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
STS authentication configuration is required only for clusters that were installed in STS mode. For clusters that do not use STS, the Cloud Credential Operator handles credentials automatically and no additional configuration is needed.
STS authentication uses the IRSA workflow to establish trust between Kubernetes service accounts and AWS IAM:
- You create an AWS IAM role with a trust policy that trusts the cluster’s OpenID Connect (OIDC) provider, scoped to the OpenShift sandboxed containers Operator service account.
- You attach IAM policies to the role for managing peer pod EC2 instances and creating pod virtual machine (VM) images.
-
When installing the OpenShift sandboxed containers Operator, you provide the IAM role Amazon Resource Name (ARN) as the
ROLEARNenvironment variable in the Operator subscription. - The OpenShift sandboxed containers Operator uses the role ARN to create a secret that also references the projected service account token to be consumed by the OpenShift sandboxed containers components.
- The AWS SDK sends the Kubernetes service account token to AWS STS.
- AWS STS validates the token against the cluster’s OIDC provider and returns temporary AWS credentials.
- The OpenShift sandboxed containers components use these temporary credentials to authenticate AWS API requests for peer pod operations.
3.1.1. Configure an IAM role for STS authentication
If you use STS authentication, you must create an AWS Identity and Access Management (IAM) role, attach the required policies, and configure the OpenID Connect (OIDC) trust policy before installing the OpenShift sandboxed containers Operator.
Security Token Service (STS) authentication configuration is required only for clusters that were installed in STS mode.
The IAM role uses two managed policies:
- A base policy for runtime cloud API adaptor (CAA) operations.
- An extended policy for pod virtual machine (VM) image creation, which you can detach after image creation to follow the principle of least privilege.
Prerequisites
-
You have installed the AWS CLI (
aws) and configured it with IAM permissions for creating roles and policies. -
You have installed the OpenShift Container Platform CLI (
oc). -
You have access to the cluster as a user with the
cluster-adminrole. - You have installed the cluster in STS mode.
Procedure
Set the required environment variable for the IAM role name:
$ export ROLE_NAME=openshift-sandboxed-containers-role
Retrieve the AWS account ID and the cluster’s OIDC provider:
$ export AWS_ACCOUNT_ID=$(aws sts get-caller-identity \ --query "Account" --output text)
$ export OIDC_PROVIDER=$(oc get authentication cluster \ -o jsonpath='{.spec.serviceAccountIssuer}' | sed 's/^https:\/\///')To verify the values, run the following commands:
$ echo "AWS_ACCOUNT_ID: $AWS_ACCOUNT_ID"
$ echo "OIDC_PROVIDER: $OIDC_PROVIDER"
Create a trust policy JSON file that grants the cluster’s OIDC provider permission to assume the IAM role:
$ cat > trust-policy.json <<EOF { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/${OIDC_PROVIDER}" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "${OIDC_PROVIDER}:sub": "system:serviceaccount:openshift-sandboxed-containers-operator:default", "${OIDC_PROVIDER}:aud": "openshift" } } } ] } EOFThe trust policy scopes access to the
defaultservice account in theopenshift-sandboxed-containers-operatornamespace with theopenshiftaudience.Create the IAM role with the trust policy:
$ aws iam create-role \ --role-name $ROLE_NAME \ --assume-role-policy-document file://trust-policy.json
Attach the base IAM policy for runtime EC2 operations:
$ aws iam attach-role-policy \ --role-name $ROLE_NAME \ --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess
This policy grants the IAM role the EC2 permissions that the cloud API adaptor requires to create and manage peer pod instances.
Create the extended IAM policy for pod VM image creation operations:
$ cat > extended-policy.json <<EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "VMImportRoleManagement", "Effect": "Allow", "Action": [ "iam:CreateRole", "iam:PutRolePolicy", "iam:GetRole", "iam:ListRolePolicies", "iam:DeleteRole", "iam:DeleteRolePolicy" ], "Resource": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/vmimport" }, { "Sid": "S3BucketManagement", "Effect": "Allow", "Action": [ "s3:CreateBucket", "s3:DeleteBucket", "s3:GetBucketLocation", "s3:ListBucket", "s3:GetBucketAcl" ], "Resource": "arn:aws:s3:::podvm-*" }, { "Sid": "S3ObjectManagement", "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject" ], "Resource": "arn:aws:s3:::podvm-*/*" }, { "Sid": "S3ListAllBuckets", "Effect": "Allow", "Action": "s3:ListAllMyBuckets", "Resource": "*" } ] } EOFThis policy grants permissions for managing the
vmimportIAM role and S3 buckets used during pod VM image creation.Create the IAM policy and attach it to the role:
$ aws iam create-policy \ --policy-name OSC-ImageCreation-Policy \ --policy-document file://extended-policy.json
$ aws iam attach-role-policy \ --role-name $ROLE_NAME \ --policy-arn arn:aws:iam::${AWS_ACCOUNT_ID}:policy/OSC-ImageCreation-Policy
Verification
Verify that the IAM role was created and the policies are attached:
$ aws iam list-attached-role-policies --role-name $ROLE_NAME
The output should list two attached policies:
AmazonEC2FullAccessandOSC-ImageCreation-Policy.
Next steps
Construct and save the IAM Role ARN by running the following command:
$ export ROLEARN="arn:aws:iam::${AWS_ACCOUNT_ID}:role/${ROLE_NAME}" && \ echo "ROLEARN: $ROLEARN"You need the role ARN when installing the OpenShift sandboxed containers Operator.
After the pod VM image is created, detach the extended policy to follow the principle of least privilege:
$ aws iam detach-role-policy \ --role-name $ROLE_NAME \ --policy-arn arn:aws:iam::${AWS_ACCOUNT_ID}:policy/OSC-ImageCreation-PolicyYou can reattach the policy later if you need to recreate the pod VM image. Detaching the policy does not require any Operator reconfiguration because the IAM role ARN remains the same.
3.2. Prerequisites
Review the following prerequisites before deploying OpenShift sandboxed containers.
- You have installed Red Hat OpenShift Container Platform version 4.18.38 or later.
- Your OpenShift Container Platform cluster has at least one worker node.
Additional resources
3.3. Install the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the command-line interface (CLI).
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Create an
osc-namespace.yamlmanifest file:apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
Create the namespace by running the following command:
$ oc create -f osc-namespace.yaml
Create an
osc-operatorgroup.yamlmanifest file:apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: sandboxed-containers-operator-group namespace: openshift-sandboxed-containers-operator spec: targetNamespaces: - openshift-sandboxed-containers-operator
Create the Operator group by running the following command:
$ oc create -f osc-operatorgroup.yaml
Create an
osc-subscription.yamlmanifest file:apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: sandboxed-containers-operator namespace: openshift-sandboxed-containers-operator spec: channel: stable name: sandboxed-containers-operator source: redhat-operators sourceNamespace: openshift-marketplace startingCSV: sandboxed-containers-operator.v1.13.1
Optional: If your cluster uses STS authentication, add the following configuration to the
osc-subscription.yamlfile to set the IAM role ARN:# ... spec: config: env: - name: ROLEARN value: <role_arn> installPlanApproval: Manual<role_arn>Specifies the ARN of the IAM role that you created in Section 3.1.1, “Configure an IAM role for STS authentication”. For example,
arn:aws:iam::123456789012:role/openshift-sandboxed-containers-role.NoteManual installation plan approval is recommended for STS deployments. Permission changes might be required before upgrading, and manual subscriptions ensure that the cluster administrator has time to verify the permissions of the next version and take the necessary steps before the upgrade.
Create the subscription by running the following command:
$ oc create -f osc-subscription.yaml
Verification
Verify that the Operator is correctly installed by running the following command:
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the installation progress by running the following command:
$ watch oc get csv -n openshift-sandboxed-containers-operator
NAME DISPLAY VERSION PHASE sandboxed-containers-operator.v1.13.1 OpenShift sandboxed containers Operator 1.13.1 Succeeded
The installation is complete when the
PHASEcolumn showsSucceeded.
Chapter 4. Configuration
You can configure OpenShift sandboxed containers for Amazon Web Services.
Perform the following steps:
- Enable ports to allow internal communication with peer pods.
- Create the peer pods config map.
-
Create the
KataConfigcustom resource. - Optional: Modify the number of peer pod VMs running on each worker node.
- Verify the pod VM image.
- Disable insecure options by customizing the Kata Agent policy.
- Optional: If you select a custom peer pod VM image from an authenticated registry, configure a pull secret.
- Optional: Select a custom peer pod VM image.
- Configure your workload for OpenShift sandboxed containers.
4.1. Enable ports for peer pod communication
You must enable ports 15150 and 9000 to allow internal communication with peer pods running on AWS.
Prerequisites
- You have installed the AWS command line tool.
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Log in to your OpenShift Container Platform cluster and retrieve the instance ID:
$ INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' \ -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')Retrieve the AWS region:
$ AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.aws.region}')Retrieve the security group IDs and store them in an array:
$ AWS_SG_IDS=($(aws ec2 describe-instances --instance-ids ${INSTANCE_ID} \ --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' \ --output text --region $AWS_REGION))For each security group ID, authorize the peer pods shim to access kata-agent communication, and set up the peer pods tunnel:
$ for AWS_SG_ID in "${AWS_SG_IDS[@]}"; do \ aws ec2 authorize-security-group-ingress --group-id $AWS_SG_ID --protocol tcp --port 15150 --source-group $AWS_SG_ID --region $AWS_REGION; \ aws ec2 authorize-security-group-ingress --group-id $AWS_SG_ID --protocol tcp --port 9000 --source-group $AWS_SG_ID --region $AWS_REGION; \ doneNoteThe
aws ec2 authorize-security-group-ingresscommand is not idempotent. If the rules already exist, the command returns anInvalidPermission.Duplicateerror and exits with a nonzero status. This causes the loop to stop before processing remaining security groups. If you are re-running this procedure, verify that the rules do not already exist before running the loop.The ports are now enabled.
4.2. Retrieve cloud provider values
You retrieve network and infrastructure values from your Amazon Web Services instance. You use these values when you create the peer pods config map.
Procedure
Retrieve and record the instance ID by running the following command:
$ INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' \ -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')Use this value to retrieve other values for the secret object.
Retrieve and record the AWS region by running the following command:
$ AWS_REGION=$(oc get infrastructure/cluster \ -o jsonpath='{.status.platformStatus.aws.region}') \ && echo "AWS_REGION: \"$AWS_REGION\""Retrieve and record the AWS subnet ID by running the following command:
$ AWS_SUBNET_ID=$(aws ec2 describe-instances --instance-ids ${INSTANCE_ID} \ --query 'Reservations[*].Instances[*].SubnetId' --region ${AWS_REGION} \ --output text) && echo "AWS_SUBNET_ID: \"$AWS_SUBNET_ID\""Retrieve and record the AWS VPC ID by running the following command:
$ AWS_VPC_ID=$(aws ec2 describe-instances --instance-ids ${INSTANCE_ID} \ --query 'Reservations[*].Instances[*].VpcId' --region ${AWS_REGION} \ --output text) && echo "AWS_VPC_ID: \"$AWS_VPC_ID\""Retrieve and record the AWS security group IDs by running the following command:
AWS_SG_IDS=$(aws ec2 describe-instances --instance-ids ${INSTANCE_ID} \ --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' \ --region $AWS_REGION --output json | jq -r '.[][][]' | paste -sd "," -) \ && echo "AWS_SG_IDS: \"$AWS_SG_IDS\""
4.3. Create the peer pods config map
You create the peer pods config map to provide cloud provider credentials and configuration settings that the OpenShift sandboxed containers Operator uses to create and manage peer pod virtual machine instances.
Prerequisites
- You have an Amazon Machine Image (AMI) ID if you are not using the default AMI ID based on your cluster credentials.
Procedure
Create a
peer-pods-cm.yamlmanifest file according to the following example:apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "aws" VXLAN_PORT: "9000" PROXY_TIMEOUT: "8m" PODVM_INSTANCE_TYPE: "t3.medium" PODVM_INSTANCE_TYPES: "t2.small,t2.medium,t3.large" PODVM_AMI_ID: "<podvm_ami_id>" AWS_REGION: "<aws_region>" AWS_SUBNET_ID: "<aws_subnet_id>" AWS_VPC_ID: "<aws_vpc_id>" AWS_SG_IDS: "<aws_sg_ids>" TAGS: "key1=value1,key2=value2" PEERPODS_LIMIT_PER_NODE: "10" ROOT_VOLUME_SIZE: "6" DISABLECVM: "true"
PODVM_INSTANCE_TYPE- Defines the default instance type that is used if the instance type is not defined in the workload object.
PODVM_INSTANCE_TYPES- Specify the allowed instance types, without spaces, for creating the pod. You can define smaller instance types for workloads that need less memory and fewer CPUs or larger instance types for larger workloads.
PODVM_AMI_ID-
This value is populated when you run the
KataConfigcustom resource (CR), using an AMI ID based on your cluster credentials. If you create your own AMI, specify the correct AMI ID. TAGS-
You can configure custom tags as
key=valuepairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters. PEERPODS_LIMIT_PER_NODE-
Maximum number of peer pods per node. The default value is
10. ROOT_VOLUME_SIZE- Root volume size in gigabytes for the pod VM. The default and minimum size is 6 GB.
Create the config map by running the following command:
$ oc create -f peer-pods-cm.yaml
Verification
Verify that the peer pods config map exists by running the following command:
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator
NAME DATA AGE peer-pods-cm 10 10s
Additional resources
4.4. Create the KataConfig custom resource
You must create the KataConfig custom resource (CR) to install kata-remote as a runtime class on your worker nodes.
Prerequisites
-
Be aware that creating the
KataConfigCR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes depending on your deployment size, hardware type, and other factors.
Procedure
Create an
example-kataconfig.yamlmanifest file according to the following example:apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
<label_key>: '<label_value>'-
Optional: If you have applied node labels to install
kata-remoteon specific nodes, specify the key and value, for example,kata-remote: 'true'.
Create the
KataConfigCR by running the following command:$ oc create -f example-kataconfig.yaml
The new
KataConfigCR is created and installskata-remoteas a runtime class on the worker nodes.Wait for the
kata-remoteinstallation to complete and the worker nodes to reboot before verifying the installation.Optional: Monitor the installation progress by running the following command:
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodesisinstalledand the conditionInProgressisFalsewithout specifying a reason, thekata-remoteis installed on the cluster.
Verification
Verify the daemon set by running the following command:
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
$ oc get runtimeclass
NAME HANDLER AGE kata kata 34m kata-nvidia-gpu kata-nvidia-gpu 34m kata-remote kata-remote 152m
You can also see the default
kataruntime class in addition tokata-remote.
4.4.1. Set the peer pod VM limit per node
To modify the limit of peer pod virtual machines (VMs) per node, edit the peer-pods-cm config map.
Procedure
Check the current limit by running the following command:
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator \ -o jsonpath='{.data.PEERPODS_LIMIT_PER_NODE}{"\n"}'Specify a new value for the
limitkey by running the following command:$ oc patch configmap peer-pods-cm -n openshift-sandboxed-containers-operator \ --type merge -p '{"data":{"PEERPODS_LIMIT_PER_NODE":"<value>"}}'
Verification
Verify the updated limit by running the following command:
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator \ -o jsonpath='{.data.PEERPODS_LIMIT_PER_NODE}{"\n"}'Confirm the output shows the value you specified.
4.5. Verify the pod VM image
After the OpenShift sandboxed containers Operator installs kata-remote on your cluster, it creates a pod VM image for peer pods. This process can take a long time because the image builds on the cloud instance. To verify that the pod VM image was created successfully, check the peer pods config map.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Obtain the config map that you created for the peer pods:
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
Check the
datasection of the YAML output for thePODVM_AMI_IDparameter.If the
PODVM_AMI_IDparameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
$ oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
Retrieve the job log by running the following command:
$ oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
If you cannot resolve the issue, submit a Red Hat Support case and attach the output of both logs.
4.6. Configure the Kata Agent policy
You can configure agent policies to restrict which API requests the kata-agent inside the pod virtual machine (VM) may handle. Policies can be set to block all administrative actions after the container starts, neutralizing the agent as an attack vector during runtime. A custom policy replaces the default policy entirely. To modify specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create an
initdata.tomlfile to modify the default policy:algorithm = "sha256" version = "0.1.0" [data] "aa.toml" = ''' ''' "policy.rego" = ''' package agent_policy default AddARPNeighborsRequest := true default AddSwapRequest := true default CloseStdinRequest := true default CopyFileRequest := true default CreateContainerRequest := true default CreateSandboxRequest := true default DestroySandboxRequest := true default GetMetricsRequest := true default GetOOMEventRequest := true default GuestDetailsRequest := true default ListInterfacesRequest := true default ListRoutesRequest := true default MemHotplugByProbeRequest := true default OnlineCPUMemRequest := true default PauseContainerRequest := true default PullImageRequest := true default ReadStreamRequest := false default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default ReseedRandomDevRequest := true default ResumeContainerRequest := true default SetGuestDateTimeRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StartTracingRequest := true default StatsContainerRequest := true default StopTracingRequest := true default TtyWinResizeRequest := true default UpdateContainerRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default ExecProcessRequest := false default SetPolicyRequest := false default WriteStreamRequest := false '''
The default policy allows all API calls. Adjust the
trueorfalsevalues to customize the policy further based on your needs.Convert the
initdata.tomlfile to a Base64-encoded string by running the following command:$ cat initdata.toml | gzip | base64 -w0 > initdata.txt
Record this string to use in the pod manifest.
Add the Base64-encoded initdata string to the
my-pod.yamlmanifest:apiVersion: v1 kind: Pod metadata: name: my-pod annotations: io.katacontainers.config.hypervisor.cc_init_data: <initdata_string> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefaultCreate the pod by running the following command:
$ oc create -f my-pod.yaml
4.7. Use a custom VM image for peer pods
You can select a custom peer pod virtual machine (VM) image by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map. If the image is in a private registry, you must first configure a pull secret.
Prerequisites
- You have the ID of a custom pod VM image, which is compatible with your cloud provider or hypervisor.
Procedure
Optional: If the custom pod VM image is in a private registry, configure a pull secret:
Set the
NSvariable to the namespace where you deploy your peer pods:$ NS=<namespace>
Copy the pull secret to the peer pod namespace:
$ oc get secret pull-secret -n openshift-config -o yaml \ | sed "s/namespace: openshift-config/namespace: ${NS}/" \ | oc apply -n "${NS}" -f -You can use the cluster pull secret, as in this example, or a custom pull secret.
Optional: Link the pull secret to the default service account:
$ oc secrets link default pull-secret --for=pull -n ${NS}
Create a
my-pod-manifest.yamlfile according to the following example:apiVersion: v1 kind: Pod metadata: name: my-pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<custom_image_id>" spec: runtimeClassName: kata-remote containers: - name: <example_container> image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]Create the pod by running the following command:
$ oc create -f my-pod-manifest.yaml
Verification
Verify that the pod is running with the custom peer pod VM image by running the following command:
$ oc get pod my-pod-manifest -o jsonpath='{.metadata.annotations.io\.katacontainers\.config\.hypervisor\.image}'- Confirm that the output matches the custom image ID you specified.
Additional resources
4.8. Configure your workload
You configure your workload for OpenShift sandboxed containers by setting kata-remote as the runtime class for the following pod-templated objects:
-
Podobjects -
ReplicaSetobjects -
ReplicationControllerobjects -
StatefulSetobjects -
Deploymentobjects -
DeploymentConfigobjects
Do not deploy workloads in an Operator namespace. Create a dedicated namespace for these resources.
You can define whether the workload should be deployed using the default instance type, which you defined in the peer pods config map, by adding an annotation to the YAML file.
If you do not want to define the instance type manually, you can add an annotation to use an automatic instance type, based on the memory available.
Procedure
Add
spec.runtimeClassName: kata-remoteto the manifest of each pod-templated workload object as in the following example:apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
Optional: To override the default instance type, add the following annotation with an instance type that is defined in the peer pods config map:
apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: <instance> # ...Optional: To use an automatic instance type, add the following annotations:
apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...The workload runs on an automatic instance type based on the amount of memory available.
Apply the changes to the workload object by running the following command:
$ oc apply -f <object.yaml>
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassNamefield of a pod-templated object. If the value iskata-remote, then the workload is running on OpenShift sandboxed containers.
Chapter 5. Upgrade
You update OpenShift sandboxed containers by updating the OpenShift Container Platform cluster and the OpenShift sandboxed containers Operator.
Then, you update the pod virtual machine (VM) image by deleting and re-creating KataConfig custom resource (CR). Updating the OpenShift sandboxed containers Operator when enablePeerPods: true is set in the KataConfig CR does not update the pod VM image automatically.
You must perform the following steps:
Update your OpenShift Container Platform cluster to update the
Kataruntime and its dependencies.The RHCOS extension
sandboxed containerscontains the required components to run OpenShift sandboxed containers, such as the Kata containers runtime, the hypervisor Quick Emulator (QEMU), and other dependencies. You update the extension by updating the cluster to a new release of OpenShift Container Platform.- Update the OpenShift sandboxed containers Operator.
-
Delete the
KataConfigCR. - Verify that the image ID in the peer pods config map is empty.
-
Re-create the
KataConfigCR.
Additional resources
5.1. Upgrade the OpenShift sandboxed containers Operator
You can upgrade the OpenShift sandboxed containers Operator by using the command-line interface (CLI).
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Create an
osc-subscription.yamlmanifest file:apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: sandboxed-containers-operator namespace: openshift-sandboxed-containers-operator spec: channel: stable installPlanApproval: Automatic name: sandboxed-containers-operator source: redhat-operators sourceNamespace: openshift-marketplace startingCSV: sandboxed-containers-operator.v1.13.1
Create the subscription by running the following command:
$ oc create -f osc-subscription.yaml
Verification
Verify that the Operator upgrade is complete by running the following command:
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the upgrade progress by running the following command:
$ watch oc get csv -n openshift-sandboxed-containers-operator
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.13.1 1.13.0 Succeeded
The upgrade is complete when the
PHASEcolumn showsSucceededfor the new version.
Additional resources
5.2. Delete the KataConfig custom resource
You must delete the KataConfig custom resource (CR).
Deleting the KataConfig CR automatically reboots the worker nodes. Reboot can take from 10 to 60 minutes. The following factors can affect the reboot time:
- A larger OpenShift Container Platform deployment with a greater number of worker nodes.
- Activation of the BIOS and Diagnostics utility.
- Deployment on a hard drive rather than an SSD.
- Deployment on physical nodes such as bare metal, rather than on virtual nodes.
- A slow central processing unit (CPU) and network.
Prerequisites
-
You have deleted all pods that use the
kata-remoteruntime class.
Procedure
Delete the
KataConfigCR by running the following command:$ oc delete kataconfig example-kataconfig
The OpenShift sandboxed containers Operator removes all resources that were initially created to enable the runtime on your cluster.
ImportantWhen you delete the
KataConfigCR, the command-line interface (CLI) stops responding until all worker nodes reboot. You must wait for the deletion process to complete before performing the verification.
Verification
Confirm that the
KataConfigCR no longer exists by running the following command:$ oc get kataconfig example-kataconfig
Error from server (NotFound): kataconfigs.kataconfiguration.openshift.io "example-kataconfig" not found
Additional resources
5.3. Verify the peer pod image ID is empty
When you configure a custom pod virtual machine (VM) image for peer pods, you must verify that the image ID in the peer pods config map is empty before the Operator populates it with the image URI.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Obtain the value of the PODVM_AMI_ID in the peer pods config map by running the following command:
$ oc get configmap -n openshift-sandboxed-containers-operator peer-pods-cm -o jsonpath="{.data.PODVM_AMI_ID}"If the value is not empty, update the value and patch the config map by running the following command:
$ oc patch configmap peer-pods-cm -n openshift-sandboxed-containers-operator -p '{"data":{"PODVM_AMI_ID":""}}'
Verification
Verify that the image ID value is empty by running the following command:
$ oc get configmap -n openshift-sandboxed-containers-operator peer-pods-cm \ -o jsonpath="{.data.PODVM_AMI_ID}"If the image ID value is empty, the command returns no output.
Additional resources
5.4. Create the KataConfig custom resource
You must create the KataConfig custom resource (CR) to install kata-remote as a runtime class on your worker nodes.
Prerequisites
-
Be aware that creating the
KataConfigCR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes depending on your deployment size, hardware type, and other factors.
Procedure
Create an
example-kataconfig.yamlmanifest file according to the following example:apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
<label_key>: '<label_value>'-
Optional: If you have applied node labels to install
kata-remoteon specific nodes, specify the key and value, for example,kata-remote: 'true'.
Create the
KataConfigCR by running the following command:$ oc create -f example-kataconfig.yaml
The new
KataConfigCR is created and installskata-remoteas a runtime class on the worker nodes.Wait for the
kata-remoteinstallation to complete and the worker nodes to reboot before verifying the installation.Optional: Monitor the installation progress by running the following command:
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodesisinstalledand the conditionInProgressisFalsewithout specifying a reason, thekata-remoteis installed on the cluster.
Verification
Verify the daemon set by running the following command:
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
$ oc get runtimeclass
NAME HANDLER AGE kata kata 34m kata-nvidia-gpu kata-nvidia-gpu 34m kata-remote kata-remote 152m
You can also see the default
kataruntime class in addition tokata-remote.
Chapter 6. Uninstallation
You uninstall OpenShift sandboxed containers by deleting the workload pods, uninstalling the OpenShift sandboxed containers Operator, and deleting its resources.
You perform the following tasks:
Delete pods that use the
kata-remoteruntime class.ImportantYou must delete the workload pods before you delete the
KataConfigCR. The pod names usually have the prefixpodvmand custom tags, if provided.-
Delete the
KataConfigcustom resource (CR). - Uninstall the OpenShift sandboxed containers Operator.
-
Delete the
KataConfigcustom resource definition (CRD).
6.1. Delete workload pods
You must delete your workload pods. The pod names usually have the prefix podvm and custom tags, if provided.
Prerequisites
-
You have installed the
jqutility.
Procedure
Search for the pods by running the following command:
$ oc get pods -A -o json | jq -r '.items[] | select(.spec.runtimeClassName == "kata-remote").metadata.name'
Delete each pod by running the following command:
$ oc delete pod <pod>
Verification
Verify that the pods using the
kata-remoteruntime class are no longer running by running the following command:$ oc get pods -A -o json | jq -r '.items[] | select(.spec.runtimeClassName == "kata-remote").metadata.name'
Confirm that the command returns no output.
Additional resources
6.2. Delete the KataConfig custom resource
You must delete the KataConfig custom resource (CR).
Deleting the KataConfig CR automatically reboots the worker nodes. Reboot can take from 10 to 60 minutes. The following factors can affect the reboot time:
- A larger OpenShift Container Platform deployment with a greater number of worker nodes.
- Activation of the BIOS and Diagnostics utility.
- Deployment on a hard drive rather than an SSD.
- Deployment on physical nodes such as bare metal, rather than on virtual nodes.
- A slow central processing unit (CPU) and network.
Prerequisites
-
You have deleted all pods that use the
kata-remoteruntime class.
Procedure
Delete the
KataConfigCR by running the following command:$ oc delete kataconfig example-kataconfig
The OpenShift sandboxed containers Operator removes all resources that were initially created to enable the runtime on your cluster.
ImportantWhen you delete the
KataConfigCR, the command-line interface (CLI) stops responding until all worker nodes reboot. You must wait for the deletion process to complete before performing the verification.
Verification
Confirm that the
KataConfigCR no longer exists by running the following command:$ oc get kataconfig example-kataconfig
Error from server (NotFound): kataconfigs.kataconfiguration.openshift.io "example-kataconfig" not found
Additional resources
6.3. Uninstall the OpenShift sandboxed containers Operator
You uninstall the OpenShift sandboxed containers Operator by using the command line.
Prerequisites
-
You have deleted all pods with the
kata-remoteruntime class.
Procedure
Delete the subscription by running the following command:
$ oc delete subscription sandboxed-containers-operator -n openshift-sandboxed-containers-operator
Delete the namespace by running the following command:
$ oc delete namespace openshift-sandboxed-containers-operator
Additional resources
6.4. Delete the KataConfig CRD
You must delete the KataConfig custom resource definition (CRD).
Procedure
Delete the
KataConfigCRD by running the following command:$ oc delete crd kataconfigs.kataconfiguration.openshift.io
Verification
Confirm that the
KataConfigCRD no longer exists by running the following command:$ oc get crd kataconfigs.kataconfiguration.openshift.io
Error from server (NotFound): customresourcedefinitions.apiextensions.k8s.io "kataconfigs.kataconfiguration.openshift.io" not found
Additional resources
Chapter 7. Observability
You can monitor the health of your OpenShift sandboxed containers environment.
The following tools are available:
- OpenShift Container Platform web console. Administrators can access and query raw metrics through Prometheus.
- Logging
7.1. Metrics
You can monitor system health by querying metrics displayed in the OpenShift Container Platform web console.
You can access the following metrics:
- Kata agent metrics
-
Kata agent metrics display information about the kata agent process running in the virtual machine (VM) embedded in your sandboxed containers. These metrics include data from
/proc/<pid>/[io, stat, status]. - Kata guest operating system metrics
-
Kata guest operating system metrics display data from the guest operating system running in your sandboxed containers. These metrics include data from
/proc/[stats, diskstats, meminfo, vmstats]and/proc/net/dev. - Hypervisor metrics
-
Hypervisor metrics display data regarding the hypervisor running the VM embedded in your sandboxed containers. These metrics mainly include data from
/proc/<pid>/[io, stat, status]. - Kata monitor metrics
- Kata monitor is the process that gathers metric data and makes it available to Prometheus. The kata monitor metrics display detailed information about the resource usage of the kata-monitor process itself. These metrics also include counters from Prometheus data collection.
- Kata containerd shim v2 metrics
-
Kata containerd shim v2 metrics display detailed information about the kata shim process. These metrics include data from
/proc/<pid>/[io, stat, status]and detailed resource usage metrics.
7.2. View OpenShift sandboxed containers metrics
You can access the metrics for OpenShift sandboxed containers in the Metrics page in the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole or with view permissions for all projects.
Procedure
- In the OpenShift Container Platform web console, navigate to Observe → Metrics.
In the input field, enter the query for the metric you want to observe.
All kata-related metrics begin with kata. Typing kata displays a list of all available kata metrics.
The metrics from your query are visualized on the page.
Troubleshooting
If no metrics are shown, verify that the query begins with
kataand confirm that OpenShift sandboxed containers workloads are running. To do so, check whether any pods use akataruntime class:$ oc get pods -A -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.runtimeClassName}{"\n"}{end}' | grep kataIf no pods are using a
kataruntime class, the cluster generates no OpenShift sandboxed containers metrics.
7.3. Enable debug logs for CRI-O runtime
You can enable debug logs by updating the logLevel field in the KataConfig custom resource (CR). This changes the log level in the Container Runtime Interface (CRI-O) runtime for the worker nodes running OpenShift sandboxed containers.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Change the
logLevelfield in your existingKataConfigCR todebug:$ oc patch kataconfig <kataconfig> --type merge --patch '{"spec":{"logLevel":"debug"}}'Monitor the
kata-ocmachine config pool until the value ofUPDATEDisTrue, indicating that all worker nodes are updated:$ oc get mcp kata-oc
Example output
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE kata-oc rendered-kata-oc-169 False True False 3 1 1 0 9h
Verification
Start a debug session with a node in the machine config pool:
$ oc debug node/<node_name>
Change the root directory to
/host:# chroot /host
Verify the changes in the
crio.conffile:# crio config | egrep 'log_level
Example output
log_level = "debug"
Additional resources
7.4. View debug logs for OpenShift sandboxed containers components
Cluster administrators can use the debug logs to troubleshoot issues. The logs for each node are printed to the node journal.
You can review the logs for the following OpenShift sandboxed containers components:
- Kata agent
-
Kata runtime (
containerd-shim-kata-v2) -
virtiofsd
Quick Emulator (QEMU) only generates warning and error logs. These warnings and errors print to the node journal in both the Kata runtime logs and the Container Runtime Interface (CRI-O) logs with an extra qemuPid field.
Example of QEMU logs:
Mar 11 11:57:28 openshift-worker-0 kata[2241647]: time="2023-03-11T11:57:28.587116986Z" level=info msg="Start logging QEMU (qemuPid=2241693)" name=containerd-shim-v2 pid=2241647 sandbox=d1d4d68efc35e5ccb4331af73da459c13f46269b512774aa6bde7da34db48987 source=virtcontainers/hypervisor subsystem=qemu Mar 11 11:57:28 openshift-worker-0 kata[2241647]: time="2023-03-11T11:57:28.607339014Z" level=error msg="qemu-kvm: -machine q35,accel=kvm,kernel_irqchip=split,foo: Expected '=' after parameter 'foo'" name=containerd-shim-v2 pid=2241647 qemuPid=2241693 sandbox=d1d4d68efc35e5ccb4331af73da459c13f46269b512774aa6bde7da34db48987 source=virtcontainers/hypervisor subsystem=qemu Mar 11 11:57:28 openshift-worker-0 kata[2241647]: time="2023-03-11T11:57:28.60890737Z" level=info msg="Stop logging QEMU (qemuPid=2241693)" name=containerd-shim-v2 pid=2241647 sandbox=d1d4d68efc35e5ccb4331af73da459c13f46269b512774aa6bde7da34db48987 source=virtcontainers/hypervisor subsystem=qemu
The Kata runtime prints Start logging QEMU when QEMU starts, and Stop Logging QEMU when QEMU stops. The error appears in between these two log messages with the qemuPid field. The actual error message from QEMU appears in red.
The console of the QEMU guest is printed to the node journal as well. You can view the guest console logs together with the Kata agent logs.
Prerequisites
-
You have workloads running with the
kata-remoteruntime class. -
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
To review the Kata agent logs and guest console logs, run the following command:
$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata -g “reading guest console”
To review the Kata runtime logs, run the following command:
$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata
To review the
virtiofsdlogs, run the following command:$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t virtiofsd
To review the QEMU logs, run the following command:
$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata -g "qemuPid=\d+"
NoteThis command uses a Perl-compatible regular expression (PCRE). If the command returns no output, confirm that QEMU is in use on the node before assuming a pattern-matching failure.
Verification
-
Verify that the output of each
oc debugcommand in the previous steps contains timestamped log entries with alevel=field. This indicates that the component is logging to the node journal. -
If a command returns no output, verify that the node is running workloads that use the
kata-remoteruntime class, or that QEMU is in use on the node before assuming a pattern-matching failure.
Chapter 8. Troubleshooting
You can open a Red Hat support case and provide debugging information by using must-gather. The must-gather tool collects diagnostic information about your OpenShift Container Platform cluster, including virtual machines and other data.
8.1. Use the must-gather utility
If you must open a Red Hat support case, you must use the must-gather utility to collect diagnostic information about your OpenShift Container Platform cluster, including virtual machines and other data. The oc adm must-gather command collects the information from your cluster for debugging issues, including resource definitions and service logs. By default, the oc adm must-gather command uses the default plugin image and writes into ./must-gather.local.
To collect data related to one or more specific features, use the
--imageargument:$ oc adm must-gather --image=registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel9:1.13.1
To collect audit logs, use the
-- /usr/bin/gather_audit_logsargument:$ oc adm must-gather -- /usr/bin/gather_audit_logs
NoteAudit logs are not collected as part of the default set of information to reduce the size of the files.
When you run
oc adm must-gather, a new pod with a random name is created in a new project on the cluster. The data is collected on that pod and saved in a new directory that starts withmust-gather.local. This directory is created in the current working directory.NAMESPACE NAME READY STATUS RESTARTS AGE ... openshift-must-gather-5drcj must-gather-bklx4 2/2 Running 0 72s openshift-must-gather-5drcj must-gather-s8sdh 2/2 Running 0 72s ...
Optionally, you can run the
oc adm must-gathercommand in a specific namespace by using the--run-namespaceoption.$ oc adm must-gather --run-namespace <namespace> --image=registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel9:1.13.1
Chapter 9. KataConfig status messages
The following table displays the status messages for the KataConfig custom resource (CR) for a cluster with two worker nodes.
Table 9.1. KataConfig status messages
| Status | Description |
|---|---|
| Initial installation
When a |
conditions:
message: Performing initial installation of kata-remote on cluster
reason: Installing
status: 'True'
type: InProgress
kataNodes:
nodeCount: 0
readyNodeCount: 0 |
| Installing Within a few seconds the status changes. |
kataNodes: nodeCount: 2 readyNodeCount: 0 waitingToInstall: - worker-0 - worker-1 |
| Installing (Worker-1 installation starting)
For a short period of time, the status changes, signifying that one node has initiated the installation of |
kataNodes: installing: - worker-1 nodeCount: 2 readyNodeCount: 0 waitingToInstall: - worker-0 |
| Installing (Worker-1 installed, worker-0 installation started)
After some time, |
kataNodes: installed: - worker-1 installing: - worker-0 nodeCount: 2 readyNodeCount: 1 |
| Installed
When installed, both workers are listed as installed, and the |
conditions:
message: ""
reason: ""
status: 'False'
type: InProgress
kataNodes:
installed:
- worker-0
- worker-1
nodeCount: 2
readyNodeCount: 2 |
| Status | Description |
|---|---|
| Initial uninstall
If |
conditions:
message: Removing kata-remote from cluster
reason: Uninstalling
status: 'True'
type: InProgress
kataNodes:
nodeCount: 0
readyNodeCount: 0
waitingToUninstall:
- worker-0
- worker-1 |
| Uninstalling After a few seconds, one of the workers starts uninstalling. |
kataNodes: nodeCount: 0 readyNodeCount: 0 uninstalling: - worker-1 waitingToUninstall: - worker-0 |
| Uninstalling Worker-1 finishes and worker-0 starts uninstalling. |
kataNodes: nodeCount: 0 readyNodeCount: 0 uninstalling: - worker-0 |
The reason field can also report the following causes:
-
Failed: This is reported if the node cannot finish its transition. ThestatusreportsTrueand themessageisNode <node_name> Degraded: <error_message_from_the_node>. -
BlockedByExistingKataPods: This is reported if there are pods running on a cluster that use thekata-remoteruntime whilekata-remoteis being uninstalled. Thestatusfield isFalseand themessageisExisting pods using "kata-remote" RuntimeClass found. Please delete the pods manually for KataConfig deletion to proceed. There could also be a technical error message reported likeFailed to list kata pods: <error_message>if communication with the cluster control plane fails.