User guide
Deploying sandboxed containers in OpenShift Container Platform
Abstract
Preface
Providing feedback on Red Hat documentation
You can provide feedback or report an error by submitting the Create Issue form in Jira. The Jira issue will be created in the Red Hat Hybrid Cloud Infrastructure Jira project, where you can track the progress of your feedback.
- Ensure that you are logged in to Jira. If you do not have a Jira account, you must create a Red Hat Jira account.
- Launch the Create Issue form.
Complete the Summary, Description, and Reporter fields.
In the Description field, include the documentation URL, chapter or section number, and a detailed description of the issue.
- Click Create.
Chapter 1. About OpenShift sandboxed containers
OpenShift sandboxed containers for 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.
1.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-uid
root 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 tree
or 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, may not want their custom settings interfering with packet tuning or with
sysctl
variables 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_ADMIN
orCAP_BPF
privileges, 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 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.
1.2. Compatibility with OpenShift Container Platform
The required functionality for the OpenShift Container Platform platform is supported by two main components:
- Kata runtime: This includes Red Hat Enterprise Linux CoreOS (RHCOS) and updates with every OpenShift Container Platform release.
-
OpenShift sandboxed containers Operator: Install the Operator using either the web console or OpenShift CLI (
oc
).
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. For more information, see OpenShift Container Platform Life Cycle Policy for additional details.
The Operator depends on the features that come with the RHCOS host and the environment it runs in.
You must install Red Hat Enterprise Linux CoreOS (RHCOS) on the worker nodes. RHEL nodes are not supported.
The following compatibility matrix for OpenShift sandboxed containers and OpenShift Container Platform releases identifies compatible features and environments.
Architecture | OpenShift Container Platform version |
---|---|
x86_64 | 4.8 or later |
s390x | 4.14 or later |
There are two ways to deploy Kata containers runtime:
- Bare metal
- Peer pods
Peer pods technology for the deployment of OpenShift sandboxed containers in public clouds was available as Developer Preview in OpenShift sandboxed containers 1.5 and OpenShift Container Platform 4.14.
With the release of OpenShift sandboxed containers 1.7, the Operator requires OpenShift Container Platform version 4.15 or later.
Feature | Deployment method | OpenShift Container Platform 4.15 | OpenShift Container Platform 4.16 |
---|---|---|---|
Confidential Containers | Bare metal | ||
Peer pods | Technology Preview | Technology Preview [1] | |
GPU support [2] | Bare metal | ||
Peer pods | Developer Preview | Developer Preview |
- Technology Preview of Confidential Containers has been available since OpenShift sandboxed containers 1.7.0.
- GPU functionality is not available on IBM Z.
Platform | GPU | Confidential Containers |
---|---|---|
AWS Cloud Computing Services | Developer Preview | |
Microsoft Azure Cloud Computing Services | Developer Preview | Technology Preview [1] |
- Technology Preview of Confidential Containers has been available since OpenShift sandboxed containers 1.7.0.
Additional resources
1.3. Node eligibility checks
You can verify that your bare-metal cluster nodes support OpenShift sandboxed containers by running a node eligibility check. The most common reason for node ineligibility is lack of virtualization support. If you run sandboxed workloads on ineligible nodes, you will experience errors.
High-level workflow
- Install the Node Feature Discovery Operator.
-
Create the
NodeFeatureDiscovery
custom resource (CR). -
Enable node eligibility checks when you create the
Kataconfig
CR. You can run node eligibility checks on all worker nodes or on selected nodes.
Additional resources
1.4. Common terms
The following terms are used throughout the documentation.
- 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.
- 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 of 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.
- OpenShift sandboxed containers Operator
- The OpenShift sandboxed containers Operator manages the lifecycle of sandboxed containers on a cluster. You can use the OpenShift sandboxed containers Operator to perform tasks such as the installation and removal of sandboxed containers, software updates, and status monitoring.
- Kata Containers
- Kata Containers is a core upstream project that is used to build OpenShift sandboxed containers. OpenShift sandboxed containers integrate Kata Containers with OpenShift Container Platform.
- KataConfig
-
KataConfig
objects represent configurations of sandboxed containers. They store information about the state of the cluster, such as the nodes on which the software is deployed. - Runtime class
-
A
RuntimeClass
object describes which runtime can be used to run a given workload. A runtime class that is namedkata
is installed and deployed by the OpenShift sandboxed containers Operator. The runtime class contains information about the runtime that describes resources that the runtime needs to operate, such as the pod overhead.
- 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.
- IBM Secure Execution
- IBM Secure Execution for Linux is an advanced security feature introduced with IBM z15® and LinuxONE III. This feature extends the protection provided by pervasive encryption. IBM Secure Execution safeguards data at rest, in transit, and in use. It enables secure deployment of workloads and ensures data protection throughout its lifecycle. For more information, see Introducing IBM Secure Execution for Linux.
- Confidential Containers
Confidential Containers protects containers and data by verifying that your workload is running in a Trusted Execution Environment (TEE). You can deploy this feature to safeguard the privacy of big data analytics and machine learning inferences.
Trustee is a component of Confidential Containers. 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. Trustee includes components deployed on a trusted side and used to verify whether the remote workload is running in a Trusted Execution Environment (TEE). Trustee is flexible and can be deployed in several different configurations to support a wide variety of applications and hardware platforms.
- Confidential compute attestation Operator
- The Confidential compute attestation Operator manages the installation, lifecycle, and configuration of Confidential Containers.
1.5. 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 OLM-ready.
-
The second container image contains the actual controller that monitors and manages the
KataConfig
resource.
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, QEMU, and its dependencies. You can enable them by using the MachineConfig
resources that the Machine Config Operator provides.
Additional resources
1.6. About Confidential Containers
Confidential Containers provides a confidential computing environment to protect containers and data by leveraging Trusted Execution Environments.
Confidential Containers on Microsoft Azure Cloud Computing Services, IBM Z®, and IBM® LinuxONE 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.
You can sign container images by using a tool such as Red Hat Trusted Artifact Signer. Then, you create a container image signature verification policy.
The Trustee Operator verifies the signatures, ensuring that only trusted and authenticated container images are deployed in your environment.
For more information, see Exploring the OpenShift Confidential Containers solution.
1.7. 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. See About live migration in the OpenShift Virtualization documentation for details.
1.8. Block volume support
OpenShift Container Platform can statically provision raw block volumes. These volumes do not have a file system, and can provide performance benefits for applications that either write to the disk directly or implement their own storage service.
You can use a local block device as persistent volume (PV) storage with OpenShift sandboxed containers. This block device can be provisioned by using the Local Storage Operator (LSO).
The Local Storage Operator is not installed in OpenShift Container Platform by default. See Installing the Local Storage Operator for installation instructions.
You can provision raw block volumes for OpenShift sandboxed containers by specifying volumeMode: Block
in the PV specification.
Block volume example
apiVersion: "local.storage.openshift.io/v1" kind: "LocalVolume" metadata: name: "local-disks" namespace: "openshift-local-storage" spec: nodeSelector: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - worker-0 storageClassDevices: - storageClassName: "local-sc" forceWipeDevicesAndDestroyAllData: false volumeMode: Block devicePaths: - /path/to/device
apiVersion: "local.storage.openshift.io/v1"
kind: "LocalVolume"
metadata:
name: "local-disks"
namespace: "openshift-local-storage"
spec:
nodeSelector:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- worker-0
storageClassDevices:
- storageClassName: "local-sc"
forceWipeDevicesAndDestroyAllData: false
volumeMode: Block
devicePaths:
- /path/to/device
- 1
- Set
volumeMode
toBlock
to indicate that this PV is a raw block volume. - 2
- Replace this value with the filepath to your
LocalVolume
resourceby-id
. PVs are created for these local disks when the provisioner is deployed successfully. You must also use this path to label the node that uses the block device when deploying OpenShift sandboxed containers.
1.9. FIPS compliance
OpenShift Container Platform is designed for Federal Information Processing Standards (FIPS) 140-2 and 140-3. When running Red Hat Enterprise Linux (RHEL) or Red Hat Enterprise Linux CoreOS (RHCOS) booted in FIPS mode, OpenShift Container Platform core components use the RHEL cryptographic libraries that have been submitted to NIST for FIPS 140-2/140-3 Validation on only the x86_64
, ppc64le
, and s390x
architectures.
For more information about the NIST validation program, see Cryptographic Module Validation Program. For the latest NIST status for the individual versions of RHEL cryptographic libraries that have been submitted for validation, see Compliance Activities and Government Standards.
OpenShift sandboxed containers can be used on FIPS enabled clusters.
When running in FIPS mode, OpenShift sandboxed containers components, VMs, and VM images are adapted to comply with FIPS.
FIPS compliance for OpenShift sandboxed containers only applies to the kata
runtime class. The peer pod runtime class, kata-remote
, is not yet fully supported and has not been tested for FIPS compliance.
FIPS compliance is one of the most critical components required in highly secure environments, to ensure that only supported cryptographic technologies are allowed on nodes.
The use of FIPS Validated / Modules in Process cryptographic libraries is only supported on OpenShift Container Platform deployments on the x86_64
architecture.
To understand Red Hat’s view of OpenShift Container Platform compliance frameworks, refer to the Risk Management and Regulatory Readiness chapter of the OpenShift Security Guide Book.
Chapter 2. Deploying OpenShift sandboxed containers on bare metal
You can deploy OpenShift sandboxed containers on an on-premise bare-metal cluster with Red Hat Enterprise Linux CoreOS (RHCOS) installed on the worker nodes.
- RHEL nodes are not supported.
- Nested virtualization is not supported.
You can use any installation method including user-provisioned, installer-provisioned, or Assisted Installer to deploy your cluster.
You can also install OpenShift sandboxed containers on Amazon Web Services (AWS) bare-metal instances. Bare-metal instances offered by other cloud providers are not supported.
Cluster requirements
- You have installed Red Hat OpenShift Container Platform 4.14 or later on the cluster where you are installing the OpenShift sandboxed containers Operator.
- Your cluster has at least one worker node.
For details on installing OpenShift Container Platform on bare metal see Installing on bare metal.
2.1. OpenShift sandboxed containers resource requirements
You must ensure that your cluster has sufficient resources.
OpenShift sandboxed containers lets users run workloads on their OpenShift Container Platform 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-v2
is used to communicate with the pod. -
virtiofsd
handles 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
virtiofsd
daemon 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
kind: RuntimeClass apiVersion: node.k8s.io/v1 metadata: name: kata overhead: podFixed: memory: "500Mi" cpu: "500m"
kind: RuntimeClass
apiVersion: node.k8s.io/v1
metadata:
name: kata
overhead:
podFixed:
memory: "500Mi"
cpu: "500m"
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 used in all three cases. Therefore, the total memory usage is only 300Mi, mapped in three different places. This is correctly accounted for when reporting the memory utilization metrics.
2.2. Deploying OpenShift sandboxed containers by using the web console
You can deploy OpenShift sandboxed containers on bare metal by using the OpenShift Container Platform web console to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Install the Node Feature Discovery (NFD) Operator to configure node eligibility checks. For more information, see node eligibility checks and the NFD Operator documentation.
- Optional: Customize the Kata agent policy.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
2.2.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
- In the web console, navigate to Operators → OperatorHub.
-
In the Filter by keyword field, type
OpenShift sandboxed containers
. - Select the OpenShift sandboxed containers Operator tile 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-operator
namespace. 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-operator
causes 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.
- Navigate to Operators → Installed Operators to verify that the Operator is installed.
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
2.2.2. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
2.2.3. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata
as a RuntimeClass
on your worker nodes.
The kata
runtime class is installed on all worker nodes by default. If you want to install kata
on specific nodes, you can add labels to those nodes and then define the label in the KataConfig
CR.
OpenShift sandboxed containers installs kata
as a secondary, optional runtime on the cluster and not as the primary runtime.
Creating the KataConfig
CR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes. The following factors might increase 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 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 access to the cluster as a user with the
cluster-admin
role. - Optional: You have installed the Node Feature Discovery Operator if you want to enable node eligibility checks.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator.
- On the KataConfig tab, click Create KataConfig.
Enter the following details:
-
Name: Optional: The default name is
example-kataconfig
. -
Labels: Optional: Enter any relevant, identifying attributes to the
KataConfig
resource. Each label represents a key-value pair. - checkNodeEligibility: Optional: Select to use the Node Feature Discovery Operator (NFD) to detect node eligibility.
kataConfigPoolSelector. Optional: To install
kata
on selected nodes, add a match expression for the labels on the selected nodes:- Expand the kataConfigPoolSelector area.
- In the kataConfigPoolSelector area, expand matchExpressions. This is a list of label selector requirements.
- Click Add matchExpressions.
- In the Key field, enter the label key the selector applies to.
-
In the Operator field, enter 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
true
orfalse
for key label value.
-
logLevel: Define the level of log data retrieved for nodes with the
kata
runtime class.
-
Name: Optional: The default name is
Click Create. The
KataConfig
CR is created and installs thekata
runtime class on the worker nodes.Wait for the
kata
installation to complete and the worker nodes to reboot before verifying the installation.
Verification
-
On the KataConfig tab, click the
KataConfig
CR to view its details. Click the YAML tab to view the
status
stanza.The
status
stanza contains theconditions
andkataNodes
keys. The value ofstatus.kataNodes
is an array of nodes, each of which lists nodes in a particular state ofkata
installation. A message appears each time there is an update.Click Reload to refresh the YAML.
When all workers in the
status.kataNodes
array display the valuesinstalled
andconditions.InProgress: False
with no specified reason, thekata
is installed on the cluster.
Additional resources
2.2.4. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
Do not deploy workloads in an Operator namespace. Create a dedicated namespace for these resources.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
- In the OpenShift Container Platform web console, navigate to Workloads → workload type, for example, Pods.
- On the workload type page, click an object to view its details.
- Click the YAML tab.
Add
spec.runtimeClassName: kata
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata # ...
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata
, then the workload is running on OpenShift sandboxed containers, using peer pods.
2.3. Deploying OpenShift sandboxed containers by using the command line
You can deploy OpenShift sandboxed containers on bare metal by using the command line interface (CLI) to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
After installing the Operator, you can configure the following options:
- Configure a block storage device.
Install the Node Feature Discovery (NFD) Operator to configure node eligibility checks. For more information, see node eligibility checks and the NFD Operator documentation.
-
Create a
NodeFeatureDiscovery
custom resource.
-
Create a
- Optional: Customize the Kata agent policy.
-
Create the
KataConfig
custom resource. - Optional: Modify the pod overhead.
- Configure the OpenShift sandboxed containers workload objects.
2.3.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
osc-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
Create the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-namespace.yaml
$ oc apply -f osc-namespace.yaml
Create an
osc-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: sandboxed-containers-operator-group namespace: openshift-sandboxed-containers-operator spec: targetNamespaces: - openshift-sandboxed-containers-operator
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-operatorgroup.yaml
$ oc apply -f osc-operatorgroup.yaml
Create an
osc-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.9.0
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.9.0
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-subscription.yaml
$ oc apply -f osc-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n openshift-sandboxed-containers-operator
$ watch oc get csv -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
2.3.2. Optional configurations
You can configure the following options after you install the OpenShift sandboxed containers Operator.
2.3.2.1. Provisioning local block volumes
You can use local block volumes with OpenShift sandboxed containers. You must first provision the local block volumes by using the Local Storage Operator (LSO). Then you must enable the nodes with the local block volumes to run OpenShift sandboxed containers workloads.
You can provision local block volumes for OpenShift sandboxed containers by using the Local Storage Operator (LSO). The local volume provisioner looks for any block volume devices at the paths specified in the defined resource.
Prerequisites
- You have installed the Local Storage Operator.
You have a local disk that meets the following conditions:
- It is attached to a node.
- It is not mounted.
- It does not contain partitions.
Procedure
Create the local volume resource. This resource must define the nodes and paths to the local volumes.
NoteDo not use different storage class names for the same device. Doing so creates multiple persistent volumes (PVs).
Example: Block
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: "local.storage.openshift.io/v1" kind: "LocalVolume" metadata: name: "local-disks" namespace: "openshift-local-storage" spec: nodeSelector: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - ip-10-0-136-143 - ip-10-0-140-255 - ip-10-0-144-180 storageClassDevices: - storageClassName: "local-sc" forceWipeDevicesAndDestroyAllData: false volumeMode: Block devicePaths: - /path/to/device
apiVersion: "local.storage.openshift.io/v1" kind: "LocalVolume" metadata: name: "local-disks" namespace: "openshift-local-storage"
1 spec: nodeSelector:
2 nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - ip-10-0-136-143 - ip-10-0-140-255 - ip-10-0-144-180 storageClassDevices: - storageClassName: "local-sc"
3 forceWipeDevicesAndDestroyAllData: false
4 volumeMode: Block devicePaths:
5 - /path/to/device
6 - 1
- The namespace where the Local Storage Operator is installed.
- 2
- Optional: A node selector containing a list of nodes where the local storage volumes are attached. This example uses the node hostnames, obtained from
oc get node
. If a value is not defined, then the Local Storage Operator will attempt to find matching disks on all available nodes. - 3
- The name of the storage class to use when creating persistent volume objects.
- 4
- This setting defines whether or not to call
wipefs
, which removes partition table signatures (magic strings) making the disk ready to use for Local Storage Operator provisioning. No other data besides signatures is erased. The default is "false" (wipefs
is not invoked). SettingforceWipeDevicesAndDestroyAllData
to "true" can be useful in scenarios where previous data can remain on disks that need to be re-used. In these scenarios, setting this field to true eliminates the need for administrators to erase the disks manually. - 5
- The path containing a list of local storage devices to choose from. You must use this path when enabling a node with a local block device to run OpenShift sandboxed containers workloads.
- 6
- Replace this value with the filepath to your
LocalVolume
resourceby-id
, such as/dev/disk/by-id/wwn
. PVs are created for these local disks when the provisioner is deployed successfully.
Create the local volume resource in your OpenShift Container Platform cluster. Specify the file you just created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f <local-volume>.yaml
$ oc apply -f <local-volume>.yaml
Verify that the provisioner was created and that the corresponding daemon sets were created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get all -n openshift-local-storage
$ oc get all -n openshift-local-storage
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME READY STATUS RESTARTS AGE pod/diskmaker-manager-9wzms 1/1 Running 0 5m43s pod/diskmaker-manager-jgvjp 1/1 Running 0 5m43s pod/diskmaker-manager-tbdsj 1/1 Running 0 5m43s pod/local-storage-operator-7db4bd9f79-t6k87 1/1 Running 0 14m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/local-storage-operator-metrics ClusterIP 172.30.135.36 <none> 8383/TCP,8686/TCP 14m NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE daemonset.apps/diskmaker-manager 3 3 3 3 3 <none> 5m43s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/local-storage-operator 1/1 1 1 14m NAME DESIRED CURRENT READY AGE replicaset.apps/local-storage-operator-7db4bd9f79 1 1 1 14m
NAME READY STATUS RESTARTS AGE pod/diskmaker-manager-9wzms 1/1 Running 0 5m43s pod/diskmaker-manager-jgvjp 1/1 Running 0 5m43s pod/diskmaker-manager-tbdsj 1/1 Running 0 5m43s pod/local-storage-operator-7db4bd9f79-t6k87 1/1 Running 0 14m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/local-storage-operator-metrics ClusterIP 172.30.135.36 <none> 8383/TCP,8686/TCP 14m NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE daemonset.apps/diskmaker-manager 3 3 3 3 3 <none> 5m43s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/local-storage-operator 1/1 1 1 14m NAME DESIRED CURRENT READY AGE replicaset.apps/local-storage-operator-7db4bd9f79 1 1 1 14m
Note the
desired
andcurrent
number of daemon set processes. Adesired
count of0
indicates that the label selectors were invalid.Verify that the persistent volumes were created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pv
$ oc get pv
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE local-pv-1cec77cf 100Gi RWO Delete Available local-sc 88m local-pv-2ef7cd2a 100Gi RWO Delete Available local-sc 82m local-pv-3fa1c73 100Gi RWO Delete Available local-sc 48m
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE local-pv-1cec77cf 100Gi RWO Delete Available local-sc 88m local-pv-2ef7cd2a 100Gi RWO Delete Available local-sc 82m local-pv-3fa1c73 100Gi RWO Delete Available local-sc 48m
Editing the LocalVolume
object does not change existing persistent volumes because doing so might result in a destructive operation.
2.3.2.2. Enabling nodes to use a local block device
You can configure nodes with a local block device to run OpenShift sandboxed containers workloads at the paths specified in the defined volume resource.
Prerequisites
- You provisioned a block device using the Local Storage Operator (LSO).
Procedure
Enable each node with a local block device to run OpenShift sandboxed containers workloads by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug node/worker-0 -- chcon -vt container_file_t /host/path/to/device
$ oc debug node/worker-0 -- chcon -vt container_file_t /host/path/to/device
The
/path/to/device
must be the same path you defined when creating the local storage resource.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow system_u:object_r:container_file_t:s0 /host/path/to/device
system_u:object_r:container_file_t:s0 /host/path/to/device
2.3.2.3. Creating a NodeFeatureDiscovery custom resource
You create a NodeFeatureDiscovery
custom resource (CR) to define the configuration parameters that the Node Feature Discovery (NFD) Operator checks to determine that the worker nodes can support OpenShift sandboxed containers.
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
CR.
To install the kata
runtime on all worker nodes, set checkNodeEligibility: false
in the KataConfig
CR.
In both these scenarios, you do not need to create the NodeFeatureDiscovery
CR. 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 OpenShift sandboxed 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
- You have installed the NFD Operator.
Procedure
Create an
nfd.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: nfd.openshift.io/v1 kind: NodeFeatureDiscovery metadata: name: nfd-kata namespace: openshift-nfd spec: workerConfig: configData: | sources: custom: - name: "feature.node.kubernetes.io/runtime.kata" matchOn: - cpuId: ["SSE4", "VMX"] loadedKMod: ["kvm", "kvm_intel"] - cpuId: ["SSE4", "SVM"] loadedKMod: ["kvm", "kvm_amd"] # ...
apiVersion: nfd.openshift.io/v1 kind: NodeFeatureDiscovery metadata: name: nfd-kata namespace: openshift-nfd spec: workerConfig: configData: | sources: custom: - name: "feature.node.kubernetes.io/runtime.kata" matchOn: - cpuId: ["SSE4", "VMX"] loadedKMod: ["kvm", "kvm_intel"] - cpuId: ["SSE4", "SVM"] loadedKMod: ["kvm", "kvm_amd"] # ...
Create the
NodeFeatureDiscovery
CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create -f nfd.yaml
$ oc create -f nfd.yaml
The
NodeFeatureDiscovery
CR applies thefeature.node.kubernetes.io/runtime.kata=true
label to all qualifying worker nodes.
Create a
kata-config.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: checkNodeEligibility: true
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: checkNodeEligibility: true
Create the
KataConfig
CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create -f kata-config.yaml
$ oc create -f kata-config.yaml
Verification
Verify that qualifying nodes in the cluster have the correct label applied:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get nodes --selector='feature.node.kubernetes.io/runtime.kata=true'
$ oc get nodes --selector='feature.node.kubernetes.io/runtime.kata=true'
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.0
2.3.3. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
2.3.4. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata
as a runtime class on your worker 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
RuntimeClass
CR namedkata
with a default configuration. This enables users to configure workloads to usekata
as the runtime by referencing the CR in theRuntimeClassName
field. This CR also specifies the resource overhead for the runtime.
OpenShift sandboxed containers installs kata
as a secondary, optional runtime on the cluster and not as the primary runtime.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role. - Optional: You have installed the Node Feature Discovery Operator if you want to enable node eligibility checks.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: checkNodeEligibility: false logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: checkNodeEligibility: false
1 logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
2 Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata
as a runtime class on the worker nodes.Wait for the
kata
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata
is installed on the cluster.
2.3.5. Modifying pod overhead
Pod overhead describes the amount of system resources that a pod on a node uses. You can modify the pod overhead by changing the spec.overhead
field for a RuntimeClass
custom resource. 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.
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. Therefore, the total memory usage is only 300Mi, mapped in three different places. This is correctly accounted for when reporting the memory utilization metrics.
The default values are supported by Red Hat. Changing default overhead values is not supported and can result in technical issues.
Procedure
Obtain the
RuntimeClass
object by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc describe runtimeclass kata
$ oc describe runtimeclass kata
Update the
overhead.podFixed.memory
andcpu
values and save as the file asruntimeclass.yaml
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow kind: RuntimeClass apiVersion: node.k8s.io/v1 metadata: name: kata overhead: podFixed: memory: "500Mi" cpu: "500m"
kind: RuntimeClass apiVersion: node.k8s.io/v1 metadata: name: kata overhead: podFixed: memory: "500Mi" cpu: "500m"
Apply the changes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f runtimeclass.yaml
$ oc apply -f runtimeclass.yaml
2.3.6. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
Do not deploy workloads in an Operator namespace. Create a dedicated namespace for these resources.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
Add
spec.runtimeClassName: kata
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata # ...
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata
, then the workload is running on OpenShift sandboxed containers, using peer pods.
Chapter 3. Deploying OpenShift sandboxed containers on AWS
You can deploy OpenShift sandboxed containers on AWS Cloud Computing Services by using the OpenShift Container Platform web console or the command line interface (CLI).
OpenShift sandboxed containers deploys peer pods. The peer pod design circumvents the need for nested virtualization. For more information, see peer pod and Peer pods technical deep dive.
Cluster requirements
- You have installed Red Hat OpenShift Container Platform 4.14 or later on the cluster where you are installing the OpenShift sandboxed containers Operator.
- Your cluster has at least one worker node.
For details on installing OpenShift Container Platform on AWS Cloud Computing Services see Installing on AWS.
3.1. Peer pod resource requirements
You must ensure that your cluster has sufficient resources.
Peer pod virtual machines (VMs) require resources in two locations:
-
The worker node. The worker node stores metadata, Kata shim resources (
containerd-shim-kata-v2
), remote-hypervisor resources (cloud-api-adaptor
), and the tunnel setup between the worker nodes and the peer pod VM. - The cloud instance. This is the actual peer pod VM running in the cloud.
The CPU and memory resources used in the Kubernetes worker node are handled by the pod overhead included in the RuntimeClass (kata-remote
) definition used for creating peer pods.
The total number of peer pod VMs running in the cloud is defined as Kubernetes Node extended resources. This limit is per node and is set by the PEERPODS_LIMIT_PER_NODE
attribute in the peer-pods-cm
config map.
The extended resource is named kata.peerpods.io/vm
, and enables the Kubernetes scheduler to handle capacity tracking and accounting.
You can edit the limit per node based on the requirements for your environment after you install the OpenShift sandboxed containers Operator.
A mutating webhook adds the extended resource kata.peerpods.io/vm
to the pod specification. It also removes any resource-specific entries from the pod specification, if present. This enables the Kubernetes scheduler to account for these extended resources, ensuring the peer pod is only scheduled when resources are available.
The mutating webhook modifies a Kubernetes pod as follows:
-
The mutating webhook checks the pod for the expected
RuntimeClassName
value, specified in theTARGET_RUNTIME_CLASS
environment variable. If the value in the pod specification does not match the value in theTARGET_RUNTIME_CLASS
, the webhook exits without modifying the pod. If the
RuntimeClassName
values match, the webhook makes the following changes to the pod spec:-
The webhook removes every resource specification from the
resources
field of all containers and init containers in the pod. -
The webhook adds the extended resource (
kata.peerpods.io/vm
) to the spec by modifying the resources field of the first container in the pod. The extended resourcekata.peerpods.io/vm
is used by the Kubernetes scheduler for accounting purposes.
-
The webhook removes every resource specification from the
The mutating webhook excludes specific system namespaces in OpenShift Container Platform from mutation. If a peer pod is created in those system namespaces, then resource accounting using Kubernetes extended resources does not work unless the pod spec includes the extended resource.
As a best practice, define a cluster-wide policy to only allow peer pod creation in specific namespaces.
3.2. Deploying OpenShift sandboxed containers by using the web console
You can deploy OpenShift sandboxed containers on AWS by using the OpenShift Container Platform web console to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Enable ports 15150 and 9000 to allow internal communication with peer pods.
- Optional: Create the peer pods secret if you uninstalled the Cloud Credential Operator, which is installed with the OpenShift sandboxed containers Operator.
- Optional: Select a custom pod VM image.
- Optional: Customize the Kata agent policy.
- Create the peer pods config map.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
3.2.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
- In the web console, navigate to Operators → OperatorHub.
-
In the Filter by keyword field, type
OpenShift sandboxed containers
. - Select the OpenShift sandboxed containers Operator tile 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-operator
namespace. 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-operator
causes 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.
- Navigate to Operators → Installed Operators to verify that the Operator is installed.
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
3.2.2. Enabling ports for AWS
You must enable ports 15150 and 9000 to allow internal communication with peer pods running on AWS.
Prerequisites
- You have installed the OpenShift sandboxed containers Operator.
- You have installed the AWS command line tool.
-
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Log in to your OpenShift Container Platform cluster and retrieve the instance ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' \ -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
$ INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' \ -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
Retrieve the AWS region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS_SG_IDS=($(aws ec2 describe-instances --instance-ids ${INSTANCE_ID} \ --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' \ --output text --region $AWS_REGION))
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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 \ done
$ 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 \ done
The ports are now enabled.
3.2.3. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
You have the following values generated by using the AWS console:
-
AWS_ACCESS_KEY_ID
-
AWS_SECRET_ACCESS_KEY
-
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Click the OpenShift sandboxed containers Operator tile.
- Click the Import icon (+) on the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AWS_ACCESS_KEY_ID: "<aws_access_key>" AWS_SECRET_ACCESS_KEY: "<aws_secret_access_key>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AWS_ACCESS_KEY_ID: "<aws_access_key>"
1 AWS_SECRET_ACCESS_KEY: "<aws_secret_access_key>"
2 - Click Save to apply the changes.
- Navigate to Workloads → Secrets to verify the peer pods secret.
3.2.4. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Prerequisites
- You have your Amazon Machine Image (AMI) ID if you are not using the default AMI ID based on your cluster credentials.
Procedure
Obtain the following values from your AWS instance:
Retrieve and record the instance ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
$ INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
This is used to retrieve other values for the secret object.
Retrieve and record the AWS region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.aws.region}') && echo "AWS_REGION: \"$AWS_REGION\""
$ AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.aws.region}') && echo "AWS_REGION: \"$AWS_REGION\""
Retrieve and record the AWS subnet ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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\""
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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\""
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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\""
$ 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\""
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "aws" VXLAN_PORT: "9000" PODVM_INSTANCE_TYPE: "t3.medium" PODVM_INSTANCE_TYPES: "t2.small,t2.medium,t3.large" PROXY_TIMEOUT: "5m" 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>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "aws" VXLAN_PORT: "9000" PODVM_INSTANCE_TYPE: "t3.medium"
1 PODVM_INSTANCE_TYPES: "t2.small,t2.medium,t3.large"
2 PROXY_TIMEOUT: "5m" PODVM_AMI_ID: "<podvm_ami_id>"
3 AWS_REGION: "<aws_region>"
4 AWS_SUBNET_ID: "<aws_subnet_id>"
5 AWS_VPC_ID: "<aws_vpc_id>"
6 AWS_SG_IDS: "<aws_sg_ids>"
7 PEERPODS_LIMIT_PER_NODE: "10"
8 TAGS: "key1=value1,key2=value2"
9 DISABLECVM: "true"
- 1
- Defines the default instance type that is used when a type is not defined in the workload.
- 2
- Lists all of the instance types you can specify when creating the pod. This allows you to define smaller instance types for workloads that need less memory and fewer CPUs or larger instance types for larger workloads.
- 3
- Optional: By default, this value is populated when you run the
KataConfig
CR, using an AMI ID based on your cluster credentials. If you create your own AMI, specify the correct AMI ID. - 4
- Specify the
AWS_REGION
value you retrieved. - 5
- Specify the
AWS_SUBNET_ID
value you retrieved. - 6
- Specify the
AWS_VPC_ID
value you retrieved. - 7
- Specify the
AWS_SG_IDS
value you retrieved. - 8
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 9
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters.
- Click Save to apply the changes.
- Navigate to Workloads → ConfigMaps to view the new config map.
3.2.5. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: 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"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<custom_image_id>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
- Click Save to apply the changes.
3.2.6. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest and add the Base64-encoded policy to it:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
- Click Save to apply the changes.
3.2.7. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a RuntimeClass
on your worker nodes.
The kata-remote
runtime class is installed on all worker nodes by default. If you want to install kata-remote
on specific nodes, you can add labels to those nodes and then define the label in the KataConfig
CR.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
Creating the KataConfig
CR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes. The following factors might increase 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 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 access to the cluster as a user with the
cluster-admin
role. - Optional: You have installed the Node Feature Discovery Operator if you want to enable node eligibility checks.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator.
- On the KataConfig tab, click Create KataConfig.
Enter the following details:
-
Name: Optional: The default name is
example-kataconfig
. -
Labels: Optional: Enter any relevant, identifying attributes to the
KataConfig
resource. Each label represents a key-value pair. - enablePeerPods: Select for public cloud, IBM Z®, and IBM® LinuxONE deployments.
kataConfigPoolSelector. Optional: To install
kata-remote
on selected nodes, add a match expression for the labels on the selected nodes:- Expand the kataConfigPoolSelector area.
- In the kataConfigPoolSelector area, expand matchExpressions. This is a list of label selector requirements.
- Click Add matchExpressions.
- In the Key field, enter the label key the selector applies to.
-
In the Operator field, enter 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
true
orfalse
for key label value.
-
logLevel: Define the level of log data retrieved for nodes with the
kata-remote
runtime class.
-
Name: Optional: The default name is
Click Create. The
KataConfig
CR is created and installs thekata-remote
runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.
Verification
-
On the KataConfig tab, click the
KataConfig
CR to view its details. Click the YAML tab to view the
status
stanza.The
status
stanza contains theconditions
andkataNodes
keys. The value ofstatus.kataNodes
is an array of nodes, each of which lists nodes in a particular state ofkata-remote
installation. A message appears each time there is an update.Click Reload to refresh the YAML.
When all workers in the
status.kataNodes
array display the valuesinstalled
andconditions.InProgress: False
with no specified reason, thekata-remote
is installed on the cluster.
Additional resources
Verifying the pod VM image
After kata-remote
is installed on your cluster, the OpenShift sandboxed containers Operator creates a pod VM image, which is used to create peer pods. This process can take a long time because the image is created on the cloud instance. You can verify that the pod VM image was created successfully by checking the config map that you created for the cloud provider.
Procedure
- Navigate to Workloads → ConfigMaps.
- Click the provider config map to view its details.
- Click the YAML tab.
Check the
status
stanza of the YAML file.If the
PODVM_AMI_ID
parameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
$ 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.
3.2.8. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
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 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.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
- In the OpenShift Container Platform web console, navigate to Workloads → workload type, for example, Pods.
- On the workload type page, click an object to view its details.
- Click the YAML tab.
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
Add an annotation to the pod-templated object to use a manually defined instance type or an automatic instance type:
To use a manually defined instance type, add the following annotation:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "t3.medium" # ...
apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "t3.medium"
1 # ...
To use an automatic instance type, add the following annotations:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
Define the amount of memory available for the workload to use. The workload will run on an automatic instance type based on the amount of memory available.
Click Save to apply the changes.
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
3.3. Deploying OpenShift sandboxed containers by using the command line
You can deploy OpenShift sandboxed containers on AWS by using the command line interface (CLI) to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Change the number of virtual machines running on each worker node.
- Optional: Enable ports 15150 and 9000 to allow internal communication with peer pods.
- Optional: Create the peer pods secret if you uninstalled the Cloud Credential Operator, which is installed with the OpenShift sandboxed containers Operator.
- Optional: Select a custom pod VM image.
- Create the peer pods config map.
- Optional: Customize the Kata agent policy.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
3.3.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
osc-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
Create the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-namespace.yaml
$ oc apply -f osc-namespace.yaml
Create an
osc-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: sandboxed-containers-operator-group namespace: openshift-sandboxed-containers-operator spec: targetNamespaces: - openshift-sandboxed-containers-operator
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-operatorgroup.yaml
$ oc apply -f osc-operatorgroup.yaml
Create an
osc-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.9.0
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.9.0
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-subscription.yaml
$ oc apply -f osc-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n openshift-sandboxed-containers-operator
$ watch oc get csv -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
3.3.2. Enabling ports for AWS
You must enable ports 15150 and 9000 to allow internal communication with peer pods running on AWS.
Prerequisites
- You have installed the OpenShift sandboxed containers Operator.
- You have installed the AWS command line tool.
-
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Log in to your OpenShift Container Platform cluster and retrieve the instance ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' \ -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
$ INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' \ -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
Retrieve the AWS region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS_SG_IDS=($(aws ec2 describe-instances --instance-ids ${INSTANCE_ID} \ --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' \ --output text --region $AWS_REGION))
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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 \ done
$ 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 \ done
The ports are now enabled.
3.3.3. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
You have the following values generated by using the AWS console:
-
AWS_ACCESS_KEY_ID
-
AWS_SECRET_ACCESS_KEY
-
Procedure
Create a
peer-pods-secret.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AWS_ACCESS_KEY_ID: "<aws_access_key>" AWS_SECRET_ACCESS_KEY: "<aws_secret_access_key>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AWS_ACCESS_KEY_ID: "<aws_access_key>"
1 AWS_SECRET_ACCESS_KEY: "<aws_secret_access_key>"
2 Create the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-secret.yaml
$ oc apply -f peer-pods-secret.yaml
3.3.4. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Prerequisites
- You have your Amazon Machine Image (AMI) ID if you are not using the default AMI ID based on your cluster credentials.
Procedure
Obtain the following values from your AWS instance:
Retrieve and record the instance ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
$ INSTANCE_ID=$(oc get nodes -l 'node-role.kubernetes.io/worker' -o jsonpath='{.items[0].spec.providerID}' | sed 's#[^ ]*/##g')
This is used to retrieve other values for the secret object.
Retrieve and record the AWS region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.aws.region}') && echo "AWS_REGION: \"$AWS_REGION\""
$ AWS_REGION=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.aws.region}') && echo "AWS_REGION: \"$AWS_REGION\""
Retrieve and record the AWS subnet ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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\""
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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\""
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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\""
$ 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\""
Create a
peer-pods-cm.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "aws" VXLAN_PORT: "9000" PODVM_INSTANCE_TYPE: "t3.medium" PODVM_INSTANCE_TYPES: "t2.small,t2.medium,t3.large" PROXY_TIMEOUT: "5m" 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>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "aws" VXLAN_PORT: "9000" PODVM_INSTANCE_TYPE: "t3.medium"
1 PODVM_INSTANCE_TYPES: "t2.small,t2.medium,t3.large"
2 PROXY_TIMEOUT: "5m" PODVM_AMI_ID: "<podvm_ami_id>"
3 AWS_REGION: "<aws_region>"
4 AWS_SUBNET_ID: "<aws_subnet_id>"
5 AWS_VPC_ID: "<aws_vpc_id>"
6 AWS_SG_IDS: "<aws_sg_ids>"
7 PEERPODS_LIMIT_PER_NODE: "10"
8 TAGS: "key1=value1,key2=value2"
9 DISABLECVM: "true"
- 1
- Defines the default instance type that is used when a type is not defined in the workload.
- 2
- Lists all of the instance types you can specify when creating the pod. This allows you to define smaller instance types for workloads that need less memory and fewer CPUs or larger instance types for larger workloads.
- 3
- Optional: By default, this value is populated when you run the
KataConfig
CR, using an AMI ID based on your cluster credentials. If you create your own AMI, specify the correct AMI ID. - 4
- Specify the
AWS_REGION
value you retrieved. - 5
- Specify the
AWS_SUBNET_ID
value you retrieved. - 6
- Specify the
AWS_VPC_ID
value you retrieved. - 7
- Specify the
AWS_SG_IDS
value you retrieved. - 8
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 9
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-cm.yaml
$ oc apply -f peer-pods-cm.yaml
3.3.5. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
Edit the pod manifest by adding the
io.katacontainers.config.hypervisor.image
annotation and save it in apod-manifest.yaml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: 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"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<custom_image_id>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f pod-manifest.yaml
$ oc apply -f pod-manifest.yaml
3.3.6. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
Add the Base64-encoded policy to a
my-pod.yaml
pod specification file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
Apply the pod manifest by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f my-pod.yaml
$ oc apply -f my-pod.yaml
3.3.7. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a runtime class on your worker nodes.
Creating the KataConfig
CR triggers the OpenShift sandboxed containers Operator to do the following:
-
Create a
RuntimeClass
CR namedkata-remote
with a default configuration. This enables users to configure workloads to usekata-remote
as the runtime by referencing the CR in theRuntimeClassName
field. This CR also specifies the resource overhead for the runtime.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 - 1
- Optional: If you have applied node labels to install
kata-remote
on specific nodes, specify the key and value, for example,osc: 'true'
.
Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
Verifying the pod VM image
After kata-remote
is installed on your cluster, the OpenShift sandboxed containers Operator creates a pod VM image, which is used to create peer pods. This process can take a long time because the image is created on the cloud instance. You can verify that the pod VM image was created successfully by checking the config map that you created for the cloud provider.
Procedure
Obtain the config map you created for the peer pods:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
Check the
status
stanza of the YAML file.If the
PODVM_AMI_ID
parameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
$ 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.
3.3.8. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
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 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.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
Add an annotation to the pod-templated object to use a manually defined instance type or an automatic instance type:
To use a manually defined instance type, add the following annotation:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "t3.medium" # ...
apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "t3.medium"
1 # ...
- 1
- Specify the instance type that you defined in the config map.
To use an automatic instance type, add the following annotations:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
Define the amount of memory available for the workload to use. The workload will run on an automatic instance type based on the amount of memory available.
Apply the changes to the workload object by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f <object.yaml>
$ oc apply -f <object.yaml>
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
Chapter 4. Deploying OpenShift sandboxed containers on Azure
You can deploy OpenShift sandboxed containers on Microsoft Azure Cloud Computing Services.
OpenShift sandboxed containers deploys peer pods. The peer pod design circumvents the need for nested virtualization. For more information, see peer pod and Peer pods technical deep dive.
Cluster requirements
- You have installed Red Hat OpenShift Container Platform 4.14 or later on the cluster where you are installing the OpenShift sandboxed containers Operator.
- Your cluster has at least one worker node.
For details on installing OpenShift Container Platform on Microsoft Azure Cloud Computing Services see Installing on Azure.
4.1. Peer pod resource requirements
You must ensure that your cluster has sufficient resources.
Peer pod virtual machines (VMs) require resources in two locations:
-
The worker node. The worker node stores metadata, Kata shim resources (
containerd-shim-kata-v2
), remote-hypervisor resources (cloud-api-adaptor
), and the tunnel setup between the worker nodes and the peer pod VM. - The cloud instance. This is the actual peer pod VM running in the cloud.
The CPU and memory resources used in the Kubernetes worker node are handled by the pod overhead included in the RuntimeClass (kata-remote
) definition used for creating peer pods.
The total number of peer pod VMs running in the cloud is defined as Kubernetes Node extended resources. This limit is per node and is set by the PEERPODS_LIMIT_PER_NODE
attribute in the peer-pods-cm
config map.
The extended resource is named kata.peerpods.io/vm
, and enables the Kubernetes scheduler to handle capacity tracking and accounting.
You can edit the limit per node based on the requirements for your environment after you install the OpenShift sandboxed containers Operator.
A mutating webhook adds the extended resource kata.peerpods.io/vm
to the pod specification. It also removes any resource-specific entries from the pod specification, if present. This enables the Kubernetes scheduler to account for these extended resources, ensuring the peer pod is only scheduled when resources are available.
The mutating webhook modifies a Kubernetes pod as follows:
-
The mutating webhook checks the pod for the expected
RuntimeClassName
value, specified in theTARGET_RUNTIME_CLASS
environment variable. If the value in the pod specification does not match the value in theTARGET_RUNTIME_CLASS
, the webhook exits without modifying the pod. If the
RuntimeClassName
values match, the webhook makes the following changes to the pod spec:-
The webhook removes every resource specification from the
resources
field of all containers and init containers in the pod. -
The webhook adds the extended resource (
kata.peerpods.io/vm
) to the spec by modifying the resources field of the first container in the pod. The extended resourcekata.peerpods.io/vm
is used by the Kubernetes scheduler for accounting purposes.
-
The webhook removes every resource specification from the
The mutating webhook excludes specific system namespaces in OpenShift Container Platform from mutation. If a peer pod is created in those system namespaces, then resource accounting using Kubernetes extended resources does not work unless the pod spec includes the extended resource.
As a best practice, define a cluster-wide policy to only allow peer pod creation in specific namespaces.
4.2. Configuring outbound connections
To enable peer pods to communicate with external networks, such as the public internet, you must configure outbound connectivity for the pod virtual machine (VM) subnet. This involves setting up a NAT gateway and, optionally, defining how the subnet integrates with your cluster’s virtual network (VNet) in Azure.
- Peer pods and subnets
- Peer pods operate in a dedicated Azure subnet that requires explicit configuration for outbound access. This subnet can either be the default worker subnet used by OpenShift Container Platform nodes or a separate, custom subnet created specifically for peer pods.
- VNet peering
- When using a separate subnet, VNet peering connects the peer pod VNet to the cluster’s VNet, ensuring internal communication while maintaining isolation. This requires non-overlapping CIDR ranges between the VNets.
You can configure outbound connectivity in two ways:
- Default worker subnet: Modify the existing worker subnet to include a NAT gateway. This is simpler and reuses cluster resources, but it offers less isolation.
- Peer pod VNet: Set up a dedicated VNet and subnet for peer pods, attach a NAT gateway, and peer it with the cluster VNet. This provides greater isolation and flexibility at the cost of additional complexity.
4.2.1. Configuring the default worker subnet for outbound connections
You can configure the default worker subnet with a NAT gateway.
Prerequisites
-
The Azure CLI (
az
) is installed and authenticated. - You have administrator access to the Azure resource group and the VNet.
Procedure
Set the
AZURE_RESOURCE_GROUP
environment variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster \ -o jsonpath='{.status.platformStatus.azure.resourceGroupName}')
$ AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster \ -o jsonpath='{.status.platformStatus.azure.resourceGroupName}')
Set the
AZURE_REGION
environment variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP}\ --query "{Location:location}" --output tsv) && \ echo "AZURE_REGION: \"$AZURE_REGION\""
$ AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP}\ --query "{Location:location}" --output tsv) && \ echo "AZURE_REGION: \"$AZURE_REGION\""
Set the
AZURE_VNET_NAME
environment variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_VNET_NAME=$(az network vnet list \ -g "${AZURE_RESOURCE_GROUP}" --query '[].name' -o tsv)
$ AZURE_VNET_NAME=$(az network vnet list \ -g "${AZURE_RESOURCE_GROUP}" --query '[].name' -o tsv)
Set the
AZURE_SUBNET_ID
environment variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_SUBNET_ID=$(az network vnet subnet list \ --resource-group "${AZURE_RESOURCE_GROUP}" \ --vnet-name "${AZURE_VNET_NAME}" --query "[].{Id:id} \ | [? contains(Id, 'worker')]" --output tsv)
$ AZURE_SUBNET_ID=$(az network vnet subnet list \ --resource-group "${AZURE_RESOURCE_GROUP}" \ --vnet-name "${AZURE_VNET_NAME}" --query "[].{Id:id} \ | [? contains(Id, 'worker')]" --output tsv)
Set the NAT gateway environment variables for the peer pod subnet by running the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_NAT_GW=peerpod-nat-gw
$ export PEERPOD_NAT_GW=peerpod-nat-gw
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_NAT_GW_IP=peerpod-nat-gw-ip
$ export PEERPOD_NAT_GW_IP=peerpod-nat-gw-ip
Create a public IP address for the NAT gateway by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network public-ip create -g "${AZURE_RESOURCE_GROUP}" \ -n "${PEERPOD_NAT_GW_IP}" -l "${AZURE_REGION}" --sku Standard
$ az network public-ip create -g "${AZURE_RESOURCE_GROUP}" \ -n "${PEERPOD_NAT_GW_IP}" -l "${AZURE_REGION}" --sku Standard
Create the NAT gateway and associate it with the public IP address by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network nat gateway create -g "${AZURE_RESOURCE_GROUP}" \ -l "${AZURE_REGION}" --public-ip-addresses "${PEERPOD_NAT_GW_IP}" \ -n "${PEERPOD_NAT_GW}"
$ az network nat gateway create -g "${AZURE_RESOURCE_GROUP}" \ -l "${AZURE_REGION}" --public-ip-addresses "${PEERPOD_NAT_GW_IP}" \ -n "${PEERPOD_NAT_GW}"
Update the VNet subnet to use the NAT gateway by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet subnet update --nat-gateway "${PEERPOD_NAT_GW}" \ --ids "${AZURE_SUBNET_ID}"
$ az network vnet subnet update --nat-gateway "${PEERPOD_NAT_GW}" \ --ids "${AZURE_SUBNET_ID}"
Verification
Confirm the NAT gateway is attached to the VNet subnet by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet subnet show --ids "${AZURE_SUBNET_ID}" \ --query "natGateway.id" -o tsv
$ az network vnet subnet show --ids "${AZURE_SUBNET_ID}" \ --query "natGateway.id" -o tsv
The output contains the NAT gateway resource ID. If no NAT gateway is attached, the output is empty.
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow /subscriptions/12345678-1234-1234-1234-1234567890ab/resourceGroups/myResourceGroup/providers/Microsoft.Network/natGateways/myNatGateway
/subscriptions/12345678-1234-1234-1234-1234567890ab/resourceGroups/myResourceGroup/providers/Microsoft.Network/natGateways/myNatGateway
Additional Resources
- Azure documentation: NAT Gateway Overview
- Azure documentation: VNet Peering Overview
4.2.2. Creating a peer pod VNet for outbound connections
To enable public internet access, you can create a dedicated virtual network (VNet) for peer pods, attach a network address translation (NAT) gateway, create a subnet, and enable VNet peering with non-overlapping address spaces.
Prerequisites
-
The Azure CLI (
az
) is installed - You have signed in to Azure. See Authenticate to Azure using Azure CLI.
- You have administrator access to the Azure resource group and VNet hosting the cluster.
-
You have verified the cluster VNet classless inter-domain routing (CIDR) address. The default value is
10.0.0.0/14
. If you overrode the default value, you have ensured that you chose a non-overlapping CIDR address for the peer pod VNet. For example,192.168.0.0/16
.
Procedure
Set the environmental variables for the peer pod network:
Set the peer pod VNet environment variables by running the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_VNET_NAME="${PEERPOD_VNET_NAME:-peerpod-vnet}"
$ export PEERPOD_VNET_NAME="${PEERPOD_VNET_NAME:-peerpod-vnet}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_VNET_CIDR="${PEERPOD_VNET_CIDR:-192.168.0.0/16}"
$ export PEERPOD_VNET_CIDR="${PEERPOD_VNET_CIDR:-192.168.0.0/16}"
Set the peer pod subnet environment variables by running the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_SUBNET_NAME="${PEERPOD_SUBNET_NAME:-peerpod-subnet}"
$ export PEERPOD_SUBNET_NAME="${PEERPOD_SUBNET_NAME:-peerpod-subnet}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_SUBNET_CIDR="${PEERPOD_SUBNET_CIDR:-192.168.0.0/16}"
$ export PEERPOD_SUBNET_CIDR="${PEERPOD_SUBNET_CIDR:-192.168.0.0/16}"
Set the environmental variables for Azure:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster \ -o jsonpath='{.status.platformStatus.azure.resourceGroupName}')
$ AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster \ -o jsonpath='{.status.platformStatus.azure.resourceGroupName}')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP}\ --query "{Location:location}" --output tsv) && \ echo "AZURE_REGION: \"$AZURE_REGION\""
$ AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP}\ --query "{Location:location}" --output tsv) && \ echo "AZURE_REGION: \"$AZURE_REGION\""
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_VNET_NAME=$(az network vnet list \ -g "${AZURE_RESOURCE_GROUP}" --query '[].name' -o tsv)
$ AZURE_VNET_NAME=$(az network vnet list \ -g "${AZURE_RESOURCE_GROUP}" --query '[].name' -o tsv)
Set the peer pod NAT gateway environment variables by running the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_NAT_GW="${PEERPOD_NAT_GW:-peerpod-nat-gw}"
$ export PEERPOD_NAT_GW="${PEERPOD_NAT_GW:-peerpod-nat-gw}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export PEERPOD_NAT_GW_IP="${PEERPOD_NAT_PUBLIC_IP:-peerpod-nat-gw-ip}"
$ export PEERPOD_NAT_GW_IP="${PEERPOD_NAT_PUBLIC_IP:-peerpod-nat-gw-ip}"
Configure the VNET:
Create the peer pod VNet by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet create --resource-group "${AZURE_RESOURCE_GROUP}" \ --name "${PEERPOD_VNET_NAME}" \ --address-prefixes "${PEERPOD_VNET_CIDR}"
$ az network vnet create --resource-group "${AZURE_RESOURCE_GROUP}" \ --name "${PEERPOD_VNET_NAME}" \ --address-prefixes "${PEERPOD_VNET_CIDR}"
Create a public IP address for the peer pod VNet by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network public-ip create -g "${AZURE_RESOURCE_GROUP}" \ -n "${PEERPOD_NAT_GW_IP}" -l "${AZURE_REGION}"
$ az network public-ip create -g "${AZURE_RESOURCE_GROUP}" \ -n "${PEERPOD_NAT_GW_IP}" -l "${AZURE_REGION}"
Create a NAT gateway for the peer pod VNet by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network nat gateway create -g "${AZURE_RESOURCE_GROUP}" \ -l "${AZURE_REGION}" \ --public-ip-addresses "${PEERPOD_NAT_GW_IP}" \ -n "${PEERPOD_NAT_GW}"
$ az network nat gateway create -g "${AZURE_RESOURCE_GROUP}" \ -l "${AZURE_REGION}" \ --public-ip-addresses "${PEERPOD_NAT_GW_IP}" \ -n "${PEERPOD_NAT_GW}"
Create a subnet in the peer pod VNet and attach the NAT gateway by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet subnet create \ --resource-group "${AZURE_RESOURCE_GROUP}" \ --vnet-name "${PEERPOD_VNET_NAME}" \ --name "${PEERPOD_SUBNET_NAME}" \ --address-prefixes "${PEERPOD_SUBNET_CIDR}" \ --nat-gateway "${PEERPOD_NAT_GW}"
$ az network vnet subnet create \ --resource-group "${AZURE_RESOURCE_GROUP}" \ --vnet-name "${PEERPOD_VNET_NAME}" \ --name "${PEERPOD_SUBNET_NAME}" \ --address-prefixes "${PEERPOD_SUBNET_CIDR}" \ --nat-gateway "${PEERPOD_NAT_GW}"
Configure the virtual network peering connection:
Create the peering connection by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet peering create -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-azure-vnet-to-peerpod-vnet \ --vnet-name "${AZURE_VNET_NAME}" \ --remote-vnet "${PEERPOD_VNET_NAME}" --allow-vnet-access \ --allow-forwarded-traffic
$ az network vnet peering create -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-azure-vnet-to-peerpod-vnet \ --vnet-name "${AZURE_VNET_NAME}" \ --remote-vnet "${PEERPOD_VNET_NAME}" --allow-vnet-access \ --allow-forwarded-traffic
Sync the peering connection by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet peering sync -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-azure-vnet-to-peerpod-vnet \ --vnet-name "${AZURE_VNET_NAME}"
$ az network vnet peering sync -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-azure-vnet-to-peerpod-vnet \ --vnet-name "${AZURE_VNET_NAME}"
Complete the peering connection by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet peering create -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-peerpod-vnet-to-azure-vnet \ --vnet-name "${PEERPOD_VNET_NAME}" \ --remote-vnet "${AZURE_VNET_NAME}" --allow-vnet-access \ --allow-forwarded-traffic
$ az network vnet peering create -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-peerpod-vnet-to-azure-vnet \ --vnet-name "${PEERPOD_VNET_NAME}" \ --remote-vnet "${AZURE_VNET_NAME}" --allow-vnet-access \ --allow-forwarded-traffic
Verification
Check the peering connection status from the cluster VNet by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet peering show -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-azure-vnet-to-peerpod-vnet \ --vnet-name "${AZURE_VNET_NAME}" \ --query "peeringState" -o tsv
$ az network vnet peering show -g "${AZURE_RESOURCE_GROUP}" \ -n peerpod-azure-vnet-to-peerpod-vnet \ --vnet-name "${AZURE_VNET_NAME}" \ --query "peeringState" -o tsv
This should return
Connected
.Verify that the NAT gateway is attached to the peer pod subnet by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az network vnet subnet show --resource-group "${AZURE_RESOURCE_GROUP}" \ --vnet-name "${PEERPOD_VNET_NAME}" --name "${PEERPOD_SUBNET_NAME}" \ --query "natGateway.id" -o tsv
$ az network vnet subnet show --resource-group "${AZURE_RESOURCE_GROUP}" \ --vnet-name "${PEERPOD_VNET_NAME}" --name "${PEERPOD_SUBNET_NAME}" \ --query "natGateway.id" -o tsv
Additional Resources
- Azure documentation: NAT Gateway Overview
- Azure documentation: VNet Peering Overview
4.3. Deploying OpenShift sandboxed containers by using the web console
You can deploy OpenShift sandboxed containers on Azure by using the OpenShift Container Platform web console to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Create the peer pods secret if you uninstalled the Cloud Credential Operator, which is installed with the OpenShift sandboxed containers Operator.
- Optional: Select a custom pod VM image.
- Optional: Create the Azure secret.
- Optional: Customize the Kata agent policy.
- Create the peer pods config map.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
4.3.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
- In the web console, navigate to Operators → OperatorHub.
-
In the Filter by keyword field, type
OpenShift sandboxed containers
. - Select the OpenShift sandboxed containers Operator tile 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-operator
namespace. 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-operator
causes 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.
- Navigate to Operators → Installed Operators to verify that the Operator is installed.
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
4.3.2. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
- You have installed and configured the Azure CLI tool.
Procedure
Retrieve the Azure subscription ID by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_SUBSCRIPTION_ID=$(az account list --query "[?isDefault].id" \ -o tsv) && echo "AZURE_SUBSCRIPTION_ID: \"$AZURE_SUBSCRIPTION_ID\""
$ AZURE_SUBSCRIPTION_ID=$(az account list --query "[?isDefault].id" \ -o tsv) && echo "AZURE_SUBSCRIPTION_ID: \"$AZURE_SUBSCRIPTION_ID\""
Generate the RBAC content by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az ad sp create-for-rbac --role Contributor --scopes /subscriptions/$AZURE_SUBSCRIPTION_ID \ --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
$ az ad sp create-for-rbac --role Contributor --scopes /subscriptions/$AZURE_SUBSCRIPTION_ID \ --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "client_id": `AZURE_CLIENT_ID`, "client_secret": `AZURE_CLIENT_SECRET`, "tenant_id": `AZURE_TENANT_ID` }
{ "client_id": `AZURE_CLIENT_ID`, "client_secret": `AZURE_CLIENT_SECRET`, "tenant_id": `AZURE_TENANT_ID` }
-
Record the RBAC output to use in the
secret
object. - In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Click the OpenShift sandboxed containers Operator tile.
- Click the Import icon (+) on the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AZURE_CLIENT_ID: "<azure_client_id>" AZURE_CLIENT_SECRET: "<azure_client_secret>" AZURE_TENANT_ID: "<azure_tenant_id>" AZURE_SUBSCRIPTION_ID: "<azure_subscription_id>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AZURE_CLIENT_ID: "<azure_client_id>"
1 AZURE_CLIENT_SECRET: "<azure_client_secret>"
2 AZURE_TENANT_ID: "<azure_tenant_id>"
3 AZURE_SUBSCRIPTION_ID: "<azure_subscription_id>"
4 - Click Save to apply the changes.
- Navigate to Workloads → Secrets to verify the peer pods secret.
4.3.3. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Procedure
Obtain the following values from your Azure instance:
Retrieve and record the Azure resource group:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.azure.resourceGroupName}') && echo "AZURE_RESOURCE_GROUP: \"$AZURE_RESOURCE_GROUP\""
$ AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.azure.resourceGroupName}') && echo "AZURE_RESOURCE_GROUP: \"$AZURE_RESOURCE_GROUP\""
Retrieve and record the Azure VNet name:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_VNET_NAME=$(az network vnet list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Name:name}" --output tsv)
$ AZURE_VNET_NAME=$(az network vnet list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Name:name}" --output tsv)
This value is used to retrieve the Azure subnet ID.
Retrieve and record the Azure subnet ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_SUBNET_ID=$(az network vnet subnet list --resource-group ${AZURE_RESOURCE_GROUP} --vnet-name $AZURE_VNET_NAME --query "[].{Id:id} | [? contains(Id, 'worker')]" --output tsv) && echo "AZURE_SUBNET_ID: \"$AZURE_SUBNET_ID\""
$ AZURE_SUBNET_ID=$(az network vnet subnet list --resource-group ${AZURE_RESOURCE_GROUP} --vnet-name $AZURE_VNET_NAME --query "[].{Id:id} | [? contains(Id, 'worker')]" --output tsv) && echo "AZURE_SUBNET_ID: \"$AZURE_SUBNET_ID\""
Retrieve and record the Azure network security group (NSG) ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_NSG_ID=$(az network nsg list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Id:id}" --output tsv) && echo "AZURE_NSG_ID: \"$AZURE_NSG_ID\""
$ AZURE_NSG_ID=$(az network nsg list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Id:id}" --output tsv) && echo "AZURE_NSG_ID: \"$AZURE_NSG_ID\""
Retrieve and record the Azure region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP} --query "{Location:location}" --output tsv) && echo "AZURE_REGION: \"$AZURE_REGION\""
$ AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP} --query "{Location:location}" --output tsv) && echo "AZURE_REGION: \"$AZURE_REGION\""
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "azure" VXLAN_PORT: "9000" AZURE_INSTANCE_SIZE: "Standard_B2als_v2" AZURE_INSTANCE_SIZES: "Standard_B2als_v2,Standard_D2as_v5,Standard_D4as_v5,Standard_D2ads_v5" AZURE_SUBNET_ID: "<azure_subnet_id>" AZURE_NSG_ID: "<azure_nsg_id>" PROXY_TIMEOUT: "5m" AZURE_IMAGE_ID: "<azure_image_id>" AZURE_REGION: "<azure_region>" AZURE_RESOURCE_GROUP: "<azure_resource_group>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "azure" VXLAN_PORT: "9000" AZURE_INSTANCE_SIZE: "Standard_B2als_v2"
1 AZURE_INSTANCE_SIZES: "Standard_B2als_v2,Standard_D2as_v5,Standard_D4as_v5,Standard_D2ads_v5"
2 AZURE_SUBNET_ID: "<azure_subnet_id>"
3 AZURE_NSG_ID: "<azure_nsg_id>"
4 PROXY_TIMEOUT: "5m" AZURE_IMAGE_ID: "<azure_image_id>"
5 AZURE_REGION: "<azure_region>"
6 AZURE_RESOURCE_GROUP: "<azure_resource_group>"
7 PEERPODS_LIMIT_PER_NODE: "10"
8 TAGS: "key1=value1,key2=value2"
9 DISABLECVM: "true"
- 1
- The
"Standard_B2als_v2"
instance size is the default value if an instance size is not defined in the workload. - 2
- Lists all of the instance sizes you can specify when creating the pod. This allows you to define smaller instance sizes for workloads that need less memory and fewer CPUs or larger instance sizes for larger workloads.
- 3
- Specify the
AZURE_SUBNET_ID
value that you retrieved. - 4
- Specify the
AZURE_NSG_ID
value that you retrieved. - 5
- Optional: By default, this value is populated when you run the
KataConfig
CR, using an Azure image ID based on your cluster credentials. If you create your own Azure image, specify the correct image ID. - 6
- Specify the
AZURE_REGION
value you retrieved. - 7
- Specify the
AZURE_RESOURCE_GROUP
value you retrieved. - 8
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 9
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters.
- Click Save to apply the changes.
- Navigate to Workloads → ConfigMaps to view the new config map.
4.3.4. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: 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"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<custom_image_id>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
- Click Save to apply the changes.
4.3.5. Creating the Azure secret
You must create the SSH key secret, which is required by the Azure virtual machine (VM) creation API. Azure only requires the SSH public key. Confidential Containers disables SSH in VMs, so the keys have no effect in the VMs.
Procedure
Generate an SSH key pair by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh-keygen -f ./id_rsa -N ""
$ ssh-keygen -f ./id_rsa -N ""
- In the OpenShift Container Platform web console, navigate to Workloads → Secrets.
- On the Secrets page, verify that you are in the openshift-sandboxed-containers-operator project.
- Click Create and select Key/value secret.
-
In the Secret name field, enter
ssh-key-secret
. -
In the Key field, enter
id_rsa.pub
. - In the Value field, paste your public SSH key.
- Click Create.
Delete the SSH keys you created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow shred --remove id_rsa.pub id_rsa
$ shred --remove id_rsa.pub id_rsa
4.3.6. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest and add the Base64-encoded policy to it:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
- Click Save to apply the changes.
4.3.7. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a RuntimeClass
on your worker nodes.
The kata-remote
runtime class is installed on all worker nodes by default. If you want to install kata-remote
on specific nodes, you can add labels to those nodes and then define the label in the KataConfig
CR.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
Creating the KataConfig
CR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes. The following factors might increase 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 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 access to the cluster as a user with the
cluster-admin
role. - Optional: You have installed the Node Feature Discovery Operator if you want to enable node eligibility checks.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator.
- On the KataConfig tab, click Create KataConfig.
Enter the following details:
-
Name: Optional: The default name is
example-kataconfig
. -
Labels: Optional: Enter any relevant, identifying attributes to the
KataConfig
resource. Each label represents a key-value pair. - enablePeerPods: Select for public cloud, IBM Z®, and IBM® LinuxONE deployments.
kataConfigPoolSelector. Optional: To install
kata-remote
on selected nodes, add a match expression for the labels on the selected nodes:- Expand the kataConfigPoolSelector area.
- In the kataConfigPoolSelector area, expand matchExpressions. This is a list of label selector requirements.
- Click Add matchExpressions.
- In the Key field, enter the label key the selector applies to.
-
In the Operator field, enter 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
true
orfalse
for key label value.
-
logLevel: Define the level of log data retrieved for nodes with the
kata-remote
runtime class.
-
Name: Optional: The default name is
Click Create. The
KataConfig
CR is created and installs thekata-remote
runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.
Verification
-
On the KataConfig tab, click the
KataConfig
CR to view its details. Click the YAML tab to view the
status
stanza.The
status
stanza contains theconditions
andkataNodes
keys. The value ofstatus.kataNodes
is an array of nodes, each of which lists nodes in a particular state ofkata-remote
installation. A message appears each time there is an update.Click Reload to refresh the YAML.
When all workers in the
status.kataNodes
array display the valuesinstalled
andconditions.InProgress: False
with no specified reason, thekata-remote
is installed on the cluster.
Additional resources
Verifying the pod VM image
After kata-remote
is installed on your cluster, the OpenShift sandboxed containers Operator creates a pod VM image, which is used to create peer pods. This process can take a long time because the image is created on the cloud instance. You can verify that the pod VM image was created successfully by checking the config map that you created for the cloud provider.
Procedure
- Navigate to Workloads → ConfigMaps.
- Click the provider config map to view its details.
- Click the YAML tab.
Check the
status
stanza of the YAML file.If the
AZURE_IMAGE_ID
parameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
$ 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.3.8. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
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 size, which you defined in the config map, by adding an annotation to the YAML file.
If you do not want to define the instance size manually, you can add an annotation to use an automatic instance size, based on the memory available.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
- In the OpenShift Container Platform web console, navigate to Workloads → workload type, for example, Pods.
- On the workload type page, click an object to view its details.
- Click the YAML tab.
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
Add an annotation to the pod-templated object to use a manually defined instance size or an automatic instance size:
To use a manually defined instance size, add the following annotation:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "Standard_B2als_v2" # ...
apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "Standard_B2als_v2"
1 # ...
- 1
- Specify the instance size that you defined in the config map.
To use an automatic instance size, add the following annotations:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
Define the amount of memory available for the workload to use. The workload will run on an automatic instance size based on the amount of memory available.
Click Save to apply the changes.
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
4.4. Deploying OpenShift sandboxed containers by using the command line
You can deploy OpenShift sandboxed containers on Azure by using the command line interface (CLI) to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Change the number of virtual machines running on each worker node.
- Optional: Create the peer pods secret if you uninstalled the Cloud Credential Operator, which is installed with the OpenShift sandboxed containers Operator.
- Optional: Select a custom pod VM image.
- Create the peer pods config map.
- Optional: Create the Azure secret.
- Optional: Customize the Kata agent policy.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
4.4.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
osc-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
Create the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-namespace.yaml
$ oc apply -f osc-namespace.yaml
Create an
osc-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: sandboxed-containers-operator-group namespace: openshift-sandboxed-containers-operator spec: targetNamespaces: - openshift-sandboxed-containers-operator
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-operatorgroup.yaml
$ oc apply -f osc-operatorgroup.yaml
Create an
osc-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.9.0
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.9.0
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-subscription.yaml
$ oc apply -f osc-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n openshift-sandboxed-containers-operator
$ watch oc get csv -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
4.4.2. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
- You have installed and configured the Azure CLI tool.
Procedure
Retrieve the Azure subscription ID by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_SUBSCRIPTION_ID=$(az account list --query "[?isDefault].id" \ -o tsv) && echo "AZURE_SUBSCRIPTION_ID: \"$AZURE_SUBSCRIPTION_ID\""
$ AZURE_SUBSCRIPTION_ID=$(az account list --query "[?isDefault].id" \ -o tsv) && echo "AZURE_SUBSCRIPTION_ID: \"$AZURE_SUBSCRIPTION_ID\""
Generate the RBAC content by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az ad sp create-for-rbac --role Contributor --scopes /subscriptions/$AZURE_SUBSCRIPTION_ID \ --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
$ az ad sp create-for-rbac --role Contributor --scopes /subscriptions/$AZURE_SUBSCRIPTION_ID \ --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "client_id": `AZURE_CLIENT_ID`, "client_secret": `AZURE_CLIENT_SECRET`, "tenant_id": `AZURE_TENANT_ID` }
{ "client_id": `AZURE_CLIENT_ID`, "client_secret": `AZURE_CLIENT_SECRET`, "tenant_id": `AZURE_TENANT_ID` }
-
Record the RBAC output to use in the
secret
object. Create a
peer-pods-secret.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AZURE_CLIENT_ID: "<azure_client_id>" AZURE_CLIENT_SECRET: "<azure_client_secret>" AZURE_TENANT_ID: "<azure_tenant_id>" AZURE_SUBSCRIPTION_ID: "<azure_subscription_id>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: AZURE_CLIENT_ID: "<azure_client_id>"
1 AZURE_CLIENT_SECRET: "<azure_client_secret>"
2 AZURE_TENANT_ID: "<azure_tenant_id>"
3 AZURE_SUBSCRIPTION_ID: "<azure_subscription_id>"
4 Create the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-secret.yaml
$ oc apply -f peer-pods-secret.yaml
4.4.3. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Procedure
Obtain the following values from your Azure instance:
Retrieve and record the Azure resource group:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.azure.resourceGroupName}') && echo "AZURE_RESOURCE_GROUP: \"$AZURE_RESOURCE_GROUP\""
$ AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.azure.resourceGroupName}') && echo "AZURE_RESOURCE_GROUP: \"$AZURE_RESOURCE_GROUP\""
Retrieve and record the Azure VNet name:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_VNET_NAME=$(az network vnet list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Name:name}" --output tsv)
$ AZURE_VNET_NAME=$(az network vnet list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Name:name}" --output tsv)
This value is used to retrieve the Azure subnet ID.
Retrieve and record the Azure subnet ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_SUBNET_ID=$(az network vnet subnet list --resource-group ${AZURE_RESOURCE_GROUP} --vnet-name $AZURE_VNET_NAME --query "[].{Id:id} | [? contains(Id, 'worker')]" --output tsv) && echo "AZURE_SUBNET_ID: \"$AZURE_SUBNET_ID\""
$ AZURE_SUBNET_ID=$(az network vnet subnet list --resource-group ${AZURE_RESOURCE_GROUP} --vnet-name $AZURE_VNET_NAME --query "[].{Id:id} | [? contains(Id, 'worker')]" --output tsv) && echo "AZURE_SUBNET_ID: \"$AZURE_SUBNET_ID\""
Retrieve and record the Azure network security group (NSG) ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_NSG_ID=$(az network nsg list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Id:id}" --output tsv) && echo "AZURE_NSG_ID: \"$AZURE_NSG_ID\""
$ AZURE_NSG_ID=$(az network nsg list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Id:id}" --output tsv) && echo "AZURE_NSG_ID: \"$AZURE_NSG_ID\""
Retrieve and record the Azure region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP} --query "{Location:location}" --output tsv) && echo "AZURE_REGION: \"$AZURE_REGION\""
$ AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP} --query "{Location:location}" --output tsv) && echo "AZURE_REGION: \"$AZURE_REGION\""
Create a
peer-pods-cm.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "azure" VXLAN_PORT: "9000" AZURE_INSTANCE_SIZE: "Standard_B2als_v2" AZURE_INSTANCE_SIZES: "Standard_B2als_v2,Standard_D2as_v5,Standard_D4as_v5,Standard_D2ads_v5" AZURE_SUBNET_ID: "<azure_subnet_id>" AZURE_NSG_ID: "<azure_nsg_id>" PROXY_TIMEOUT: "5m" AZURE_IMAGE_ID: "<azure_image_id>" AZURE_REGION: "<azure_region>" AZURE_RESOURCE_GROUP: "<azure_resource_group>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "azure" VXLAN_PORT: "9000" AZURE_INSTANCE_SIZE: "Standard_B2als_v2"
1 AZURE_INSTANCE_SIZES: "Standard_B2als_v2,Standard_D2as_v5,Standard_D4as_v5,Standard_D2ads_v5"
2 AZURE_SUBNET_ID: "<azure_subnet_id>"
3 AZURE_NSG_ID: "<azure_nsg_id>"
4 PROXY_TIMEOUT: "5m" AZURE_IMAGE_ID: "<azure_image_id>"
5 AZURE_REGION: "<azure_region>"
6 AZURE_RESOURCE_GROUP: "<azure_resource_group>"
7 PEERPODS_LIMIT_PER_NODE: "10"
8 TAGS: "key1=value1,key2=value2"
9 DISABLECVM: "true"
- 1
- The
"Standard_B2als_v2"
instance size is the default value if an instance size is not defined in the workload. - 2
- Lists all of the instance sizes you can specify when creating the pod. This allows you to define smaller instance sizes for workloads that need less memory and fewer CPUs or larger instance sizes for larger workloads.
- 3
- Specify the
AZURE_SUBNET_ID
value that you retrieved. - 4
- Specify the
AZURE_NSG_ID
value that you retrieved. - 5
- Optional: By default, this value is populated when you run the
KataConfig
CR, using an Azure image ID based on your cluster credentials. If you create your own Azure image, specify the correct image ID. - 6
- Specify the
AZURE_REGION
value you retrieved. - 7
- Specify the
AZURE_RESOURCE_GROUP
value you retrieved. - 8
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 9
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-cm.yaml
$ oc apply -f peer-pods-cm.yaml
4.4.4. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
Edit the pod manifest by adding the
io.katacontainers.config.hypervisor.image
annotation and save it in apod-manifest.yaml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: 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"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<custom_image_id>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f pod-manifest.yaml
$ oc apply -f pod-manifest.yaml
4.4.5. Creating the Azure secret
You must create the SSH key secret, which is required by the Azure virtual machine (VM) creation API. Azure only requires the SSH public key. Confidential Containers disables SSH in VMs, so the keys have no effect in the VMs.
Procedure
Generate an SSH key pair by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh-keygen -f ./id_rsa -N ""
$ ssh-keygen -f ./id_rsa -N ""
Create the
Secret
object by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create secret generic ssh-key-secret \ -n openshift-sandboxed-containers-operator \ --from-file=id_rsa.pub=./id_rsa.pub \ --from-file=id_rsa=./id_rsa
$ oc create secret generic ssh-key-secret \ -n openshift-sandboxed-containers-operator \ --from-file=id_rsa.pub=./id_rsa.pub \ --from-file=id_rsa=./id_rsa
Delete the SSH keys you created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow shred --remove id_rsa.pub id_rsa
$ shred --remove id_rsa.pub id_rsa
4.4.6. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
Add the Base64-encoded policy to a
my-pod.yaml
pod specification file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
Apply the pod manifest by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f my-pod.yaml
$ oc apply -f my-pod.yaml
4.4.7. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a runtime class on your worker nodes.
Creating the KataConfig
CR triggers the OpenShift sandboxed containers Operator to do the following:
-
Create a
RuntimeClass
CR namedkata-remote
with a default configuration. This enables users to configure workloads to usekata-remote
as the runtime by referencing the CR in theRuntimeClassName
field. This CR also specifies the resource overhead for the runtime.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 - 1
- Optional: If you have applied node labels to install
kata-remote
on specific nodes, specify the key and value, for example,osc: 'true'
.
Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
Verifying the pod VM image
After kata-remote
is installed on your cluster, the OpenShift sandboxed containers Operator creates a pod VM image, which is used to create peer pods. This process can take a long time because the image is created on the cloud instance. You can verify that the pod VM image was created successfully by checking the config map that you created for the cloud provider.
Procedure
Obtain the config map you created for the peer pods:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
Check the
status
stanza of the YAML file.If the
AZURE_IMAGE_ID
parameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
$ 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.4.8. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
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 size, which you defined in the config map, by adding an annotation to the YAML file.
If you do not want to define the instance size manually, you can add an annotation to use an automatic instance size, based on the memory available.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
Add an annotation to the pod-templated object to use a manually defined instance size or an automatic instance size:
To use a manually defined instance size, add the following annotation:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "Standard_B2als_v2" # ...
apiVersion: v1 kind: <object> metadata: annotations: io.katacontainers.config.hypervisor.machine_type: "Standard_B2als_v2"
1 # ...
- 1
- Specify the instance size that you defined in the config map.
To use an automatic instance size, add the following annotations:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
apiVersion: v1 kind: <Pod> metadata: annotations: io.katacontainers.config.hypervisor.default_vcpus: <vcpus> io.katacontainers.config.hypervisor.default_memory: <memory> # ...
Define the amount of memory available for the workload to use. The workload will run on an automatic instance size based on the amount of memory available.
Apply the changes to the workload object by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f <object.yaml>
$ oc apply -f <object.yaml>
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
Chapter 5. Deploying OpenShift sandboxed containers on Google Cloud
You can deploy OpenShift sandboxed containers on Google Cloud.
OpenShift sandboxed containers deploys peer pods. The peer pod design circumvents the need for nested virtualization. For more information, see peer pod and Peer pods technical deep dive.
Cluster requirements
- You have installed OpenShift Container Platform 4.17 or later on the cluster where you are installing the OpenShift sandboxed containers Operator for Google Cloud.
- Your cluster has at least one worker node.
For more information, see Installing on Google Cloud in the OpenShift Container Platform documentation.
5.1. Peer pod resource requirements
You must ensure that your cluster has sufficient resources.
Peer pod virtual machines (VMs) require resources in two locations:
-
The worker node. The worker node stores metadata, Kata shim resources (
containerd-shim-kata-v2
), remote-hypervisor resources (cloud-api-adaptor
), and the tunnel setup between the worker nodes and the peer pod VM. - The cloud instance. This is the actual peer pod VM running in the cloud.
The CPU and memory resources used in the Kubernetes worker node are handled by the pod overhead included in the RuntimeClass (kata-remote
) definition used for creating peer pods.
The total number of peer pod VMs running in the cloud is defined as Kubernetes Node extended resources. This limit is per node and is set by the PEERPODS_LIMIT_PER_NODE
attribute in the peer-pods-cm
config map.
The extended resource is named kata.peerpods.io/vm
, and enables the Kubernetes scheduler to handle capacity tracking and accounting.
You can edit the limit per node based on the requirements for your environment after you install the OpenShift sandboxed containers Operator.
A mutating webhook adds the extended resource kata.peerpods.io/vm
to the pod specification. It also removes any resource-specific entries from the pod specification, if present. This enables the Kubernetes scheduler to account for these extended resources, ensuring the peer pod is only scheduled when resources are available.
The mutating webhook modifies a Kubernetes pod as follows:
-
The mutating webhook checks the pod for the expected
RuntimeClassName
value, specified in theTARGET_RUNTIME_CLASS
environment variable. If the value in the pod specification does not match the value in theTARGET_RUNTIME_CLASS
, the webhook exits without modifying the pod. If the
RuntimeClassName
values match, the webhook makes the following changes to the pod spec:-
The webhook removes every resource specification from the
resources
field of all containers and init containers in the pod. -
The webhook adds the extended resource (
kata.peerpods.io/vm
) to the spec by modifying the resources field of the first container in the pod. The extended resourcekata.peerpods.io/vm
is used by the Kubernetes scheduler for accounting purposes.
-
The webhook removes every resource specification from the
The mutating webhook excludes specific system namespaces in OpenShift Container Platform from mutation. If a peer pod is created in those system namespaces, then resource accounting using Kubernetes extended resources does not work unless the pod spec includes the extended resource.
As a best practice, define a cluster-wide policy to only allow peer pod creation in specific namespaces.
5.2. Deploying OpenShift sandboxed containers by using the web console
You can deploy OpenShift sandboxed containers on Google Cloud by using the OpenShift Container Platform web console to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Enable port 15150 to allow internal communication with peer pods.
- Optional: Create the peer pods secret if you uninstalled the Cloud Credential Operator, which is installed with the OpenShift sandboxed containers Operator.
- Optional: Customize the Kata agent policy.
- Create the peer pods config map.
- Optional: Create the peer pod virtual machine (VM) image and VM image config map.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
5.2.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
- In the web console, navigate to Operators → OperatorHub.
-
In the Filter by keyword field, type
OpenShift sandboxed containers
. - Select the OpenShift sandboxed containers Operator tile 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-operator
namespace. 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-operator
causes 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.
- Navigate to Operators → Installed Operators to verify that the Operator is installed.
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
5.2.2. Enabling port 15150 for Google Cloud
You must enable port 15150 on the OpenShift Container Platform to allow internal communication with peer pods running on Compute Engine.
Prerequisites
- You have installed the Google Cloud command line interface (CLI) tool.
-
You have access to the OpenShift Container Platform cluster as a user with the
roles/container.admin
role.
Procedure
Set the project ID variable by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export GCP_PROJECT_ID="<project_id>"
$ export GCP_PROJECT_ID="<project_id>"
Log in to Google Cloud by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud auth login
$ gcloud auth login
Set the Google Cloud project ID by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud config set project ${GCP_PROJECT_ID}
$ gcloud config set project ${GCP_PROJECT_ID}
Open port 15150 by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud compute firewall-rules create allow-port-15150-restricted \ --project=${GCP_PROJECT_ID} \ --network=default \ --allow=tcp:15150 \ --source-ranges=<external_ip_cidr-1>[,<external_ip_cidr-2>,...]
$ gcloud compute firewall-rules create allow-port-15150-restricted \ --project=${GCP_PROJECT_ID} \ --network=default \ --allow=tcp:15150 \ --source-ranges=<external_ip_cidr-1>[,<external_ip_cidr-2>,...]
1 - 1
- Specify one or more IP addresses or ranges in CIDR format, separated by commas. For example,
203.0.113.5/32,198.51.100.0/24
.
Verification
Verify that port 15150 is open by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud compute firewall-rule list
$ gcloud compute firewall-rule list
5.2.3. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
-
You have created a Google Cloud service account with permissions such as
roles/compute.instanceAdmin.v1
to manage Compute Engine resources.
Procedure
- In the Google Cloud console, navigate to IAM & Admin → Service Accounts → Keys and save your key as a JSON file.
Convert the JSON file to a single line string by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow cat <key_file>.json | jq -c .
$ cat <key_file>.json | jq -c .
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Click the OpenShift sandboxed containers Operator tile.
- Click the Import icon (+) on the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: GCP_CREDENTIALS: "<gc_service_account_key_json>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: GCP_CREDENTIALS: "<gc_service_account_key_json>"
1 - 1
- Replace
<gc_service_account_key_json>
with the single-line string you created from the Google Cloud service account key JSON file.
- Click Save to apply the changes.
- Navigate to Workloads → Secrets to verify the peer pods secret.
5.2.4. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Procedure
Log in to your Compute Engine instance to set the following environmental variables:
Get the project ID by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow GCP_PROJECT_ID=$(gcloud config get-value project)
$ GCP_PROJECT_ID=$(gcloud config get-value project)
Get the zone by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow GCP_ZONE=$(gcloud config get-value compute/zone)
$ GCP_ZONE=$(gcloud config get-value compute/zone)
Retrieve a list of network names by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud compute networks list --format="value(name)"
$ gcloud compute networks list --format="value(name)"
Specify the network by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow GCP_NETWORK=<network_name>
$ GCP_NETWORK=<network_name>
1 - 1
- Replace
<network_name>
with the name of the network.
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "gcp" PROXY_TIMEOUT: "5m" GCP_PROJECT_ID: "<gcp_project_id>" GCP_ZONE: "<gcp_zone>" GCP_MACHINE_TYPE: "e2-medium" GCP_NETWORK: "<gcp_network>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "gcp" PROXY_TIMEOUT: "5m" GCP_PROJECT_ID: "<gcp_project_id>"
1 GCP_ZONE: "<gcp_zone>"
2 GCP_MACHINE_TYPE: "e2-medium"
3 GCP_NETWORK: "<gcp_network>"
4 PEERPODS_LIMIT_PER_NODE: "10"
5 TAGS: "key1=value1,key2=value2"
6 DISABLECVM: "true"
- 1
- Specify the project ID you want to use.
- 2
- Specify the
GCP_ZONE
value that you retrieved. This zone will run the workload. - 3
- Specify the machine type that matches the requirements of your workload.
- 4
- Specify the
GCP_NETWORK
value you retrieved. - 5
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 6
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters.
- Click Save to apply the changes.
- Navigate to Workloads → ConfigMaps to view the new config map.
5.2.5. Creating the peer pod VM image
You must create a QCOW2 peer pod virtual machine (VM) image.
Prerequisites
-
You have installed
podman
. - You have access to a container registry.
Procedure
Clone the OpenShift sandboxed containers repository by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow git clone https://github.com/openshift/sandboxed-containers-operator.git
$ git clone https://github.com/openshift/sandboxed-containers-operator.git
Navigate to
sandboxed-containers-operator/config/peerpods/podvm/bootc
by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cd sandboxed-containers-operator/config/peerpods/podvm/bootc
$ cd sandboxed-containers-operator/config/peerpods/podvm/bootc
Log in to
registry.redhat.io
by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman login registry.redhat.io
$ podman login registry.redhat.io
You must log in to
registry.redhat.io
, because thepodman build
process must access theContainerfile.rhel
container image hosted on the registry.Set the image path for your container registry by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow IMG="<container_registry_url>/<username>/podvm-bootc:latest"
$ IMG="<container_registry_url>/<username>/podvm-bootc:latest"
Build the pod VM
bootc
image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman build -t ${IMG} -f Containerfile.rhel .
$ podman build -t ${IMG} -f Containerfile.rhel .
Log in to your container registry by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman login <container_registry_url>
$ podman login <container_registry_url>
Push the image to your container registry by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman push ${IMG}
$ podman push ${IMG}
For testing and development, you can make the image public.
Verify the
podvm-bootc
image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman images
$ podman images
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow REPOSITORY TAG IMAGE ID CREATED SIZE example.com/example_user/podvm-bootc latest 88ddab975a07 2 seconds ago 1.82 GB
REPOSITORY TAG IMAGE ID CREATED SIZE example.com/example_user/podvm-bootc latest 88ddab975a07 2 seconds ago 1.82 GB
5.2.6. Creating the peer pod VM image config map
Create a config map for the pod virtual machine (VM) image.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: gc-podvm-image-cm namespace: openshift-sandboxed-containers-operator data: IMAGE_TYPE: pre-built PODVM_IMAGE_URI: <container_registry_url>/<username>/podvm-bootc:latest IMAGE_BASE_NAME: "podvm-image" IMAGE_VERSION: "0-0-0" INSTALL_PACKAGES: "no" DISABLE_CLOUD_CONFIG: "true" UPDATE_PEERPODS_CM: "yes" BOOT_FIPS: "no" BOOTC_BUILD_CONFIG: | [[customizations.user]] name = "peerpod" password = "peerpod" groups = ["wheel", "root"] [[customizations.filesystem]] mountpoint = "/" minsize = "5 GiB" [[customizations.filesystem]] mountpoint = "/var/kata-containers" minsize = "15 GiB"
apiVersion: v1 kind: ConfigMap metadata: name: gc-podvm-image-cm namespace: openshift-sandboxed-containers-operator data: IMAGE_TYPE: pre-built PODVM_IMAGE_URI: <container_registry_url>/<username>/podvm-bootc:latest IMAGE_BASE_NAME: "podvm-image" IMAGE_VERSION: "0-0-0" INSTALL_PACKAGES: "no" DISABLE_CLOUD_CONFIG: "true" UPDATE_PEERPODS_CM: "yes" BOOT_FIPS: "no" BOOTC_BUILD_CONFIG: | [[customizations.user]] name = "peerpod" password = "peerpod" groups = ["wheel", "root"] [[customizations.filesystem]] mountpoint = "/" minsize = "5 GiB" [[customizations.filesystem]] mountpoint = "/var/kata-containers" minsize = "15 GiB"
- Click Save to apply the changes.
- Navigate to Workloads → ConfigMaps to view the new config map.
5.2.7. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator from the list of operators.
- Click the Import icon (+) in the top right corner.
In the Import YAML window, paste the following YAML manifest and add the Base64-encoded policy to it:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
- Click Save to apply the changes.
5.2.8. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a RuntimeClass
on your worker nodes.
The kata-remote
runtime class is installed on all worker nodes by default. If you want to install kata-remote
on specific nodes, you can add labels to those nodes and then define the label in the KataConfig
CR.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
Creating the KataConfig
CR automatically reboots the worker nodes. The reboot can take from 10 to more than 60 minutes. The following factors might increase 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 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 access to the cluster as a user with the
cluster-admin
role. - Optional: You have installed the Node Feature Discovery Operator if you want to enable node eligibility checks.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
- Select the OpenShift sandboxed containers Operator.
- On the KataConfig tab, click Create KataConfig.
Enter the following details:
-
Name: Optional: The default name is
example-kataconfig
. -
Labels: Optional: Enter any relevant, identifying attributes to the
KataConfig
resource. Each label represents a key-value pair. - enablePeerPods: Select for public cloud, IBM Z®, and IBM® LinuxONE deployments.
kataConfigPoolSelector. Optional: To install
kata-remote
on selected nodes, add a match expression for the labels on the selected nodes:- Expand the kataConfigPoolSelector area.
- In the kataConfigPoolSelector area, expand matchExpressions. This is a list of label selector requirements.
- Click Add matchExpressions.
- In the Key field, enter the label key the selector applies to.
-
In the Operator field, enter 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
true
orfalse
for key label value.
-
logLevel: Define the level of log data retrieved for nodes with the
kata-remote
runtime class.
-
Name: Optional: The default name is
Click Create. The
KataConfig
CR is created and installs thekata-remote
runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.
Verification
-
On the KataConfig tab, click the
KataConfig
CR to view its details. Click the YAML tab to view the
status
stanza.The
status
stanza contains theconditions
andkataNodes
keys. The value ofstatus.kataNodes
is an array of nodes, each of which lists nodes in a particular state ofkata-remote
installation. A message appears each time there is an update.Click Reload to refresh the YAML.
When all workers in the
status.kataNodes
array display the valuesinstalled
andconditions.InProgress: False
with no specified reason, thekata-remote
is installed on the cluster.
Additional resources
Verifying the pod VM image
After kata-remote
is installed on your cluster, the OpenShift sandboxed containers Operator creates a pod VM image, which is used to create peer pods. This process can take a long time because the image is created on the cloud instance. You can verify that the pod VM image was created successfully by checking the config map that you created for the cloud provider.
Procedure
- Navigate to Workloads → ConfigMaps.
- Click the provider config map to view its details.
- Click the YAML tab.
Check the
status
stanza of the YAML file.If the
PODVM_IMAGE_NAME
parameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
$ 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.
5.2.9. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
Do not deploy workloads in an Operator namespace. Create a dedicated namespace for these resources.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
5.3. Deploying OpenShift sandboxed containers by using the command line
You can deploy OpenShift sandboxed containers on Google Cloud by using the command line interface (CLI) to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Change the number of virtual machines running on each worker node.
- Optional: Enable port 15150 to allow internal communication with peer pods.
- Optional: Create the peer pods secret if you uninstalled the Cloud Credential Operator, which is installed with the OpenShift sandboxed containers Operator.
- Create the peer pods config map.
- Create the pod VM image config map.
- Optional: Customize the Kata agent policy.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
5.3.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
osc-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
Create the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-namespace.yaml
$ oc apply -f osc-namespace.yaml
Create an
osc-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: sandboxed-containers-operator-group namespace: openshift-sandboxed-containers-operator spec: targetNamespaces: - openshift-sandboxed-containers-operator
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-operatorgroup.yaml
$ oc apply -f osc-operatorgroup.yaml
Create an
osc-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.9.0
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.9.0
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-subscription.yaml
$ oc apply -f osc-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n openshift-sandboxed-containers-operator
$ watch oc get csv -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
5.3.2. Enabling port 15150 for Google Cloud
You must enable port 15150 on the OpenShift Container Platform to allow internal communication with peer pods running on Compute Engine.
Prerequisites
- You have installed the Google Cloud command line interface (CLI) tool.
-
You have access to the OpenShift Container Platform cluster as a user with the
roles/container.admin
role.
Procedure
Set the project ID variable by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export GCP_PROJECT_ID="<project_id>"
$ export GCP_PROJECT_ID="<project_id>"
Log in to Google Cloud by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud auth login
$ gcloud auth login
Set the Google Cloud project ID by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud config set project ${GCP_PROJECT_ID}
$ gcloud config set project ${GCP_PROJECT_ID}
Open port 15150 by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud compute firewall-rules create allow-port-15150-restricted \ --project=${GCP_PROJECT_ID} \ --network=default \ --allow=tcp:15150 \ --source-ranges=<external_ip_cidr-1>[,<external_ip_cidr-2>,...]
$ gcloud compute firewall-rules create allow-port-15150-restricted \ --project=${GCP_PROJECT_ID} \ --network=default \ --allow=tcp:15150 \ --source-ranges=<external_ip_cidr-1>[,<external_ip_cidr-2>,...]
1 - 1
- Specify one or more IP addresses or ranges in CIDR format, separated by commas. For example,
203.0.113.5/32,198.51.100.0/24
.
Verification
Verify that port 15150 is open by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud compute firewall-rule list
$ gcloud compute firewall-rule list
5.3.3. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
-
You have created a Google Cloud service account with permissions such as
roles/compute.instanceAdmin.v1
to manage Compute Engine resources. -
You have installed the Google Cloud SDK (
gcloud
) and authenticated it with your service account.
Procedure
Create a Google Cloud service account key and save it as a JSON file by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud iam service-accounts keys create <key_filename>.json \ --iam-account=<service_account_email_address>
$ gcloud iam service-accounts keys create <key_filename>.json \ --iam-account=<service_account_email_address>
Convert the JSON file to a single line string by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow cat <key_file>.json | jq -c .
$ cat <key_file>.json | jq -c .
Create a
peer-pods-secret.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: GCP_CREDENTIALS: "<gc_service_account_key_json>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: GCP_CREDENTIALS: "<gc_service_account_key_json>"
1 - 1
- Replace
<gc_service_account_key_json>
with the single-line string you created from the Google Cloud service account key JSON file.
Create the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-secret.yaml
$ oc apply -f peer-pods-secret.yaml
5.3.4. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Procedure
Log in to your Compute Engine instance to set the following environmental variables:
Get the project ID by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow GCP_PROJECT_ID=$(gcloud config get-value project)
$ GCP_PROJECT_ID=$(gcloud config get-value project)
Get the zone by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow GCP_ZONE=$(gcloud config get-value compute/zone)
$ GCP_ZONE=$(gcloud config get-value compute/zone)
Retrieve a list of network names by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow gcloud compute networks list --format="value(name)"
$ gcloud compute networks list --format="value(name)"
Specify the network by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow GCP_NETWORK=<network_name>
$ GCP_NETWORK=<network_name>
1 - 1
- Replace
<network_name>
with the name of the network.
Create a
peer-pods-cm.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "gcp" PROXY_TIMEOUT: "5m" GCP_PROJECT_ID: "<gcp_project_id>" GCP_ZONE: "<gcp_zone>" GCP_MACHINE_TYPE: "e2-medium" GCP_NETWORK: "<gcp_network>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "gcp" PROXY_TIMEOUT: "5m" GCP_PROJECT_ID: "<gcp_project_id>"
1 GCP_ZONE: "<gcp_zone>"
2 GCP_MACHINE_TYPE: "e2-medium"
3 GCP_NETWORK: "<gcp_network>"
4 PEERPODS_LIMIT_PER_NODE: "10"
5 TAGS: "key1=value1,key2=value2"
6 DISABLECVM: "true"
- 1
- Specify the project ID you want to use.
- 2
- Specify the
GCP_ZONE
value that you retrieved. This zone will run the workload. - 3
- Specify the machine type that matches the requirements of your workload.
- 4
- Specify the
GCP_NETWORK
value you retrieved. - 5
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 6
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-cm.yaml
$ oc apply -f peer-pods-cm.yaml
5.3.5. Creating the peer pod VM image
You must create a QCOW2 peer pod virtual machine (VM) image.
Prerequisites
-
You have installed
podman
. - You have access to a container registry.
Procedure
Clone the OpenShift sandboxed containers repository by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow git clone https://github.com/openshift/sandboxed-containers-operator.git
$ git clone https://github.com/openshift/sandboxed-containers-operator.git
Navigate to
sandboxed-containers-operator/config/peerpods/podvm/bootc
by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cd sandboxed-containers-operator/config/peerpods/podvm/bootc
$ cd sandboxed-containers-operator/config/peerpods/podvm/bootc
Log in to
registry.redhat.io
by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman login registry.redhat.io
$ podman login registry.redhat.io
You must log in to
registry.redhat.io
, because thepodman build
process must access theContainerfile.rhel
container image hosted on the registry.Set the image path for your container registry by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow IMG="<container_registry_url>/<username>/podvm-bootc:latest"
$ IMG="<container_registry_url>/<username>/podvm-bootc:latest"
Build the pod VM
bootc
image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman build -t ${IMG} -f Containerfile.rhel .
$ podman build -t ${IMG} -f Containerfile.rhel .
Log in to your container registry by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman login <container_registry_url>
$ podman login <container_registry_url>
Push the image to your container registry by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman push ${IMG}
$ podman push ${IMG}
For testing and development, you can make the image public.
Verify the
podvm-bootc
image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman images
$ podman images
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow REPOSITORY TAG IMAGE ID CREATED SIZE example.com/example_user/podvm-bootc latest 88ddab975a07 2 seconds ago 1.82 GB
REPOSITORY TAG IMAGE ID CREATED SIZE example.com/example_user/podvm-bootc latest 88ddab975a07 2 seconds ago 1.82 GB
5.3.6. Creating the peer pod VM image config map
Create a config map for the pod virtual machine (VM) image.
Procedure
Create a config map manifest for the pod VM image named
gc-podvm-image-cm.yaml
with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: gc-podvm-image-cm namespace: openshift-sandboxed-containers-operator data: IMAGE_TYPE: pre-built PODVM_IMAGE_URI: <container_registry_url>/<username>/podvm-bootc:latest IMAGE_BASE_NAME: "podvm-image" IMAGE_VERSION: "0-0-0" INSTALL_PACKAGES: "no" DISABLE_CLOUD_CONFIG: "true" UPDATE_PEERPODS_CM: "yes" BOOT_FIPS: "no" BOOTC_BUILD_CONFIG: | [[customizations.user]] name = "peerpod" password = "peerpod" groups = ["wheel", "root"] [[customizations.filesystem]] mountpoint = "/" minsize = "5 GiB" [[customizations.filesystem]] mountpoint = "/var/kata-containers" minsize = "15 GiB"
apiVersion: v1 kind: ConfigMap metadata: name: gc-podvm-image-cm namespace: openshift-sandboxed-containers-operator data: IMAGE_TYPE: pre-built PODVM_IMAGE_URI: <container_registry_url>/<username>/podvm-bootc:latest IMAGE_BASE_NAME: "podvm-image" IMAGE_VERSION: "0-0-0" INSTALL_PACKAGES: "no" DISABLE_CLOUD_CONFIG: "true" UPDATE_PEERPODS_CM: "yes" BOOT_FIPS: "no" BOOTC_BUILD_CONFIG: | [[customizations.user]] name = "peerpod" password = "peerpod" groups = ["wheel", "root"] [[customizations.filesystem]] mountpoint = "/" minsize = "5 GiB" [[customizations.filesystem]] mountpoint = "/var/kata-containers" minsize = "15 GiB"
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f gc-podvm-image-cm.yaml
$ oc apply -f gc-podvm-image-cm.yaml
5.3.7. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
Add the Base64-encoded policy to a
my-pod.yaml
pod specification file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
Apply the pod manifest by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f my-pod.yaml
$ oc apply -f my-pod.yaml
5.3.8. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a runtime class on your worker nodes.
Creating the KataConfig
CR triggers the OpenShift sandboxed containers Operator to do the following:
-
Create a
RuntimeClass
CR namedkata-remote
with a default configuration. This enables users to configure workloads to usekata-remote
as the runtime by referencing the CR in theRuntimeClassName
field. This CR also specifies the resource overhead for the runtime.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 - 1
- Optional: If you have applied node labels to install
kata-remote
on specific nodes, specify the key and value, for example,osc: 'true'
.
Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
Verifying the pod VM image
After kata-remote
is installed on your cluster, the OpenShift sandboxed containers Operator creates a pod VM image, which is used to create peer pods. This process can take a long time because the image is created on the cloud instance. You can verify that the pod VM image was created successfully by checking the config map that you created for the cloud provider.
Procedure
Obtain the config map you created for the peer pods:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
$ oc get configmap peer-pods-cm -n openshift-sandboxed-containers-operator -o yaml
Check the
status
stanza of the YAML file.If the
PODVM_IMAGE_NAME
parameter is populated, the pod VM image was created successfully.
Troubleshooting
Retrieve the events log by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get events -n openshift-sandboxed-containers-operator --field-selector involvedObject.name=osc-podvm-image-creation
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n openshift-sandboxed-containers-operator jobs/osc-podvm-image-creation
$ 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.
5.3.9. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
Do not deploy workloads in an Operator namespace. Create a dedicated namespace for these resources.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
Chapter 6. Deploying OpenShift sandboxed containers on IBM Z and IBM LinuxONE
You can deploy OpenShift sandboxed containers on IBM Z® and IBM® LinuxONE.
OpenShift sandboxed containers deploys peer pods. The peer pod design circumvents the need for nested virtualization. For more information, see peer pod and Peer pods technical deep dive.
OpenShift sandboxed containers on IBM Z® and IBM® LinuxONE 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.
Cluster requirements
- You have installed Red Hat OpenShift Container Platform 4.14 or later on the cluster where you are installing the OpenShift sandboxed containers Operator.
- Your cluster has three control plane nodes and at least two worker nodes.
- Your cluster nodes and peer pods are in the same IBM Z® KVM host logical partition (LPAR).
- Your cluster nodes and peer pods are connected to the same subnet.
For details on installing OpenShift Container Platform on IBM Z® and IBM® LinuxONE see Installing on IBM Z® and IBM® LinuxONE.
6.1. Peer pod resource requirements
You must ensure that your cluster has sufficient resources.
Peer pod virtual machines (VMs) require resources in two locations:
-
The worker node. The worker node stores metadata, Kata shim resources (
containerd-shim-kata-v2
), remote-hypervisor resources (cloud-api-adaptor
), and the tunnel setup between the worker nodes and the peer pod VM. - The libvirt virtual machine instance. This is the actual peer pod VM running in the LPAR (KVM host).
The CPU and memory resources used in the Kubernetes worker node are handled by the pod overhead included in the RuntimeClass (kata-remote
) definition used for creating peer pods.
The total number of peer pod VMs running in the cloud is defined as Kubernetes Node extended resources. This limit is per node and is set by the PEERPODS_LIMIT_PER_NODE
attribute in the peer-pods-cm
config map.
The extended resource is named kata.peerpods.io/vm
, and enables the Kubernetes scheduler to handle capacity tracking and accounting.
You can edit the limit per node based on the requirements for your environment after you install the OpenShift sandboxed containers Operator.
A mutating webhook adds the extended resource kata.peerpods.io/vm
to the pod specification. It also removes any resource-specific entries from the pod specification, if present. This enables the Kubernetes scheduler to account for these extended resources, ensuring the peer pod is only scheduled when resources are available.
The mutating webhook modifies a Kubernetes pod as follows:
-
The mutating webhook checks the pod for the expected
RuntimeClassName
value, specified in theTARGET_RUNTIME_CLASS
environment variable. If the value in the pod specification does not match the value in theTARGET_RUNTIME_CLASS
, the webhook exits without modifying the pod. If the
RuntimeClassName
values match, the webhook makes the following changes to the pod spec:-
The webhook removes every resource specification from the
resources
field of all containers and init containers in the pod. -
The webhook adds the extended resource (
kata.peerpods.io/vm
) to the spec by modifying the resources field of the first container in the pod. The extended resourcekata.peerpods.io/vm
is used by the Kubernetes scheduler for accounting purposes.
-
The webhook removes every resource specification from the
The mutating webhook excludes specific system namespaces in OpenShift Container Platform from mutation. If a peer pod is created in those system namespaces, then resource accounting using Kubernetes extended resources does not work unless the pod spec includes the extended resource.
As a best practice, define a cluster-wide policy to only allow peer pod creation in specific namespaces.
6.2. Deploying OpenShift sandboxed containers on IBM Z and IBM LinuxONE
You can deploy OpenShift sandboxed containers on IBM Z® and IBM® LinuxONE by using the command line interface (CLI) to perform the following tasks:
- Install the OpenShift sandboxed containers Operator.
- Optional: Change the number of virtual machines running on each worker node.
- Optional: Configure the libvirt volume.
- Optional: Create a custom peer pod VM image.
- Create the peer pods secret.
- Create the peer pods config map.
- Create the pod VM image config map.
- Create the KVM host secret.
- Optional: Select a custom peer pod VM image.
- Optional: Customize the Kata agent policy.
-
Create the
KataConfig
custom resource. - Configure the OpenShift sandboxed containers workload objects.
6.2.1. Installing the OpenShift sandboxed containers Operator
You can install the OpenShift sandboxed containers Operator by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
osc-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
Create the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-namespace.yaml
$ oc apply -f osc-namespace.yaml
Create an
osc-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: sandboxed-containers-operator-group namespace: openshift-sandboxed-containers-operator spec: targetNamespaces: - openshift-sandboxed-containers-operator
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-operatorgroup.yaml
$ oc apply -f osc-operatorgroup.yaml
Create an
osc-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.9.0
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.9.0
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f osc-subscription.yaml
$ oc apply -f osc-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operator
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n openshift-sandboxed-containers-operator
$ watch oc get csv -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.9.0 1.8.1 Succeeded
Additional resources
- Using Operator Lifecycle Manager on restricted networks.
- Configuring proxy support in Operator Lifecycle Manager for disconnected environments.
6.2.2. Configuring the libvirt volume
The OpenShift sandboxed containers Operator configures the libvirt volume and pool on your KVM host automatically during installation. If required, you can manually configure or create additional libvirt volumes and pools.
Prerequisites
- You have installed the OpenShift sandboxed containers Operator on your OpenShift Container Platform cluster by using the OpenShift Container Platform web console or the command line.
- You have administrator privileges for your KVM host.
-
You have installed
podman
on your KVM host. -
You have installed
virt-customize
on your KVM host. -
You have a
/var/lib/libvirt/images/
directory for your images.
Procedure
- Log in to the KVM host.
Set the name of the libvirt pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_POOL=<libvirt_pool>
$ export LIBVIRT_POOL=<libvirt_pool>
You need the
LIBVIRT_POOL
value to create the secret for the libvirt provider.Set the name of the libvirt volume by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_VOL_NAME=<libvirt_volume>
$ export LIBVIRT_VOL_NAME=<libvirt_volume>
You need the
LIBVIRT_VOL_NAME
value to create the secret for the libvirt provider.Set the path of the default storage pool location, by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_POOL_DIRECTORY="/var/lib/libvirt/images/"
$ export LIBVIRT_POOL_DIRECTORY="/var/lib/libvirt/images/"
Create a libvirt pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh pool-define-as $LIBVIRT_POOL --type dir --target "$LIBVIRT_POOL_DIRECTORY"
$ virsh pool-define-as $LIBVIRT_POOL --type dir --target "$LIBVIRT_POOL_DIRECTORY"
Start the libvirt pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh pool-start $LIBVIRT_POOL
$ virsh pool-start $LIBVIRT_POOL
Create a libvirt volume for the pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh -c qemu:///system \ vol-create-as --pool $LIBVIRT_POOL \ --name $LIBVIRT_VOL_NAME \ --capacity 20G \ --allocation 2G \ --prealloc-metadata \ --format qcow2
$ virsh -c qemu:///system \ vol-create-as --pool $LIBVIRT_POOL \ --name $LIBVIRT_VOL_NAME \ --capacity 20G \ --allocation 2G \ --prealloc-metadata \ --format qcow2
6.2.3. Creating a custom peer pod VM image
You can create a custom peer pod virtual machine (VM) image instead of using the default Operator-built image.
You build an Open Container Initiative (OCI) container with the peer pod QCOW2 image. Later, you add the container registry URL and the image path to the peer pod VM image config map.
Procedure
Create a
Dockerfile.podvm-oci
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow FROM scratch ARG PODVM_IMAGE_SRC ENV PODVM_IMAGE_PATH="/image/podvm.qcow2" COPY $PODVM_IMAGE_SRC $PODVM_IMAGE_PATH
FROM scratch ARG PODVM_IMAGE_SRC ENV PODVM_IMAGE_PATH="/image/podvm.qcow2" COPY $PODVM_IMAGE_SRC $PODVM_IMAGE_PATH
Build a container with the pod VM QCOW2 image by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow docker build -t podvm-libvirt \ --build-arg PODVM_IMAGE_SRC=<podvm_image_source> \ --build-arg PODVM_IMAGE_PATH=<podvm_image_path> \ -f Dockerfile.podvm-oci .
$ docker build -t podvm-libvirt \ --build-arg PODVM_IMAGE_SRC=<podvm_image_source> \
1 --build-arg PODVM_IMAGE_PATH=<podvm_image_path> \
2 -f Dockerfile.podvm-oci .
6.2.4. Creating the peer pods secret
When the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must create the peer pods secret for OpenShift sandboxed containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
LIBVIRT_URI
. This value is the default gateway IP address of the libvirt network. Check your libvirt network setup to obtain this value.NoteIf libvirt uses the default bridge virtual network, you can obtain the
LIBVIRT_URI
by running the following commands:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virtint=$(bridge_line=$(virsh net-info default | grep Bridge); echo "${bridge_line//Bridge:/}" | tr -d [:blank:]) LIBVIRT_URI=$( ip -4 addr show $virtint | grep -oP '(?<=inet\s)\d+(\.\d+){3}') LIBVIRT_GATEWAY_URI="qemu+ssh://root@${LIBVIRT_URI}/system?no_verify=1"
$ virtint=$(bridge_line=$(virsh net-info default | grep Bridge); echo "${bridge_line//Bridge:/}" | tr -d [:blank:]) $ LIBVIRT_URI=$( ip -4 addr show $virtint | grep -oP '(?<=inet\s)\d+(\.\d+){3}') $ LIBVIRT_GATEWAY_URI="qemu+ssh://root@${LIBVIRT_URI}/system?no_verify=1"
-
REDHAT_OFFLINE_TOKEN
. You have generated this token to download the RHEL image at Red Hat API Tokens.
Procedure
Create a
peer-pods-secret.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: CLOUD_PROVIDER: "libvirt" LIBVIRT_URI: "<libvirt_gateway_uri>" REDHAT_OFFLINE_TOKEN: "<rh_offline_token>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: CLOUD_PROVIDER: "libvirt" LIBVIRT_URI: "<libvirt_gateway_uri>"
1 REDHAT_OFFLINE_TOKEN: "<rh_offline_token>"
2 Create the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-secret.yaml
$ oc apply -f peer-pods-secret.yaml
6.2.5. Creating the peer pods config map
You must create the peer pods config map for OpenShift sandboxed containers.
Procedure
Create a
peer-pods-cm.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "libvirt" PEERPODS_LIMIT_PER_NODE: "10" LIBVIRT_POOL: "<libvirt_pool>" LIBVIRT_VOL_NAME: "<libvirt_volume>" LIBVIRT_DIR_NAME: "/var/lib/libvirt/images/<directory_name>" LIBVIRT_NET: "default" DISABLECVM: "true"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "libvirt" PEERPODS_LIMIT_PER_NODE: "10"
1 LIBVIRT_POOL: "<libvirt_pool>"
2 LIBVIRT_VOL_NAME: "<libvirt_volume>"
3 LIBVIRT_DIR_NAME: "/var/lib/libvirt/images/<directory_name>"
4 LIBVIRT_NET: "default"
5 DISABLECVM: "true"
- 1
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 2
- Specify the libvirt pool. If you have manually configured the libvirt pool, use the same name as in your KVM host configuration.
- 3
- Specify the libvirt volume name. If you have manually configured the libvirt volume, use the same name as in your KVM host configuration.
- 4
- Specify the libvirt directory for storing virtual machine disk images, such as
.qcow2
, or.raw
files. To ensure libvirt has read and write access permissions, use a subdirectory of the libvirt storage directory. The default is/var/lib/libvirt/images/
. - 5
- Optional: Specify a libvirt network if you do not want to use the default network.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-cm.yaml
$ oc apply -f peer-pods-cm.yaml
6.2.6. Creating the peer pod VM image config map
You must create a config map for the peer pod virtual machine (VM) image.
Prerequisites
- You must create an activation key by using the Red Hat Hybrid Cloud Console.
- Optional: If you want to use a Cloud API Adaptor custom image, you must have the name, URL, and the branch or tag of the image.
Procedure
Create a
libvirt-podvm-image-cm.yaml
manifest according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: libvirt-podvm-image-cm namespace: openshift-sandboxed-containers-operator data: PODVM_DISTRO: "rhel" DOWNLOAD_SOURCES: "no" CAA_SRC: "https://github.com/confidential-containers/cloud-api-adaptor" CAA_REF: "main" CONFIDENTIAL_COMPUTE_ENABLED: "yes" UPDATE_PEERPODS_CM: "yes" ORG_ID: "<rhel_organization_id>" ACTIVATION_KEY: "<rhel_activation_key>" IMAGE_NAME: "<podvm_libvirt_image>" PODVM_IMAGE_URI: "oci::<image_repo_url>:<image_tag>::<image_path>" SE_BOOT: "true" BASE_OS_VERSION: "<rhel_image_os_version>"
apiVersion: v1 kind: ConfigMap metadata: name: libvirt-podvm-image-cm namespace: openshift-sandboxed-containers-operator data: PODVM_DISTRO: "rhel" DOWNLOAD_SOURCES: "no"
1 CAA_SRC: "https://github.com/confidential-containers/cloud-api-adaptor"
2 CAA_REF: "main"
3 CONFIDENTIAL_COMPUTE_ENABLED: "yes" UPDATE_PEERPODS_CM: "yes" ORG_ID: "<rhel_organization_id>" ACTIVATION_KEY: "<rhel_activation_key>"
4 IMAGE_NAME: "<podvm_libvirt_image>"
5 PODVM_IMAGE_URI: "oci::<image_repo_url>:<image_tag>::<image_path>"
6 SE_BOOT: "true"
7 BASE_OS_VERSION: "<rhel_image_os_version>"
8 - 1
- Specify
yes
if you want to use the custom Cloud API Adaptor source to build the pod VM image. - 2
- Optional: Specify the URL of the Cloud API Adaptor custom image.
- 3
- Optional: Specify the branch or tag of the Cloud API Adaptor custom image.
- 4
- Specify your RHEL activation key.
- 5
- Specify the custom peer pod VM image name.
- 6
- Optional: If you created a custom peer pod VM image, specify the container registry URL, the image tag, and the image path (default:
/image/podvm.qcow2
). Otherwise, set the value to""
. - 7
- The default value,
true
, enables IBM Secure Execution for the default Operator-built image. If you use a custom peer pod VM image, set it tofalse
. - 8
- Specify the RHEL image operating system version. IBM Z® Secure Execution supports RHEL 9.5 and later versions.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f libvirt-podvm-image-cm.yaml
$ oc apply -f libvirt-podvm-image-cm.yaml
The libvirt pod VM image config map is created for your libvirt provider.
6.2.7. Creating the KVM host secret
You must create the secret for your KVM host.
Procedure
Generate an SSH key pair by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh-keygen -f ./id_rsa -N ""
$ ssh-keygen -f ./id_rsa -N ""
Copy the public SSH key to your KVM host:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh-copy-id -i ./id_rsa.pub <KVM_HOST_IP>
$ ssh-copy-id -i ./id_rsa.pub <KVM_HOST_IP>
1 - 1
- Specify the IP address of your KVM host or the LPAR where the peer pod VM is running. For example,
192.168.122.1
.
Create the
Secret
object by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create secret generic ssh-key-secret \ -n openshift-sandboxed-containers-operator \ --from-file=id_rsa.pub=./id_rsa.pub \ --from-file=id_rsa=./id_rsa
$ oc create secret generic ssh-key-secret \ -n openshift-sandboxed-containers-operator \ --from-file=id_rsa.pub=./id_rsa.pub \ --from-file=id_rsa=./id_rsa
Delete the SSH keys you created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow shred --remove id_rsa.pub id_rsa
$ shred --remove id_rsa.pub id_rsa
6.2.8. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map. You create a new libvirt volume in your libvirt pool and upload the custom peer pod VM image to the new volume. Then, you update the pod manifest to use the custom peer pod VM image.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
Set the name of the libvirt pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_POOL=<libvirt_pool>
$ export LIBVIRT_POOL=<libvirt_pool>
1 - 1
- Specify the existing libvirt pool name.
Set the name of the new libvirt volume by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_VOL_NAME=<new_libvirt_volume>
$ export LIBVIRT_VOL_NAME=<new_libvirt_volume>
Create a libvirt volume for the pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh -c qemu:///system \ vol-create-as --pool $LIBVIRT_POOL \ --name $LIBVIRT_VOL_NAME \ --capacity 20G \ --allocation 2G \ --prealloc-metadata \ --format qcow2
$ virsh -c qemu:///system \ vol-create-as --pool $LIBVIRT_POOL \ --name $LIBVIRT_VOL_NAME \ --capacity 20G \ --allocation 2G \ --prealloc-metadata \ --format qcow2
Upload the custom peer pod VM image to the libvirt volume:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh -c qemu:///system vol-upload \ --vol $LIBVIRT_VOL_NAME <custom_podvm_image.qcow2> \ --pool $LIBVIRT_POOL --sparse
$ virsh -c qemu:///system vol-upload \ --vol $LIBVIRT_VOL_NAME <custom_podvm_image.qcow2> \
1 --pool $LIBVIRT_POOL --sparse
- 1
- Specify the custom peer pod VM image name.
Create a
pod-manifest.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<new_libvirt_volume>" spec: runtimeClassName: kata-remote containers: - name: <example_container> image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<new_libvirt_volume>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f pod-manifest.yaml
$ oc apply -f pod-manifest.yaml
6.2.9. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
Add the Base64-encoded policy to a
my-pod.yaml
pod specification file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
Apply the pod manifest by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f my-pod.yaml
$ oc apply -f my-pod.yaml
6.2.10. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a runtime class on your worker nodes.
Creating the KataConfig
CR triggers the OpenShift sandboxed containers Operator to do the following:
-
Create a
RuntimeClass
CR namedkata-remote
with a default configuration. This enables users to configure workloads to usekata-remote
as the runtime by referencing the CR in theRuntimeClassName
field. This CR also specifies the resource overhead for the runtime.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 - 1
- Optional: If you have applied node labels to install
kata-remote
on specific nodes, specify the key and value, for example,osc: 'true'
.
Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify that you have built the peer pod image and uploaded it to the libvirt volume by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc describe configmap peer-pods-cm -n openshift-sandboxed-containers-operator
$ oc describe configmap peer-pods-cm -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Name: peer-pods-cm Namespace: openshift-sandboxed-containers-operator Labels: <none> Annotations: <none> Data ==== CLOUD_PROVIDER: libvirt BinaryData ==== Events: <none>
Name: peer-pods-cm Namespace: openshift-sandboxed-containers-operator Labels: <none> Annotations: <none> Data ==== CLOUD_PROVIDER: libvirt BinaryData ==== Events: <none>
Monitor the
kata-oc
machine config pool progress to ensure that it is in theUPDATED
state, whenUPDATEDMACHINECOUNT
equalsMACHINECOUNT
, by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get mcp/kata-oc
$ watch oc get mcp/kata-oc
Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
6.2.11. Configuring workload objects
You must configure OpenShift sandboxed containers workload objects by setting kata-remote
as the runtime class for the following pod-templated objects:
-
Pod
objects -
ReplicaSet
objects -
ReplicationController
objects -
StatefulSet
objects -
Deployment
objects -
DeploymentConfig
objects
Do not deploy workloads in an Operator namespace. Create a dedicated namespace for these resources.
Prerequisites
-
You have created the
KataConfig
custom resource (CR).
Procedure
Add
spec.runtimeClassName: kata-remote
to the manifest of each pod-templated workload object as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
apiVersion: v1 kind: <object> # ... spec: runtimeClassName: kata-remote # ...
OpenShift Container Platform creates the workload object and begins scheduling it.
Verification
-
Inspect the
spec.runtimeClassName
field of a pod-templated object. If the value iskata-remote
, then the workload is running on OpenShift sandboxed containers, using peer pods.
Chapter 7. Deploying Confidential Containers on Azure
You can deploy Confidential Containers on Microsoft Azure Cloud Computing Services after you deploy OpenShift sandboxed containers.
Confidential Containers on Azure 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.
Cluster requirements
- You have configured outbound connectivity for the pod VM subnet.
- You have installed Red Hat OpenShift Container Platform 4.15 or later on the cluster where you are installing the Confidential compute attestation Operator.
You deploy Confidential Containers by performing the following steps:
- Install the Confidential compute attestation Operator.
- Create the route for Trustee.
- Enable the Confidential Containers feature gate.
- Create initdata.
- Update the peer pods config map.
- Optional: Customize the Kata agent policy.
-
Delete the
KataConfig
custom resource (CR). -
Re-create the
KataConfig
CR. - Create the Trustee authentication secret.
- Create the Trustee config map.
- Configure Trustee values, policies, and secrets.
-
Create the
KbsConfig
CR. - Verify the Trustee configuration.
- Verify the attestation process.
7.1. Installing the Confidential compute attestation Operator
You can install the Confidential compute attestation Operator on Azure by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create a
trustee-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: trustee-operator-system
apiVersion: v1 kind: Namespace metadata: name: trustee-operator-system
Create the
trustee-operator-system
namespace by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f trustee-namespace.yaml
$ oc apply -f trustee-namespace.yaml
Create a
trustee-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: trustee-operator-group namespace: trustee-operator-system spec: targetNamespaces: - trustee-operator-system
apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: trustee-operator-group namespace: trustee-operator-system spec: targetNamespaces: - trustee-operator-system
Create the operator group by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f trustee-operatorgroup.yaml
$ oc apply -f trustee-operatorgroup.yaml
Create a
trustee-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: trustee-operator-system namespace: trustee-operator-system spec: channel: stable installPlanApproval: Automatic name: trustee-operator source: redhat-operators sourceNamespace: openshift-marketplace
apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: trustee-operator-system namespace: trustee-operator-system spec: channel: stable installPlanApproval: Automatic name: trustee-operator source: redhat-operators sourceNamespace: openshift-marketplace
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f trustee-subscription.yaml
$ oc apply -f trustee-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n trustee-operator-system
$ oc get csv -n trustee-operator-system
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n trustee-operator-system
$ watch oc get csv -n trustee-operator-system
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY PHASE trustee-operator.v0.3.0 Trustee Operator 0.3.0 Succeeded
NAME DISPLAY PHASE trustee-operator.v0.3.0 Trustee Operator 0.3.0 Succeeded
7.2. Enabling the Confidential Containers feature gate
You must enable the Confidential Containers feature gate.
Prerequisites
- You have subscribed to the OpenShift sandboxed containers Operator.
Procedure
Create a
cc-feature-gate.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: osc-feature-gates namespace: openshift-sandboxed-containers-operator data: confidential: "true"
apiVersion: v1 kind: ConfigMap metadata: name: osc-feature-gates namespace: openshift-sandboxed-containers-operator data: confidential: "true"
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f cc-feature-gate.yaml
$ oc apply -f cc-feature-gate.yaml
7.3. Creating the route for Trustee
You can create a secure route with edge TLS termination for Trustee. External ingress traffic reaches the router pods as HTTPS and passes on to the Trustee pods as HTTP.
Prerequisites
- You have installed the Confidential compute attestation Operator.
Procedure
Create an edge route by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create route edge --service=kbs-service --port kbs-port \ -n trustee-operator-system
$ oc create route edge --service=kbs-service --port kbs-port \ -n trustee-operator-system
NoteNote: Currently, only a route with a valid CA-signed certificate is supported. You cannot use a route with self-signed certificate.
Set the
TRUSTEE_HOST
variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow TRUSTEE_HOST=$(oc get route -n trustee-operator-system kbs-service \ -o jsonpath={.spec.host})
$ TRUSTEE_HOST=$(oc get route -n trustee-operator-system kbs-service \ -o jsonpath={.spec.host})
Verify the route by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow echo $TRUSTEE_HOST
$ echo $TRUSTEE_HOST
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow kbs-service-trustee-operator-system.apps.memvjias.eastus.aroapp.io
kbs-service-trustee-operator-system.apps.memvjias.eastus.aroapp.io
Record this value for the peer pods config map.
7.4. About initdata
The initdata specification provides a flexible way to initialize a peer pod with sensitive or workload-specific data at runtime, avoiding the need to embed such data in the virtual machine (VM) image. This enhances security by reducing exposure of confidential information and improves flexibility by eliminating custom image builds. For example, initdata can include three configuration settings:
- An X.509 certificate for secure communication.
- A cryptographic key for authentication.
-
An optional Kata Agent
policy.rego
file to enforce runtime behavior when overriding the default Kata Agent policy.
You can apply an initdata configuration by using one of the following methods:
- Globally by including it in the peer pods config map, setting a cluster-wide default for all pods.
For a specific pod when configuring a pod workload object, allowing customization for individual workloads.
The
io.katacontainers.config.runtime.cc_init_data
annotation you specify when configuring a pod workload object overrides the globalINITDATA
setting in the peer pods config map for that specific pod. The Kata runtime handles this precedence automatically at pod creation time.
The initdata content configures the following components:
- Attestation Agent (AA), which verifies the trustworthiness of the peer pod by sending evidence to the Trustee for attestation.
- Confidential Data Hub (CDH), which manages secrets and secure data access within the peer pod VM.
- Kata Agent, which enforces runtime policies and manages the lifecycle of the containers inside the pod VM.
7.5. Creating initdata
Create a TOML file with initdata and convert it to a Base64-encoded string. Use this string to specify the value in the peer pods config map, in the peer pod manifest, or in the verification-pod.yaml
file.
You must delete the kbs_cert
setting if you configure insecure_http = true
in the Trustee config map.
Procedure
Create the
initdata.toml
configuration file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ```toml algorithm = "sha384" version = "0.1.0" [data] "aa.toml" = ''' [token_configs] [token_configs.coco_as] url = '<url>:<port>' [token_configs.kbs] url = '<url>:<port>' cert = """ -----BEGIN CERTIFICATE----- <kbs_certificate> -----END CERTIFICATE----- """ ''' "cdh.toml" = ''' socket = 'unix:///run/confidential-containers/cdh.sock' credentials = [] [kbc] name = 'cc_kbc' url = '<url>:<port>' kbs_cert = """ -----BEGIN CERTIFICATE----- <kbs_certificate> -----END CERTIFICATE----- """ ''' "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 ExecProcessRequest := 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 := true default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default ReseedRandomDevRequest := true default ResumeContainerRequest := true default SetGuestDateTimeRequest := true default SetPolicyRequest := 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 WriteStreamRequest := true ''' ```
```toml algorithm = "sha384" version = "0.1.0" [data] "aa.toml" = ''' [token_configs] [token_configs.coco_as] url = '<url>:<port>'
1 [token_configs.kbs] url = '<url>:<port>' cert = """ -----BEGIN CERTIFICATE----- <kbs_certificate>
2 -----END CERTIFICATE----- """ ''' "cdh.toml" = ''' socket = 'unix:///run/confidential-containers/cdh.sock' credentials = [] [kbc] name = 'cc_kbc' url = '<url>:<port>' kbs_cert = """
3 -----BEGIN CERTIFICATE----- <kbs_certificate>
4 -----END CERTIFICATE----- """ ''' "policy.rego" = '''
5 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 ExecProcessRequest := 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 := true default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default ReseedRandomDevRequest := true default ResumeContainerRequest := true default SetGuestDateTimeRequest := true default SetPolicyRequest := 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 WriteStreamRequest := true ''' ```
- 1
- Specify the URL and port of the Trustee instance. If you configure the Trustee with
insecure_http
for testing purposes, use HTTP. Otherwise, use HTTPS. For production systems, avoid usinginsecure_http
unless you configure your environment to handle TLS externally, for example, with a proxy. - 2
- Specify the Base64-encoded TLS certificate for the attestation agent. This is not required for testing purposes, but it is recommended for production systems.
- 3
- Delete the
kbs_cert
setting if you configureinsecure_http = true
in the Trustee config map. - 4
- Specify the Base64-encoded TLS certificate for the Trustee instance.
- 5
- Optional: You can specify a custom Kata Agent policy.
Convert the
initdata.toml
file to a Base64-encoded string in a text file by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 initdata.toml > initdata.txt
$ base64 -w0 initdata.toml > initdata.txt
7.6. Updating the peer pods config map
You must update the peer pods config map for Confidential Containers.
Set Secure Boot to true
to enable it by default. The default value is false
, which presents a security risk.
Procedure
Obtain the following values from your Azure instance:
Retrieve and record the Azure resource group:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.azure.resourceGroupName}') && echo "AZURE_RESOURCE_GROUP: \"$AZURE_RESOURCE_GROUP\""
$ AZURE_RESOURCE_GROUP=$(oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.azure.resourceGroupName}') && echo "AZURE_RESOURCE_GROUP: \"$AZURE_RESOURCE_GROUP\""
Retrieve and record the Azure VNet name:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_VNET_NAME=$(az network vnet list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Name:name}" --output tsv)
$ AZURE_VNET_NAME=$(az network vnet list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Name:name}" --output tsv)
This value is used to retrieve the Azure subnet ID.
Retrieve and record the Azure subnet ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_SUBNET_ID=$(az network vnet subnet list --resource-group ${AZURE_RESOURCE_GROUP} --vnet-name $AZURE_VNET_NAME --query "[].{Id:id} | [? contains(Id, 'worker')]" --output tsv) && echo "AZURE_SUBNET_ID: \"$AZURE_SUBNET_ID\""
$ AZURE_SUBNET_ID=$(az network vnet subnet list --resource-group ${AZURE_RESOURCE_GROUP} --vnet-name $AZURE_VNET_NAME --query "[].{Id:id} | [? contains(Id, 'worker')]" --output tsv) && echo "AZURE_SUBNET_ID: \"$AZURE_SUBNET_ID\""
Retrieve and record the Azure network security group (NSG) ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_NSG_ID=$(az network nsg list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Id:id}" --output tsv) && echo "AZURE_NSG_ID: \"$AZURE_NSG_ID\""
$ AZURE_NSG_ID=$(az network nsg list --resource-group ${AZURE_RESOURCE_GROUP} --query "[].{Id:id}" --output tsv) && echo "AZURE_NSG_ID: \"$AZURE_NSG_ID\""
Retrieve and record the Azure region:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP} --query "{Location:location}" --output tsv) && echo "AZURE_REGION: \"$AZURE_REGION\""
$ AZURE_REGION=$(az group show --resource-group ${AZURE_RESOURCE_GROUP} --query "{Location:location}" --output tsv) && echo "AZURE_REGION: \"$AZURE_REGION\""
Create a
peer-pods-cm.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "azure" VXLAN_PORT: "9000" AZURE_INSTANCE_SIZE: "Standard_DC2as_v5" AZURE_INSTANCE_SIZES: "Standard_DC2as_v5, Standard_DC4as_v5, Standard_DC8as_v5" AZURE_SUBNET_ID: "<azure_subnet_id>" AZURE_NSG_ID: "<azure_nsg_id>" PROXY_TIMEOUT: "5m" AZURE_IMAGE_ID: "<azure_image_id>" AZURE_REGION: "<azure_region>" AZURE_RESOURCE_GROUP: "<azure_resource_group>" PEERPODS_LIMIT_PER_NODE: "10" TAGS: "key1=value1,key2=value2" INITDATA: "<base64_encoded_initdata>" ENABLE_SECURE_BOOT: "true" DISABLECVM: "false"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "azure" VXLAN_PORT: "9000" AZURE_INSTANCE_SIZE: "Standard_DC2as_v5"
1 AZURE_INSTANCE_SIZES: "Standard_DC2as_v5, Standard_DC4as_v5, Standard_DC8as_v5"
2 AZURE_SUBNET_ID: "<azure_subnet_id>"
3 AZURE_NSG_ID: "<azure_nsg_id>"
4 PROXY_TIMEOUT: "5m" AZURE_IMAGE_ID: "<azure_image_id>"
5 AZURE_REGION: "<azure_region>"
6 AZURE_RESOURCE_GROUP: "<azure_resource_group>"
7 PEERPODS_LIMIT_PER_NODE: "10"
8 TAGS: "key1=value1,key2=value2"
9 INITDATA: "<base64_encoded_initdata>"
10 ENABLE_SECURE_BOOT: "true"
11 DISABLECVM: "false"
- 1
- The
"Standard_DC2as_v5"
value is the default if an instance size is not defined in the workload. Ensure the instance type supports the trusted environment. The default"Standard_DC2as_v5"
value is for AMD SEV-SNP. If your TEE is Intel TDX, specifyStandard_EC4eds_v5
. - 2
- Lists all of the instance sizes you can specify when creating the pod. This allows you to define smaller instance sizes for workloads that need less memory and fewer CPUs or larger instance sizes for larger workloads. For Intel TDX, specify
"Standard_EC4eds_v5, Standard_EC8eds_v5, Standard_EC16eds_v5"
. - 3
- Specify the
AZURE_SUBNET_ID
value that you retrieved. - 4
- Specify the
AZURE_NSG_ID
value that you retrieved. - 5
- Optional: By default, this value is populated when you run the
KataConfig
CR, using an Azure image ID based on your cluster credentials. If you create your own Azure image, specify the correct image ID. - 6
- Specify the
AZURE_REGION
value you retrieved. - 7
- Specify the
AZURE_RESOURCE_GROUP
value you retrieved. - 8
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 9
- You can configure custom tags as
key:value
pairs for pod VM instances to track peer pod costs or to identify peer pods in different clusters. - 10
- Specify the Base64-encoded string you created in the
initdata.txt
file. - 11
- Specify
true
to enable Secure Boot by default.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-cm.yaml
$ oc apply -f peer-pods-cm.yaml
Restart the
ds/osc-caa-ds
daemon set by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc set env ds/osc-caa-ds \ -n openshift-sandboxed-containers-operator REBOOT="$(date)"
$ oc set env ds/osc-caa-ds \ -n openshift-sandboxed-containers-operator REBOOT="$(date)"
7.7. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
By default, the Kata agent policy disables the exec
and log
APIs, as they might transmit or receive unencrypted data through the control plane, which is insecure.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
Enabling the exec
or log
APIs in Confidential Containers workloads might expose sensitive information. Do not enable these APIs in production environments.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
Add the Base64-encoded policy to a
my-pod.yaml
pod specification file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
Apply the pod manifest by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f my-pod.yaml
$ oc apply -f my-pod.yaml
7.8. Deleting the KataConfig custom resource
You can delete the KataConfig
custom resource (CR) by using the command line.
Deleting the KataConfig
CR removes the runtime and its related resources from your cluster.
Deleting 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 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 CPU and network.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Delete the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete kataconfig example-kataconfig
$ 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
KataConfig
CR, the CLI stops responding until all worker nodes reboot. You must wait for the deletion process to complete before performing the verification.Verify that the custom resource was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get kataconfig example-kataconfig
$ oc get kataconfig example-kataconfig
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow No example-kataconfig instances exist
No example-kataconfig instances exist
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
7.9. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
Edit the pod manifest by adding the
io.katacontainers.config.hypervisor.image
annotation and save it in apod-manifest.yaml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: 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"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<custom_image_id>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f pod-manifest.yaml
$ oc apply -f pod-manifest.yaml
7.10. Re-creating the KataConfig custom resource
You must re-create the KataConfig
custom resource (CR) for Confidential Containers.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 - 1
- Optional: If you have applied node labels to install
kata-remote
on specific nodes, specify the key and value, for example,cc: 'true'
.
Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
7.11. Creating the Trustee authentication secret
You must create the authentication secret for Trustee.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create a private key by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl genpkey -algorithm ed25519 > privateKey
$ openssl genpkey -algorithm ed25519 > privateKey
Create a public key by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl pkey -in privateKey -pubout -out publicKey
$ openssl pkey -in privateKey -pubout -out publicKey
Create a secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create secret generic kbs-auth-public-key --from-file=publicKey -n trustee-operator-system
$ oc create secret generic kbs-auth-public-key --from-file=publicKey -n trustee-operator-system
Verify the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get secret -n trustee-operator-system
$ oc get secret -n trustee-operator-system
7.12. Creating the Trustee config map
You must create the config map to configure the Trustee server.
The following configuration example turns off security features to enable demonstration of Technology Preview features. It is not meant for a production environment.
Prerequisites
- You have created a route for Trustee.
Procedure
Create a
kbs-config-cm.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: kbs-config-cm namespace: trustee-operator-system data: kbs-config.toml: | [http_server] sockets = ["0.0.0.0:8080"] insecure_http = true [admin] insecure_api = true auth_public_key = "/etc/auth-secret/publicKey" [attestation_token] insecure_key = true attestation_token_type = "CoCo" [attestation_service] type = "coco_as_builtin" work_dir = "/opt/confidential-containers/attestation-service" policy_engine = "opa" [attestation_service.attestation_token_broker] type = "Ear" policy_dir = "/opt/confidential-containers/attestation-service/policies" [attestation_service.attestation_token_config] duration_min = 5 [attestation_service.rvps_config] type = "BuiltIn" [attestation_service.rvps_config.storage] type = "LocalJson" file_path = "/opt/confidential-containers/rvps/reference-values/reference-values.json" [[plugins]] name = "resource" type = "LocalFs" dir_path = "/opt/confidential-containers/kbs/repository" [policy_engine] policy_path = "/opt/confidential-containers/opa/policy.rego"
apiVersion: v1 kind: ConfigMap metadata: name: kbs-config-cm namespace: trustee-operator-system data: kbs-config.toml: | [http_server] sockets = ["0.0.0.0:8080"] insecure_http = true [admin] insecure_api = true auth_public_key = "/etc/auth-secret/publicKey" [attestation_token] insecure_key = true attestation_token_type = "CoCo" [attestation_service] type = "coco_as_builtin" work_dir = "/opt/confidential-containers/attestation-service" policy_engine = "opa" [attestation_service.attestation_token_broker] type = "Ear" policy_dir = "/opt/confidential-containers/attestation-service/policies" [attestation_service.attestation_token_config] duration_min = 5 [attestation_service.rvps_config] type = "BuiltIn" [attestation_service.rvps_config.storage] type = "LocalJson" file_path = "/opt/confidential-containers/rvps/reference-values/reference-values.json" [[plugins]] name = "resource" type = "LocalFs" dir_path = "/opt/confidential-containers/kbs/repository" [policy_engine] policy_path = "/opt/confidential-containers/opa/policy.rego"
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f kbs-config-cm.yaml
$ oc apply -f kbs-config-cm.yaml
7.13. Configuring Trustee values, policies, and secrets
You can configure the following values, policies, and secrets for Trustee:
- Optional: Reference values for the Reference Value Provider Service.
- Optional: Attestation policy.
- Provisioning Certificate Caching Service for Intel Trust Domain Extensions (TDX).
- Optional: Secret for custom keys for Trustee clients.
- Optional: Secret for container image signature verification.
- Container image signature verification policy. This policy is mandatory. If you do not use container image signature verification, you must create a policy that does not verify signatures.
- Resource access policy.
7.13.1. Configuring reference values
You can configure reference values for the Reference Value Provider Service (RVPS) by specifying the trusted digests of your hardware platform.
The client collects measurements from the running software, the Trusted Execution Environment (TEE) hardware and firmware and it submits a quote with the claims to the Attestation Server. These measurements must match the trusted digests registered to the Trustee. This process ensures that the confidential VM (CVM) is running the expected software stack and has not been tampered with.
Procedure
Create an
rvps-configmap.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: rvps-reference-values namespace: trustee-operator-system data: reference-values.json: | [ ]
apiVersion: v1 kind: ConfigMap metadata: name: rvps-reference-values namespace: trustee-operator-system data: reference-values.json: | [
1 ]
- 1
- Specify the trusted digests for your hardware platform if required. Otherwise, leave it empty.
Create the RVPS config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f rvps-configmap.yaml
$ oc apply -f rvps-configmap.yaml
7.13.2. Creating an attestation policy
You can create an attestation policy that overrides the default attestation policy.
Procedure
Create an
attestation-policy.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow attestation-policy.yaml
# attestation-policy.yaml apiVersion: v1 kind: ConfigMap metadata: name: attestation-policy namespace: trustee-operator-system data: default.rego: | package policy import rego.v1 # This policy validates multiple TEE platforms # The policy is meant to capture the TCB requirements # for confidential containers. # This policy is used to generate an EAR Appraisal. # More information can be found at # <https://datatracker.ietf.org/doc/draft-ietf-rats-ar4si/> default executables := 33 default hardware := 97 default configuration := 36 executables := 3 if { input.sample.launch_digest in data.reference.launch_digest } hardware := 2 if { input.sample.svn in data.reference.svn } executables := 3 if { input.snp.measurement in data.reference.snp_launch_measurement } hardware := 2 if { input.snp.reported_tcb_bootloader in data.reference.snp_bootloader input.snp.reported_tcb_microcode in data.reference.snp_microcode input.snp.reported_tcb_snp in data.reference.snp_snp_svn input.snp.reported_tcb_tee in data.reference.snp_tee_svn } configuration := 2 if { input.snp.policy_debug_allowed == "0" input.snp.policy_migrate_ma == "0" input.snp.platform_smt_enabled in data.reference.snp_smt_enabled input.snp.platform_tsme_enabled in data.reference.snp_tsme_enabled input.snp.policy_abi_major in data.reference.snp_guest_abi_major input.snp.policy_abi_minor in data.reference.snp_guest_abi_minor input.snp.policy_single_socket in data.reference.snp_single_socket input.snp.policy_smt_allowed in data.reference.snp_smt_allowed } else := 3 if { input.snp.policy_debug_allowed == "0" input.snp.policy_migrate_ma == "0" } executables := 3 if { input.tdx.quote.body.rtmr_1 in data.reference.rtmr_1 input.tdx.quote.body.rtmr_2 in data.reference.rtmr_2 } hardware := 2 if { # Check that this is a TDX quote signed by the Intel SGX Quoting Enclave. input.tdx.quote.header.tee_type == "81000000" input.tdx.quote.header.vendor_id == "939a7233f79c4ca9940a0db3957f0607" # Check TDX Module version and its hash. Also check OVMF code hash. input.tdx.quote.body.mr_seam in data.reference.mr_seam input.tdx.quote.body.tcb_svn in data.reference.tcb_svn input.tdx.quote.body.mr_td in data.reference.mr_td # Check TCB status # input.tdx.tcb_status == "OK" # Check collateral expiration status # input.tdx.collateral_expiration_status == "0" # Check against allowed advisory ids # allowed_advisory_ids := {"INTEL-SA-00837"} # attester_advisory_ids := {id | id := input.attester_advisory_ids[_]} # object.subset(allowed_advisory_ids, attester_advisory_ids) # Check against disallowed advisory ids # disallowed_advisory_ids := {"INTEL-SA-00837"} # attester_advisory_ids := {id | id := input.tdx.advisory_ids[_]} # convert array to set # intersection := attester_advisory_ids & disallowed_advisory_ids # count(intersection) == 0 } configuration := 2 if { input.tdx.td_attributes.debug == false input.tdx.quote.body.xfam in data.reference.xfam } executables := 3 if { input.azsnpvtpm.measurement in data.reference.measurement input.azsnpvtpm.tpm.pcr11 in data.reference.snp_pcr11 } hardware := 2 if { input.azsnpvtpm.reported_tcb_bootloader in data.reference.tcb_bootloader input.azsnpvtpm.reported_tcb_microcode in data.reference.tcb_microcode input.azsnpvtpm.reported_tcb_snp in data.reference.tcb_snp input.azsnpvtpm.reported_tcb_tee in data.reference.tcb_tee } configuration := 2 if { input.azsnpvtpm.platform_smt_enabled in data.reference.smt_enabled input.azsnpvtpm.platform_tsme_enabled in data.reference.tsme_enabled input.azsnpvtpm.policy_abi_major in data.reference.abi_major input.azsnpvtpm.policy_abi_minor in data.reference.abi_minor input.azsnpvtpm.policy_single_socket in data.reference.single_socket input.azsnpvtpm.policy_smt_allowed in data.reference.smt_allowed } ##### Azure vTPM TDX executables := 3 if { input.aztdxvtpm.tpm.pcr11 in data.reference.tdx_pcr11 } hardware := 2 if { # Check that the quote is a TDX quote signed by the Intel SGX Quoting Enclave. input.aztdxvtpm.quote.header.tee_type == "81000000" input.aztdxvtpm.quote.header.vendor_id == "939a7233f79c4ca9940a0db3957f0607" # Check TDX Module version and its hash. Also check OVMF code hash. input.aztdxvtpm.quote.body.mr_seam in data.reference.mr_seam input.aztdxvtpm.quote.body.tcb_svn in data.reference.tcb_svn input.aztdxvtpm.quote.body.mr_td in data.reference.mr_td } configuration := 2 if { input.aztdxvtpm.quote.body.xfam in data.reference.xfam }
The attestation policy follows the Open Policy Agent specification. In this example, the attestation policy compares the claims provided in the attestation report to the reference values registered in the RVPS database. The attestation process is successful only if all the values match.
Create the attestation policy config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f attestation-policy.yaml
$ oc apply -f attestation-policy.yaml
7.13.3. Configuring PCCS for TDX
If you use Intel Trust Domain Extensions (TDX), you must configure Trustee to use the Provisioning Certificate Caching Service (PCCS).
The PCCS retrieves the Provisioning Certification Key (PCK) certificates and caches them in a local database.
Do not use the public Intel PCCS service. Use a local caching service on-premise or on the public cloud.
Procedure
Create a
tdx-config.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: tdx-config namespace: trustee-operator-system data: sgx_default_qcnl.conf: | \ { "collateral_service": "https://api.trustedservices.intel.com/sgx/certification/v4/", "pccs_url": "<pccs_url>" }
apiVersion: v1 kind: ConfigMap metadata: name: tdx-config namespace: trustee-operator-system data: sgx_default_qcnl.conf: | \ { "collateral_service": "https://api.trustedservices.intel.com/sgx/certification/v4/", "pccs_url": "<pccs_url>"
1 }
- 1
- Specify the PCCS URL, for example,
https://localhost:8081/sgx/certification/v4/
.
Create the TDX config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f tdx-config.yaml
$ oc apply -f tdx-config.yaml
7.13.4. Creating a secret with custom keys for clients
You can create a secret that contains one or more custom keys for Trustee clients.
In this example, the kbsres1
secret has two entries (key1
, key2
), which the clients retrieve. You can add additional secrets according to your requirements by using the same format.
Prerequisites
- You have created one or more custom keys.
Procedure
Create a secret for the custom keys according to the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply secret generic kbsres1 \ --from-literal key1=<custom_key1> \ --from-literal key2=<custom_key2> \ -n trustee-operator-system
$ oc apply secret generic kbsres1 \ --from-literal key1=<custom_key1> \
1 --from-literal key2=<custom_key2> \ -n trustee-operator-system
- 1
- Specify a custom key.
The
kbsres1
secret is specified in thespec.kbsSecretResources
key of theKbsConfig
custom resource.
7.13.5. Creating a secret for container image signature verification
If you use container image signature verification, you must create a secret that contains the public container image signing key.
The Confidential compute attestation Operator uses the secret to verify the signature, ensuring that only trusted and authenticated container images are deployed in your environment.
You can use Red Hat Trusted Artifact Signer or other tools to sign container images.
Procedure
Create a secret for container image signature verification by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply secret generic <type> \ --from-file=<tag>=./<public_key_file> \ -n trustee-operator-system
$ oc apply secret generic <type> \
1 --from-file=<tag>=./<public_key_file> \
2 -n trustee-operator-system
-
Record the
<type>
value. You must add this value to thespec.kbsSecretResources
key when you create theKbsConfig
custom resource.
7.13.6. Creating the container image signature verification policy
You create the container image signature verification policy because signature verification is always enabled. If this policy is missing, the pods will not start.
If you are not using container image signature verification, you create the policy without signature verification.
For more information, see containers-policy.json 5.
Procedure
Create a
security-policy-config.json
file according to the following examples:Without signature verification:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "default": [ { "type": "insecureAcceptAnything" }], "transports": {} }
{ "default": [ { "type": "insecureAcceptAnything" }], "transports": {} }
With signature verification:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "default": [ { "type": "insecureAcceptAnything" } ], "transports": { "<transport>": { "<registry>/<image>": [ { "type": "sigstoreSigned", "keyPath": "kbs:///default/<type>/<tag>" } ] } } }
{ "default": [ { "type": "insecureAcceptAnything" } ], "transports": { "<transport>": {
1 "<registry>/<image>":
2 [ { "type": "sigstoreSigned", "keyPath": "kbs:///default/<type>/<tag>"
3 } ] } } }
- 1
- Specify the image repository for
transport
, for example,"docker":
. For more information, see containers-transports 5. - 2
- Specify the container registry and image, for example, "quay.io/my-image".
- 3
- Specify the type and tag of the container image signature verification secret that you created, for example,
img-sig/pub-key
.
Create the security policy by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply secret generic security-policy \ --from-file=osc=./<security-policy-config.json> \ -n trustee-operator-system
$ oc apply secret generic security-policy \ --from-file=osc=./<security-policy-config.json> \ -n trustee-operator-system
Do not alter the secret type,
security-policy
, or the key,osc
.The
security-policy
secret is specified in thespec.kbsSecretResources
key of theKbsConfig
custom resource.
7.13.7. Creating the resource access policy
You configure the resource access policy for the Trustee policy engine. This policy determines which resources Trustee can access.
The Trustee policy engine is different from the Attestation Service policy engine, which determines the validity of TEE evidence.
Procedure
Create a
resourcepolicy-configmap.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: resource-policy namespace: trustee-operator-system data: policy.rego: package policy default allow = true allow { input["tee"] != "sample" }
apiVersion: v1 kind: ConfigMap metadata: name: resource-policy namespace: trustee-operator-system data: policy.rego: package policy default allow = true allow { input["tee"] != "sample" }
- policy.rego
-
The name of the resource policy,
policy.rego
, must match the resource policy defined in the Trustee config map. - package policy
- The resource policy follows the Open Policy Agent specification.
Create the resource policy config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f resourcepolicy-configmap.yaml
$ oc apply -f resourcepolicy-configmap.yaml
7.14. Creating the KbsConfig custom resource
You create the KbsConfig
custom resource (CR) to launch Trustee.
Then, you check the Trustee pods and pod logs to verify the configuration.
Procedure
Create a
kbsconfig-cr.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: confidentialcontainers.org/v1alpha1 kind: KbsConfig metadata: labels: app.kubernetes.io/name: kbsconfig app.kubernetes.io/instance: kbsconfig app.kubernetes.io/part-of: trustee-operator app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: trustee-operator name: kbsconfig namespace: trustee-operator-system spec: kbsConfigMapName: kbs-config-cm kbsAuthSecretName: kbs-auth-public-key kbsDeploymentType: AllInOneDeployment kbsRvpsRefValuesConfigMapName: rvps-reference-values kbsSecretResources: ["kbsres1", "security-policy", "<type>"] kbsResourcePolicyConfigMapName: resource-policy # tdxConfigSpec: # kbsTdxConfigMapName: tdx-config # kbsAttestationPolicyConfigMapName: attestation-policy # kbsServiceType: <service_type>
apiVersion: confidentialcontainers.org/v1alpha1 kind: KbsConfig metadata: labels: app.kubernetes.io/name: kbsconfig app.kubernetes.io/instance: kbsconfig app.kubernetes.io/part-of: trustee-operator app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: trustee-operator name: kbsconfig namespace: trustee-operator-system spec: kbsConfigMapName: kbs-config-cm kbsAuthSecretName: kbs-auth-public-key kbsDeploymentType: AllInOneDeployment kbsRvpsRefValuesConfigMapName: rvps-reference-values kbsSecretResources: ["kbsres1", "security-policy", "<type>"]
1 kbsResourcePolicyConfigMapName: resource-policy # tdxConfigSpec: # kbsTdxConfigMapName: tdx-config
2 # kbsAttestationPolicyConfigMapName: attestation-policy
3 # kbsServiceType: <service_type>
4 - 1
- Optional: Specify the
type
value of the container image signature verification secret if you created the secret, for example,img-sig
. If you did not create the secret, set thekbsSecretResources
value to["kbsres1", "security-policy"]
. - 2
- Uncomment
tdxConfigSpec.kbsTdxConfigMapName: tdx-config
for Intel Trust Domain Extensions. - 3
- Uncomment
kbsAttestationPolicyConfigMapName: attestation-policy
if you create a customized attestation policy. - 4
- Uncomment
kbsServiceType: <service_type>
if you create a service type, other than the defaultClusterIP
service, to expose applications within the cluster external traffic. You can specifyNodePort
,LoadBalancer
, orExternalName
.
Create the
KbsConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f kbsconfig-cr.yaml
$ oc apply -f kbsconfig-cr.yaml
7.15. Verifying the Trustee configuration
You verify the Trustee configuration by checking the Trustee pods and logs.
Procedure
Set the default project by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc project trustee-operator-system
$ oc project trustee-operator-system
Check the Trustee pods by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pods -n trustee-operator-system
$ oc get pods -n trustee-operator-system
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME READY STATUS RESTARTS AGE trustee-deployment-8585f98449-9bbgl 1/1 Running 0 22m trustee-operator-controller-manager-5fbd44cd97-55dlh 2/2 Running 0 59m
NAME READY STATUS RESTARTS AGE trustee-deployment-8585f98449-9bbgl 1/1 Running 0 22m trustee-operator-controller-manager-5fbd44cd97-55dlh 2/2 Running 0 59m
Set the
POD_NAME
environmental variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow POD_NAME=$(oc get pods -l app=kbs -o jsonpath='{.items[0].metadata.name}' -n trustee-operator-system)
$ POD_NAME=$(oc get pods -l app=kbs -o jsonpath='{.items[0].metadata.name}' -n trustee-operator-system)
Check the pod logs by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n trustee-operator-system $POD_NAME
$ oc logs -n trustee-operator-system $POD_NAME
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow [2024-05-30T13:44:24Z INFO kbs] Using config file /etc/kbs-config/kbs-config.json [2024-05-30T13:44:24Z WARN attestation_service::rvps] No RVPS address provided and will launch a built-in rvps [2024-05-30T13:44:24Z INFO attestation_service::token::simple] No Token Signer key in config file, create an ephemeral key and without CA pubkey cert [2024-05-30T13:44:24Z INFO api_server] Starting HTTPS server at [0.0.0.0:8080] [2024-05-30T13:44:24Z INFO actix_server::builder] starting 12 workers [2024-05-30T13:44:24Z INFO actix_server::server] Tokio runtime found; starting in existing Tokio runtime
[2024-05-30T13:44:24Z INFO kbs] Using config file /etc/kbs-config/kbs-config.json [2024-05-30T13:44:24Z WARN attestation_service::rvps] No RVPS address provided and will launch a built-in rvps [2024-05-30T13:44:24Z INFO attestation_service::token::simple] No Token Signer key in config file, create an ephemeral key and without CA pubkey cert [2024-05-30T13:44:24Z INFO api_server] Starting HTTPS server at [0.0.0.0:8080] [2024-05-30T13:44:24Z INFO actix_server::builder] starting 12 workers [2024-05-30T13:44:24Z INFO actix_server::server] Tokio runtime found; starting in existing Tokio runtime
7.16. Verifying the attestation process
You can verify the attestation process by creating a test pod and retrieving its secret.
This procedure is an example to verify that attestation is working. Do not write sensitive data to standard I/O because the data can be captured by using a memory dump. Only data written to memory is encrypted.
By default, the Kata agent policy, embedded in the pod virtual machine (VM) image, disables the exec
and log
APIs for a Confidential Containers pod. This policy prevents the cluster admin from executing processes inside the pod to exfiltrate sensitive data while also blocking accidental writes of sensitive data to standard I/O.
In a test scenario, you can override the restriction at runtime by adding a policy annotation to the pod. For Technology Preview, runtime policy annotations are not verified by remote attestation.
Prerequisites
- You have created a route if the Trustee server and the test pod are not running in the same cluster.
Procedure
Create a
verification-pod.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: ocp-cc-pod labels: app: ocp-cc-pod annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> io.katacontainers.config.runtime.cc_init_data: <base64_initdata> spec: runtimeClassName: kata-remote containers: - name: skr-openshift image: registry.access.redhat.com/ubi9/ubi:9.3 command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: ocp-cc-pod labels: app: ocp-cc-pod annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy>
1 io.katacontainers.config.runtime.cc_init_data: <base64_initdata>
2 spec: runtimeClassName: kata-remote containers: - name: skr-openshift image: registry.access.redhat.com/ubi9/ubi:9.3 command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
If you specify both the
io.katacontainers.config.agent.policy
annotation and theio.katacontainers.config.runtime.cc_init_data
annotation with an agent policy, the initdata annotation takes precedence over the agent policy annotation.Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create -f verification-pod.yaml
$ oc create -f verification-pod.yaml
Connect to the Bash shell of the
ocp-cc-pod
by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc exec -it ocp-cc-pod -- bash
$ oc exec -it ocp-cc-pod -- bash
Fetch the pod secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow curl http://127.0.0.1:8006/cdh/resource/default/kbsres1/key1
$ curl http://127.0.0.1:8006/cdh/resource/default/kbsres1/key1
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow res1val1
res1val1
The Trustee server returns the secret only if the attestation is successful.
Chapter 8. Deploying Confidential Containers on IBM Z and IBM LinuxONE
You can deploy Confidential Containers on IBM Z® and IBM® LinuxONE after you deploy OpenShift sandboxed containers.
Confidential Containers on IBM Z® and IBM® LinuxONE 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.
IBM® Hyper Protect Confidential Container (HPCC) for Red Hat OpenShift Container Platform is now production-ready. HPCC enables Confidential Computing technology at the enterprise scale by providing a multiparty Hyper Protect Contract, deployment attestation, and validation of container runtime and OCI image integrity.
HPCC is supported by IBM Z17® and IBM® LinuxONE Emperor 5 and is compatible with OpenShift sandboxed containers 1.9 and later. For more information, see the IBM HPCC documentation.
Cluster requirements
- You have installed Red Hat OpenShift Container Platform 4.15 or later on the cluster where you are installing the Confidential compute attestation Operator.
LPAR requirements
- You have LinuxONE Emperor 4.
- You have enabled Secure Unpack Facility on your Logical Partition (LPAR), which is necessary for the IBM Secure Execution. For more information, see Enabling the KVM host for IBM Secure Execution.
You deploy Confidential Containers by performing the following steps:
- Install the Confidential compute attestation Operator.
- Create the route for Trustee.
- Enable the Confidential Containers feature gate.
- Create initdata.
- Update the peer pods config map.
- Optional: Customize the Kata agent policy.
-
Delete the
KataConfig
custom resource (CR). - Update the peer pods secret.
- Optional: Select a custom peer pod VM image.
-
Re-create the
KataConfig
CR. - Create the Trustee authentication secret.
- Create the Trustee config map.
- Obtain the IBM Secure Execution (SE) header.
- Configure the SE certificates and keys.
- Create the persistent storage components.
- Configure Trustee values, policies, and secrets.
-
Create the
KbsConfig
CR. - Verify the Trustee configuration.
- Verify the attestation process.
8.1. Installing the Confidential compute attestation Operator
You can install the Confidential compute attestation Operator on IBM Z® and IBM® LinuxONE by using the CLI.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create a
trustee-namespace.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Namespace metadata: name: trustee-operator-system
apiVersion: v1 kind: Namespace metadata: name: trustee-operator-system
Create the
trustee-operator-system
namespace by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f trustee-namespace.yaml
$ oc apply -f trustee-namespace.yaml
Create a
trustee-operatorgroup.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: trustee-operator-group namespace: trustee-operator-system spec: targetNamespaces: - trustee-operator-system
apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: trustee-operator-group namespace: trustee-operator-system spec: targetNamespaces: - trustee-operator-system
Create the operator group by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f trustee-operatorgroup.yaml
$ oc apply -f trustee-operatorgroup.yaml
Create a
trustee-subscription.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: trustee-operator-system namespace: trustee-operator-system spec: channel: stable installPlanApproval: Automatic name: trustee-operator source: trustee-operator-catalog sourceNamespace: openshift-marketplace
apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: trustee-operator-system namespace: trustee-operator-system spec: channel: stable installPlanApproval: Automatic name: trustee-operator source: trustee-operator-catalog sourceNamespace: openshift-marketplace
Create the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f trustee-subscription.yaml
$ oc apply -f trustee-subscription.yaml
Verify that the Operator is correctly installed by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get csv -n trustee-operator-system
$ oc get csv -n trustee-operator-system
This command can take several minutes to complete.
Watch the process by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get csv -n trustee-operator-system
$ watch oc get csv -n trustee-operator-system
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DISPLAY PHASE trustee-operator.v0.3.0 Trustee Operator 0.3.0 Succeeded
NAME DISPLAY PHASE trustee-operator.v0.3.0 Trustee Operator 0.3.0 Succeeded
8.2. Enabling the Confidential Containers feature gate
You must enable the Confidential Containers feature gate.
Prerequisites
- You have subscribed to the OpenShift sandboxed containers Operator.
Procedure
Create a
cc-feature-gate.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: osc-feature-gates namespace: openshift-sandboxed-containers-operator data: confidential: "true"
apiVersion: v1 kind: ConfigMap metadata: name: osc-feature-gates namespace: openshift-sandboxed-containers-operator data: confidential: "true"
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f cc-feature-gate.yaml
$ oc apply -f cc-feature-gate.yaml
8.3. Creating the route for Trustee
You can create a secure route with edge TLS termination for Trustee. External ingress traffic reaches the router pods as HTTPS and passes on to the Trustee pods as HTTP.
Prerequisites
- You have installed the Confidential compute attestation Operator.
Procedure
Create an edge route by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create route edge --service=kbs-service --port kbs-port \ -n trustee-operator-system
$ oc create route edge --service=kbs-service --port kbs-port \ -n trustee-operator-system
NoteNote: Currently, only a route with a valid CA-signed certificate is supported. You cannot use a route with self-signed certificate.
Set the
TRUSTEE_HOST
variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow TRUSTEE_HOST=$(oc get route -n trustee-operator-system kbs-service \ -o jsonpath={.spec.host})
$ TRUSTEE_HOST=$(oc get route -n trustee-operator-system kbs-service \ -o jsonpath={.spec.host})
Verify the route by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow echo $TRUSTEE_HOST
$ echo $TRUSTEE_HOST
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow kbs-service-trustee-operator-system.apps.memvjias.eastus.aroapp.io
kbs-service-trustee-operator-system.apps.memvjias.eastus.aroapp.io
8.4. About initdata
The initdata specification provides a flexible way to initialize a peer pod with sensitive or workload-specific data at runtime, avoiding the need to embed such data in the virtual machine (VM) image. This enhances security by reducing exposure of confidential information and improves flexibility by eliminating custom image builds. For example, initdata can include three configuration settings:
- An X.509 certificate for secure communication.
- A cryptographic key for authentication.
-
An optional Kata Agent
policy.rego
file to enforce runtime behavior when overriding the default Kata Agent policy.
You can apply an initdata configuration by using one of the following methods:
- Globally by including it in the peer pods config map, setting a cluster-wide default for all pods.
For a specific pod when configuring a pod workload object, allowing customization for individual workloads.
The
io.katacontainers.config.runtime.cc_init_data
annotation you specify when configuring a pod workload object overrides the globalINITDATA
setting in the peer pods config map for that specific pod. The Kata runtime handles this precedence automatically at pod creation time.
The initdata content configures the following components:
- Attestation Agent (AA), which verifies the trustworthiness of the peer pod by sending evidence to the Trustee for attestation.
- Confidential Data Hub (CDH), which manages secrets and secure data access within the peer pod VM.
- Kata Agent, which enforces runtime policies and manages the lifecycle of the containers inside the pod VM.
8.5. Creating initdata
Create a TOML file with initdata and convert it to a Base64-encoded string. Use this string to specify the value in the peer pods config map, in the peer pod manifest, or in the busybox.yaml
file.
You must delete the kbs_cert
setting if you configure insecure_http = true
in the Trustee config map.
Procedure
Obtain the Trustee IP address by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get node $(oc get pod -n trustee-operator-system -o jsonpath='{.items[0].spec.nodeName}') -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}'
$ oc get node $(oc get pod -n trustee-operator-system -o jsonpath='{.items[0].spec.nodeName}') -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}'
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 192.168.122.22
192.168.122.22
Obtain the Trustee port by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get svc kbs-service -n trustee-operator-system
$ oc get svc kbs-service -n trustee-operator-system
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kbs-service NodePort 172.30.116.11 <none> 8080:32178/TCP 12d
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kbs-service NodePort 172.30.116.11 <none> 8080:32178/TCP 12d
Create the
initdata.toml
configuration file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ```toml algorithm = "sha384" version = "0.1.0" [data] "aa.toml" = ''' [token_configs] [token_configs.coco_as] url = 'https://<worker_node_ip>:<node_port>' [token_configs.kbs] url = 'https://<worker_node_ip>:<node_port>' cert = """ -----BEGIN CERTIFICATE----- <kbs_certificate> -----END CERTIFICATE----- """ ''' "cdh.toml" = ''' socket = 'unix:///run/confidential-containers/cdh.sock' credentials = [] [kbc] name = 'cc_kbc' url = 'https://<worker_node_ip>:<node_port>' kbs_cert = """ -----BEGIN CERTIFICATE----- <kbs_certificate> -----END CERTIFICATE----- """ ''' "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 ExecProcessRequest := 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 := true default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default ReseedRandomDevRequest := true default ResumeContainerRequest := true default SetGuestDateTimeRequest := true default SetPolicyRequest := 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 WriteStreamRequest := true ''' ```
```toml algorithm = "sha384" version = "0.1.0" [data] "aa.toml" = ''' [token_configs] [token_configs.coco_as] url = 'https://<worker_node_ip>:<node_port>'
1 [token_configs.kbs] url = 'https://<worker_node_ip>:<node_port>' cert = """ -----BEGIN CERTIFICATE----- <kbs_certificate>
2 -----END CERTIFICATE----- """ ''' "cdh.toml" = ''' socket = 'unix:///run/confidential-containers/cdh.sock' credentials = [] [kbc] name = 'cc_kbc' url = 'https://<worker_node_ip>:<node_port>' kbs_cert = """
3 -----BEGIN CERTIFICATE----- <kbs_certificate>
4 -----END CERTIFICATE----- """ ''' "policy.rego" = '''
5 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 ExecProcessRequest := 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 := true default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default ReseedRandomDevRequest := true default ResumeContainerRequest := true default SetGuestDateTimeRequest := true default SetPolicyRequest := 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 WriteStreamRequest := true ''' ```
- 1
- Specify the Trustee IP address and the port, for example,
https://192.168.122.22:32178
. - 2
- Specify the Base64-encoded TLS certificate for the attestation agent. This is not required for testing purposes, but it is recommended for production systems.
- 3
- Delete the
kbs_cert
setting if you configureinsecure_http = true
in the Trustee config map. - 4
- Specify the Base64-encoded TLS certificate for the Trustee instance.
- 5
- Optional: You can specify a custom Kata Agent policy.
Convert the
initdata.toml
file to a Base64-encoded string in a text file by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 initdata.toml > initdata.txt
$ base64 -w0 initdata.toml > initdata.txt
8.6. Updating the peer pods config map
You must update the peer pods config map for Confidential Containers.
Set Secure Boot to true
to enable it by default. The default value is false
, which presents a security risk.
Procedure
Create a
peer-pods-cm.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "libvirt" PEERPODS_LIMIT_PER_NODE: "10" LIBVIRT_POOL: "<libvirt_pool>" LIBVIRT_VOL_NAME: "<libvirt_volume>" LIBVIRT_DIR_NAME: "/var/lib/libvirt/images/<directory_name>" LIBVIRT_NET: "default" INITDATA: "<base64_encoded_initdata>" DISABLECVM: "false"
apiVersion: v1 kind: ConfigMap metadata: name: peer-pods-cm namespace: openshift-sandboxed-containers-operator data: CLOUD_PROVIDER: "libvirt" PEERPODS_LIMIT_PER_NODE: "10"
1 LIBVIRT_POOL: "<libvirt_pool>"
2 LIBVIRT_VOL_NAME: "<libvirt_volume>"
3 LIBVIRT_DIR_NAME: "/var/lib/libvirt/images/<directory_name>"
4 LIBVIRT_NET: "default"
5 INITDATA: "<base64_encoded_initdata>"
6 DISABLECVM: "false"
- 1
- Specify the maximum number of peer pods that can be created per node. The default value is
10
. - 2
- Specify the libvirt pool. If you have manually configured the libvirt pool, use the same name as in your KVM host configuration.
- 3
- Specify the libvirt volume name. If you have manually configured the libvirt volume, use the same name as in your KVM host configuration.
- 4
- Specify the libvirt directory for storing virtual machine disk images, such as
.qcow2
, or.raw
files. To ensure libvirt has read and write access permissions, use a subdirectory of the libvirt storage directory. The default is/var/lib/libvirt/images/
. - 5
- Optional: Specify a libvirt network if you do not want to use the default network.
- 6
- Specify the Base64-encoded string you created in the
initdata.txt
file.
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-cm.yaml
$ oc apply -f peer-pods-cm.yaml
Restart the
ds/osc-caa-ds
daemon set by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc set env ds/osc-caa-ds \ -n openshift-sandboxed-containers-operator REBOOT="$(date)"
$ oc set env ds/osc-caa-ds \ -n openshift-sandboxed-containers-operator REBOOT="$(date)"
8.7. Customizing the Kata agent policy
The Kata agent policy is a security mechanism that controls agent API requests for pods running with the Kata runtime. Written in Rego and enforced by the Kata agent within the pod virtual machine (VM), this policy determines which operations are allowed or denied.
By default, the Kata agent policy disables the exec
and log
APIs, as they might transmit or receive unencrypted data through the control plane, which is insecure.
You can override the default policy with a custom one for specific use cases, such as development and testing where security is not a concern. For example, you might run in an environment where the control plane can be trusted. You can apply a custom policy in several ways:
- Embedding it in the pod VM image.
- Patching the peer pods config map.
- Adding an annotation to the workload pod YAML.
For production systems, the preferred method is to use initdata to override the Kata agent policy. The following procedure applies a custom policy to an individual pod using the io.katacontainers.config.agent.policy
annotation. The policy is provided in Base64-encoded Rego format. This approach overrides the default policy at pod creation without modifying the pod VM image.
Enabling the exec
or log
APIs in Confidential Containers workloads might expose sensitive information. Do not enable these APIs in production environments.
A custom policy replaces the default policy entirely. To modify only specific APIs, include the full policy and adjust the relevant rules.
Procedure
Create a
policy.rego
file with your custom policy. The following example shows all configurable APIs, withexec
andlog
enabled for demonstration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
package agent_policy import future.keywords.in import input default CopyFileRequest := false default CreateContainerRequest := false default CreateSandboxRequest := true default DestroySandboxRequest := true default ExecProcessRequest := true # Enabled to allow exec API default GetOOMEventRequest := true default GuestDetailsRequest := true default OnlineCPUMemRequest := true default PullImageRequest := true default ReadStreamRequest := true # Enabled to allow log API default RemoveContainerRequest := true default RemoveStaleVirtiofsShareMountsRequest := true default SignalProcessRequest := true default StartContainerRequest := true default StatsContainerRequest := true default TtyWinResizeRequest := true default UpdateEphemeralMountsRequest := true default UpdateInterfaceRequest := true default UpdateRoutesRequest := true default WaitProcessRequest := true default WriteStreamRequest := false
This policy enables the
exec
(ExecProcessRequest
) andlog
(ReadStreamRequest
) APIs. Adjust thetrue
orfalse
values to customize the policy further based on your needs.Convert the
policy.rego
file to a Base64-encoded string by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow base64 -w0 policy.rego
$ base64 -w0 policy.rego
Save the output for use in the yaml file.
Add the Base64-encoded policy to a
my-pod.yaml
pod specification file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
apiVersion: v1 kind: Pod metadata: name: <pod_name> annotations: io.katacontainers.config.agent.policy: <base64_encoded_policy> spec: runtimeClassName: kata-remote containers: - name: <container_name> image: registry.access.redhat.com/ubi9/ubi:latest command: - sleep - "36000" securityContext: privileged: false seccompProfile: type: RuntimeDefault
Apply the pod manifest by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f my-pod.yaml
$ oc apply -f my-pod.yaml
8.8. Deleting the KataConfig custom resource
You can delete the KataConfig
custom resource (CR) by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Delete the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete kataconfig example-kataconfig
$ oc delete kataconfig example-kataconfig
Verify that the custom resource was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get kataconfig example-kataconfig
$ oc get kataconfig example-kataconfig
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow No example-kataconfig instances exist
No example-kataconfig instances exist
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
8.9. Updating the peer pods secret
If the peer pods secret is empty and the Cloud Credential Operator (CCO) is installed, the OpenShift sandboxed containers Operator uses the CCO to retrieve the secret. If you have uninstalled the CCO, you must update the peer pods secret for Confidential Containers manually or the peer pods will fail to operate.
The secret stores credentials for creating the pod virtual machine (VM) image and peer pod instances.
By default, the OpenShift sandboxed containers Operator creates the secret based on the credentials used to create the cluster. However, you can manually create a secret that uses different credentials.
Prerequisites
-
REDHAT_OFFLINE_TOKEN
. You have generated this token to download the RHEL image at Red Hat API Tokens. -
HOST_KEY_CERTS
. The Host Key Document (HKD) certificate enables secure execution on IBM Z®. For more information, see Obtaining a host key document from Resource Link in the IBM documentation.
Procedure
Create a
peer-pods-secret.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: CLOUD_PROVIDER: "libvirt" LIBVIRT_URI: "<libvirt_gateway_uri>" REDHAT_OFFLINE_TOKEN: "<rh_offline_token>" HOST_KEY_CERTS: "<host_key_crt_value>"
apiVersion: v1 kind: Secret metadata: name: peer-pods-secret namespace: openshift-sandboxed-containers-operator type: Opaque stringData: CLOUD_PROVIDER: "libvirt" LIBVIRT_URI: "<libvirt_gateway_uri>"
1 REDHAT_OFFLINE_TOKEN: "<rh_offline_token>"
2 HOST_KEY_CERTS: "<host_key_crt_value>"
3 Create the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f peer-pods-secret.yaml
$ oc apply -f peer-pods-secret.yaml
8.10. Selecting a custom peer pod VM image
You can select a custom peer pod virtual machine (VM) image, tailored to your workload requirements by adding an annotation to the pod manifest. The custom image overrides the default image specified in the peer pods config map. You create a new libvirt volume in your libvirt pool and upload the custom peer pod VM image to the new volume. Then, you update the pod manifest to use the custom peer pod VM image.
Prerequisites
- The ID of the custom pod VM image to use, compatible with the cloud provider or hypervisor, is available.
Procedure
Set the name of the libvirt pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_POOL=<libvirt_pool>
$ export LIBVIRT_POOL=<libvirt_pool>
1 - 1
- Specify the existing libvirt pool name.
Set the name of the new libvirt volume by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export LIBVIRT_VOL_NAME=<new_libvirt_volume>
$ export LIBVIRT_VOL_NAME=<new_libvirt_volume>
Create a libvirt volume for the pool by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh -c qemu:///system \ vol-create-as --pool $LIBVIRT_POOL \ --name $LIBVIRT_VOL_NAME \ --capacity 20G \ --allocation 2G \ --prealloc-metadata \ --format qcow2
$ virsh -c qemu:///system \ vol-create-as --pool $LIBVIRT_POOL \ --name $LIBVIRT_VOL_NAME \ --capacity 20G \ --allocation 2G \ --prealloc-metadata \ --format qcow2
Upload the custom peer pod VM image to the libvirt volume:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh -c qemu:///system vol-upload \ --vol $LIBVIRT_VOL_NAME <custom_podvm_image.qcow2> \ --pool $LIBVIRT_POOL --sparse
$ virsh -c qemu:///system vol-upload \ --vol $LIBVIRT_VOL_NAME <custom_podvm_image.qcow2> \
1 --pool $LIBVIRT_POOL --sparse
- 1
- Specify the custom peer pod VM image name.
Create a
pod-manifest.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<new_libvirt_volume>" spec: runtimeClassName: kata-remote containers: - name: <example_container> image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
apiVersion: v1 kind: Pod metadata: name: pod-manifest annotations: io.katacontainers.config.hypervisor.image: "<new_libvirt_volume>"
1 spec: runtimeClassName: kata-remote
2 containers: - name: <example_container>
3 image: registry.access.redhat.com/ubi9/ubi:9.3 command: ["sleep", "36000"]
Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f pod-manifest.yaml
$ oc apply -f pod-manifest.yaml
8.11. Re-creating the KataConfig custom resource
You must re-create the KataConfig
custom resource (CR) for Confidential Containers.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 - 1
- Optional: If you have applied node labels to install
kata-remote
on specific nodes, specify the key and value, for example,cc: 'true'
.
Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify that you have built the peer pod image and uploaded it to the libvirt volume by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc describe configmap peer-pods-cm -n openshift-sandboxed-containers-operator
$ oc describe configmap peer-pods-cm -n openshift-sandboxed-containers-operator
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Name: peer-pods-cm Namespace: openshift-sandboxed-containers-operator Labels: <none> Annotations: <none> Data ==== CLOUD_PROVIDER: libvirt DISABLECVM: false LIBVIRT_IMAGE_ID: fa-pp-vol BinaryData ==== Events: <none>
Name: peer-pods-cm Namespace: openshift-sandboxed-containers-operator Labels: <none> Annotations: <none> Data ==== CLOUD_PROVIDER: libvirt DISABLECVM: false
1 LIBVIRT_IMAGE_ID: fa-pp-vol
2 BinaryData ==== Events: <none>
Monitor the
kata-oc
machine config pool progress to ensure that it is in theUPDATED
state, whenUPDATEDMACHINECOUNT
equalsMACHINECOUNT
, by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch oc get mcp/kata-oc
$ watch oc get mcp/kata-oc
Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
8.12. Creating the Trustee authentication secret
You must create the authentication secret for Trustee.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Create a private key by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl genpkey -algorithm ed25519 > privateKey
$ openssl genpkey -algorithm ed25519 > privateKey
Create a public key by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl pkey -in privateKey -pubout -out publicKey
$ openssl pkey -in privateKey -pubout -out publicKey
Create a secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create secret generic kbs-auth-public-key --from-file=publicKey -n trustee-operator-system
$ oc create secret generic kbs-auth-public-key --from-file=publicKey -n trustee-operator-system
Verify the secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get secret -n trustee-operator-system
$ oc get secret -n trustee-operator-system
8.13. Creating the Trustee config map
You must create the config map to configure the Trustee server.
The following configuration example turns off security features to enable demonstration of Technology Preview features. It is not meant for a production environment.
Prerequisites
- You have created a route for Trustee.
Procedure
Create a
kbs-config-cm.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: kbs-config-cm namespace: trustee-operator-system data: kbs-config.toml: | [http_server] sockets = ["0.0.0.0:8080"] insecure_http = false private_key = "/etc/https-key/https.key" certificate = "/etc/https-cert/https.crt" [admin] insecure_api = false auth_public_key = "/etc/auth-secret/publicKey" [attestation_token] insecure_key = true attestation_token_type = "CoCo" [attestation_service] type = "coco_as_builtin" work_dir = "/opt/confidential-containers/attestation-service" policy_engine = "opa" [attestation_service.attestation_token_broker] type = "Simple" policy_dir = "/opt/confidential-containers/attestation-service/policies" [attestation_service.attestation_token_config] duration_min = 5 [attestation_service.rvps_config] type = "BuiltIn" [attestation_service.rvps_config.storage] type = "LocalJson" file_path = "/opt/confidential-containers/rvps/reference-values/reference-values.json" [[plugins]] name = "resource" type = "LocalFs" dir_path = "/opt/confidential-containers/kbs/repository" [policy_engine] policy_path = "/opt/confidential-containers/opa/policy.rego"
apiVersion: v1 kind: ConfigMap metadata: name: kbs-config-cm namespace: trustee-operator-system data: kbs-config.toml: | [http_server] sockets = ["0.0.0.0:8080"] insecure_http = false private_key = "/etc/https-key/https.key" certificate = "/etc/https-cert/https.crt" [admin] insecure_api = false auth_public_key = "/etc/auth-secret/publicKey" [attestation_token] insecure_key = true attestation_token_type = "CoCo" [attestation_service] type = "coco_as_builtin" work_dir = "/opt/confidential-containers/attestation-service" policy_engine = "opa" [attestation_service.attestation_token_broker] type = "Simple" policy_dir = "/opt/confidential-containers/attestation-service/policies" [attestation_service.attestation_token_config] duration_min = 5 [attestation_service.rvps_config] type = "BuiltIn" [attestation_service.rvps_config.storage] type = "LocalJson" file_path = "/opt/confidential-containers/rvps/reference-values/reference-values.json" [[plugins]] name = "resource" type = "LocalFs" dir_path = "/opt/confidential-containers/kbs/repository" [policy_engine] policy_path = "/opt/confidential-containers/opa/policy.rego"
Create the config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f kbs-config-cm.yaml
$ oc apply -f kbs-config-cm.yaml
8.14. Configuring the IBM Secure Execution certificates and keys
You must configure the IBM Secure Execution (SE) certificates and keys for your worker nodes.
Prerequisites
- You have the IP address of the bastion node.
- You have the internal IP addresses of the worker nodes.
Procedure
Generate the Key Broker Service (KBS) certificate and key by performing the following steps:
Create the
kbs.conf
configuration file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow [req] default_bits = 2048 default_keyfile = localhost.key distinguished_name = req_distinguished_name req_extensions = req_ext x509_extensions = v3_ca [req_distinguished_name] countryName = Country Name (2-letter code) countryName_default = <country_name> stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = <state_name> localityName = Locality Name (eg, city) localityName_default = <locality_name> organizationName = Organization Name (eg, company) organizationName_default = Red Hat organizationalUnitName = organizationalunit organizationalUnitName_default = Development commonName = Common Name (e.g. server FQDN or YOUR name) commonName_default = kbs-service commonName_max = 64 [req_ext] subjectAltName = @alt_names [v3_ca] subjectAltName = @alt_names [alt_names] IP.1 = <trustee_ip> DNS.1 = localhost DNS.2 = 127.0.0.1
[req] default_bits = 2048 default_keyfile = localhost.key distinguished_name = req_distinguished_name req_extensions = req_ext x509_extensions = v3_ca [req_distinguished_name] countryName = Country Name (2-letter code) countryName_default = <country_name> stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = <state_name> localityName = Locality Name (eg, city) localityName_default = <locality_name> organizationName = Organization Name (eg, company) organizationName_default = Red Hat organizationalUnitName = organizationalunit organizationalUnitName_default = Development commonName = Common Name (e.g. server FQDN or YOUR name) commonName_default = kbs-service commonName_max = 64 [req_ext] subjectAltName = @alt_names [v3_ca] subjectAltName = @alt_names [alt_names] IP.1 = <trustee_ip> DNS.1 = localhost DNS.2 = 127.0.0.1
Generate the KBS key and self-signed certificate by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl req -x509 -nodes -days 365 \ -newkey rsa:2048 \ -keyout kbs.key \ -out kbs.crt \ -config kbs.conf \ -passin pass:
openssl req -x509 -nodes -days 365 \ -newkey rsa:2048 \ -keyout kbs.key \ -out kbs.crt \ -config kbs.conf \ -passin pass:
Copy the KBS key to the
ibmse
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cp kbs.key /tmp/ibmse/kbs.key
$ cp kbs.key /tmp/ibmse/kbs.key
Copy the KBS certificate to the
ibmse
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cp kbs.crt /tmp/ibmse/kbs.crt
$ cp kbs.crt /tmp/ibmse/kbs.crt
Obtain the attestation policy fields by performing the following steps:
Create a directory to download the
GetRvps.sh
script by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir -p Rvps-Extraction/
$ mkdir -p Rvps-Extraction/
Download the script by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget https://github.com/openshift/sandboxed-containers-operator/raw/devel/scripts/rvps-extraction/GetRvps.sh -O $PWD/GetRvps.sh
$ wget https://github.com/openshift/sandboxed-containers-operator/raw/devel/scripts/rvps-extraction/GetRvps.sh -O $PWD/GetRvps.sh
Create a subdirectory by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir -p Rvps-Extraction/static-files
$ mkdir -p Rvps-Extraction/static-files
Go to the
static-files
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cd Rvps-Extraction/static-files
$ cd Rvps-Extraction/static-files
Download the
pvextract-hdr
tool by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget https://github.com/openshift/sandboxed-containers-operator/raw/devel/scripts/rvps-extraction/static-files/pvextract-hdr -O $PWD/pvextract-hdr
$ wget https://github.com/openshift/sandboxed-containers-operator/raw/devel/scripts/rvps-extraction/static-files/pvextract-hdr -O $PWD/pvextract-hdr
Make the tool executable by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow chmod +x pvextract-hdr
$ chmod +x pvextract-hdr
Download the
se_parse_hdr.py
script by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget https://github.com/openshift/sandboxed-containers-operator/raw/devel/scripts/rvps-extraction/static-files/se_parse_hdr.py -O $PWD/se_parse_hdr.py
$ wget https://github.com/openshift/sandboxed-containers-operator/raw/devel/scripts/rvps-extraction/static-files/se_parse_hdr.py -O $PWD/se_parse_hdr.py
Copy your Host Key Document (HKD) certificate to the
static-files
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cp ~/path/to/<hkd_cert.crt> .
$ cp ~/path/to/<hkd_cert.crt> .
The
static-files
directory contains the following files:-
HKD.crt
-
pvextract-hdr
-
se_parse_hdr.py
-
Go to the
Rvps-Extraction
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cd ..
$ cd ..
Make the
GetRvps.sh
script executable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow chmod +x GetRvps.sh
$ chmod +x GetRvps.sh
Run the script:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ./GetRvps.sh
$ ./GetRvps.sh
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ***Installing necessary packages for RVPS values extraction *** Updating Subscription Management repositories. Last metadata expiration check: 0:37:12 ago on Mon Nov 18 09:20:29 2024. Package python3-3.9.19-8.el9_5.1.s390x is already installed. Package python3-cryptography-36.0.1-4.el9.s390x is already installed. Package kmod-28-10.el9.s390x is already installed. Dependencies resolved. Nothing to do. Complete! ***Installation Finished *** 1) Generate the RVPS From Local Image from User pc 2) Generate RVPS from Volume 3) Quit Please enter your choice:
***Installing necessary packages for RVPS values extraction *** Updating Subscription Management repositories. Last metadata expiration check: 0:37:12 ago on Mon Nov 18 09:20:29 2024. Package python3-3.9.19-8.el9_5.1.s390x is already installed. Package python3-cryptography-36.0.1-4.el9.s390x is already installed. Package kmod-28-10.el9.s390x is already installed. Dependencies resolved. Nothing to do. Complete! ***Installation Finished *** 1) Generate the RVPS From Local Image from User pc 2) Generate RVPS from Volume 3) Quit Please enter your choice:
Enter
2
to generate the Reference Value Provider Service from the volume:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Please enter your choice: 2
Please enter your choice: 2
Enter
fa-pp
for the libvirt pool name:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the Libvirt Pool Name: fa-pp
Enter the Libvirt Pool Name: fa-pp
Enter the libvirt gateway URI:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the Libvirt URI Name: <libvirt-uri>
Enter the Libvirt URI Name: <libvirt-uri>
1 - 1
- Specify the
LIBVIRT_URI
value that you used to create the peer pods secret.
Enter
fa-pp-vol
for the libvirt volume name:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the Libvirt Volume Name: fa-pp-vol
Enter the Libvirt Volume Name: fa-pp-vol
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Downloading from PODVM Volume... mount: /mnt/myvm: special device /dev/nbd3p1 does not exist. Error: Failed to mount the image. Retrying... Mounting on second attempt passed /dev/nbd3 disconnected SE header found at offset 0x014000 SE header written to '/root/Rvps-Extraction/output-files/hdr.bin' (640 bytes) se.tag: 42f3fe61e8a7e859cab3bb033fd11c61 se.image_phkh: 92d0aff6eb86719b6b1ea0cb98d2c99ff2ec693df3efff2158f54112f6961508 provenance = ewogICAgInNlLmF0dGVzdGF0aW9uX3Boa2giOiBbCiAgICAgICAgIjkyZDBhZmY2ZWI4NjcxOWI2YjFlYTBjYjk4ZDJjOTlmZjJlYzY5M2RmM2VmZmYyMTU4ZjU0MTEyZjY5NjE1MDgiCiAgICBdLAogICAgInNlLnRhZyI6IFsKICAgICAgICAiNDJmM2ZlNjFlOGE3ZTg1OWNhYjNiYjAzM2ZkMTFjNjEiCiAgICBdLAogICAgInNlLmltYWdlX3Boa2giOiBbCiAgICAgICAgIjkyZDBhZmY2ZWI4NjcxOWI2YjFlYTBjYjk4ZDJjOTlmZjJlYzY5M2RmM2VmZmYyMTU4ZjU0MTEyZjY5NjE1MDgiCiAgICBdLAogICAgInNlLnVzZXJfZGF0YSI6IFsKICAgICAgICAiMDAiCiAgICBdLAogICAgInNlLnZlcnNpb24iOiBbCiAgICAgICAgIjI1NiIKICAgIF0KfQo= -rw-r--r--. 1 root root 640 Dec 16 10:57 /root/Rvps-Extraction/output-files/hdr.bin -rw-r--r--. 1 root root 446 Dec 16 10:57 /root/Rvps-Extraction/output-files/ibmse-policy.rego -rw-r--r--. 1 root root 561 Dec 16 10:57 /root/Rvps-Extraction/output-files/se-message
Downloading from PODVM Volume... mount: /mnt/myvm: special device /dev/nbd3p1 does not exist. Error: Failed to mount the image. Retrying... Mounting on second attempt passed /dev/nbd3 disconnected SE header found at offset 0x014000 SE header written to '/root/Rvps-Extraction/output-files/hdr.bin' (640 bytes) se.tag: 42f3fe61e8a7e859cab3bb033fd11c61 se.image_phkh: 92d0aff6eb86719b6b1ea0cb98d2c99ff2ec693df3efff2158f54112f6961508 provenance = ewogICAgInNlLmF0dGVzdGF0aW9uX3Boa2giOiBbCiAgICAgICAgIjkyZDBhZmY2ZWI4NjcxOWI2YjFlYTBjYjk4ZDJjOTlmZjJlYzY5M2RmM2VmZmYyMTU4ZjU0MTEyZjY5NjE1MDgiCiAgICBdLAogICAgInNlLnRhZyI6IFsKICAgICAgICAiNDJmM2ZlNjFlOGE3ZTg1OWNhYjNiYjAzM2ZkMTFjNjEiCiAgICBdLAogICAgInNlLmltYWdlX3Boa2giOiBbCiAgICAgICAgIjkyZDBhZmY2ZWI4NjcxOWI2YjFlYTBjYjk4ZDJjOTlmZjJlYzY5M2RmM2VmZmYyMTU4ZjU0MTEyZjY5NjE1MDgiCiAgICBdLAogICAgInNlLnVzZXJfZGF0YSI6IFsKICAgICAgICAiMDAiCiAgICBdLAogICAgInNlLnZlcnNpb24iOiBbCiAgICAgICAgIjI1NiIKICAgIF0KfQo= -rw-r--r--. 1 root root 640 Dec 16 10:57 /root/Rvps-Extraction/output-files/hdr.bin -rw-r--r--. 1 root root 446 Dec 16 10:57 /root/Rvps-Extraction/output-files/ibmse-policy.rego -rw-r--r--. 1 root root 561 Dec 16 10:57 /root/Rvps-Extraction/output-files/se-message
Obtain the certificates and certificate revocation lists (CRLs) by performing the following steps:
Create a temporary directory for certificates by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir /tmp/ibmse/certs
$ mkdir /tmp/ibmse/certs
Download the
ibm-z-host-key-signing-gen2.crt
certificate by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget https://www.ibm.com/support/resourcelink/api/content/public/ibm-z-host-key-signing-gen2.crt -O /tmp/ibmse/certs/ibm-z-host-key-signing-gen2.crt
$ wget https://www.ibm.com/support/resourcelink/api/content/public/ibm-z-host-key-signing-gen2.crt -O /tmp/ibmse/certs/ibm-z-host-key-signing-gen2.crt
Download the
DigiCertCA.crt
certificate by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget https://www.ibm.com/support/resourcelink/api/content/public/DigiCertCA.crt -O /tmp/ibmse/certs/DigiCertCA.crt
$ wget https://www.ibm.com/support/resourcelink/api/content/public/DigiCertCA.crt -O /tmp/ibmse/certs/DigiCertCA.crt
Create a temporary directory for the CRLs by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir /tmp/ibmse/crls
$ mkdir /tmp/ibmse/crls
Download the
ibm-z-host-key-gen2.crl
file by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget https://www.ibm.com/support/resourcelink/api/content/public/ibm-z-host-key-gen2.crl -O /tmp/ibmse/crls/ibm-z-host-key-gen2.crl
$ wget https://www.ibm.com/support/resourcelink/api/content/public/ibm-z-host-key-gen2.crl -O /tmp/ibmse/crls/ibm-z-host-key-gen2.crl
Download the
DigiCertTrustedRootG4.crl
file by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget http://crl3.digicert.com/DigiCertTrustedRootG4.crl -O /tmp/ibmse/crls/DigiCertTrustedRootG4.crl
$ wget http://crl3.digicert.com/DigiCertTrustedRootG4.crl -O /tmp/ibmse/crls/DigiCertTrustedRootG4.crl
Download the
DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl
file by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget http://crl3.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl -O /tmp/ibmse/crls/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl
$ wget http://crl3.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl -O /tmp/ibmse/crls/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl
Create a temporary directory for the
hdr.bin
file by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir -p /tmp/ibmse/hdr/
$ mkdir -p /tmp/ibmse/hdr/
Copy the
hdr.bin
file to thehdr
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cp /root/Rvps-Extraction/output-files/hdr.bin /tmp/ibmse/hdr/
$ cp /root/Rvps-Extraction/output-files/hdr.bin /tmp/ibmse/hdr/
Create a temporary directory for Host Key Document (HKD) certificate by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir -p /tmp/ibmse/hkds
$ mkdir -p /tmp/ibmse/hkds
Copy your HKD certificate to the
hkds
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cp ~/path/to/<hkd_cert.crt> /tmp/ibmse/hkds/
$ cp ~/path/to/<hkd_cert.crt> /tmp/ibmse/hkds/
Generate the RSA keys:
Generate an RSA key pair by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl genrsa -aes256 -passout pass:<password> -out /tmp/encrypt_key-psw.pem 4096
$ openssl genrsa -aes256 -passout pass:<password> -out /tmp/encrypt_key-psw.pem 4096
1 - 1
- Specify the RSA key password.
Create a temporary directory for the RSA keys by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mkdir -p /tmp/ibmse/rsa
$ mkdir -p /tmp/ibmse/rsa
Create an
encrypt_key.pub
key by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl rsa -in /tmp/encrypt_key-psw.pem -passin pass:<password> -pubout -out /tmp/ibmse/rsa/encrypt_key.pub
$ openssl rsa -in /tmp/encrypt_key-psw.pem -passin pass:<password> -pubout -out /tmp/ibmse/rsa/encrypt_key.pub
Create an
encrypt_key.pem
key by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl rsa -in /tmp/encrypt_key-psw.pem -passin pass:<password> -out /tmp/ibmse/rsa/encrypt_key.pem
$ openssl rsa -in /tmp/encrypt_key-psw.pem -passin pass:<password> -out /tmp/ibmse/rsa/encrypt_key.pem
Verify the structure of the
/tmp/ibmse
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow tree /tmp/ibmse
$ tree /tmp/ibmse
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow /tmp/ibmse ├──kbs.key ├──kbs.crt | ├── certs │ ├── ibm-z-host-key-signing-gen2.crt | └── DigiCertCA.crt ├── crls │ └── ibm-z-host-key-gen2.crl │ └── DigiCertTrustedRootG4.crl │ └── DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl ├── hdr │ └── hdr.bin ├── hkds │ └── <hkd_cert.crt> └── rsa ├── encrypt_key.pem └── encrypt_key.pub
/tmp/ibmse ├──kbs.key ├──kbs.crt | ├── certs │ ├── ibm-z-host-key-signing-gen2.crt | └── DigiCertCA.crt ├── crls │ └── ibm-z-host-key-gen2.crl │ └── DigiCertTrustedRootG4.crl │ └── DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl ├── hdr │ └── hdr.bin ├── hkds │ └── <hkd_cert.crt> └── rsa ├── encrypt_key.pem └── encrypt_key.pub
Copy these files to the OpenShift Container Platform worker nodes by performing the following steps:
Create a compressed file from the
/tmp/ibmse
directory by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow tar -czf ibmse.tar.gz -C /tmp/ ibmse
$ tar -czf ibmse.tar.gz -C /tmp/ ibmse
Copy the
.tar.gz
file to the bastion node in your cluster by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow scp /tmp/ibmse.tar.gz root@<ocp_bastion_ip>:/tmp
$ scp /tmp/ibmse.tar.gz root@<ocp_bastion_ip>:/tmp
1 - 1
- Specify the IP address of the bastion node.
Connect to the bastion node over SSH by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh root@<ocp_bastion_ip>
$ ssh root@<ocp_bastion_ip>
Copy the
.tar.gz
file to each worker node by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow scp /tmp/ibmse.tar.gz core@<worker_node_ip>:/tmp
$ scp /tmp/ibmse.tar.gz core@<worker_node_ip>:/tmp
1 - 1
- Specify the IP address of the worker node.
Extract the
.tar.gz
on each worker node by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh core@<worker_node_ip> 'sudo mkdir -p /opt/confidential-containers/ && sudo tar -xzf /tmp/ibmse.tar.gz -C /opt/confidential-containers/'
$ ssh core@<worker_node_ip> 'sudo mkdir -p /opt/confidential-containers/ && sudo tar -xzf /tmp/ibmse.tar.gz -C /opt/confidential-containers/'
Update the
ibmse
folder permissions by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ssh core@<worker_node_ip> 'sudo chmod -R 755 /opt/confidential-containers/ibmse/'
$ ssh core@<worker_node_ip> 'sudo chmod -R 755 /opt/confidential-containers/ibmse/'
Create the secrets in the cluster with the KBS key and certificate by performing the following steps:
Create a
kbs-https-certificate.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: kbs-https-certificate namespace: trustee-operator-system data: https.crt: $(cat /tmp/ibmse/kbs.crt | base64 -w 0)
apiVersion: v1 kind: Secret metadata: name: kbs-https-certificate namespace: trustee-operator-system data: https.crt: $(cat /tmp/ibmse/kbs.crt | base64 -w 0)
Create the secret with the KBS certificate by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f kbs-https-certificate.yaml
$ oc apply -f kbs-https-certificate.yaml
Create a
kbs-https-key.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Secret metadata: name: kbs-https-key namespace: trustee-operator-system data: https.key: $(cat /tmp/ibmse/kbs.key | base64 -w 0)
apiVersion: v1 kind: Secret metadata: name: kbs-https-key namespace: trustee-operator-system data: https.key: $(cat /tmp/ibmse/kbs.key | base64 -w 0)
Create the secret with the KBS key by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f kbs-https-key.yaml
$ oc apply -f kbs-https-key.yaml
8.15. Creating the persistent storage components
You must create persistent storage components, persistent volume (PV) and persistent volume claim (PVC) to mount the ibmse
folder to the Trustee pod.
Procedure
Create a
persistent-volume.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: PersistentVolume metadata: name: ibmse-pv namespace: trustee-operator-system spec: capacity: storage: 100Mi accessModes: - ReadOnlyMany storageClassName: "" local: path: /opt/confidential-containers/ibmse nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: node-role.kubernetes.io/worker operator: Exists
apiVersion: v1 kind: PersistentVolume metadata: name: ibmse-pv namespace: trustee-operator-system spec: capacity: storage: 100Mi accessModes: - ReadOnlyMany storageClassName: "" local: path: /opt/confidential-containers/ibmse nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: node-role.kubernetes.io/worker operator: Exists
Create the persistent volume by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f persistent-volume.yaml
$ oc apply -f persistent-volume.yaml
Create a
persistent-volume-claim.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ibmse-pvc namespace: trustee-operator-system spec: accessModes: - ReadOnlyMany storageClassName: "" resources: requests: storage: 100Mi
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ibmse-pvc namespace: trustee-operator-system spec: accessModes: - ReadOnlyMany storageClassName: "" resources: requests: storage: 100Mi
Create the persistent volume claim by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f persistent-volume-claim.yaml
$ oc apply -f persistent-volume-claim.yaml
8.16. Configuring Trustee values, policies, and secrets
You can configure the following values, policies, and secrets for Trustee:
- Reference values for the Reference Value Provider Service.
- Attestation policy for IBM Secure Execution.
- Secret for custom keys for Trustee clients.
- Secret for container image signature verification.
- Container image signature verification policy. This policy is mandatory. If you do not use container image signature verification, you must create a policy that does not verify signatures.
- Resource access policy.
8.16.1. Configuring reference values
You can configure reference values for the Reference Value Provider Service (RVPS) by specifying the trusted digests of your hardware platform.
The client collects measurements from the running software, the Trusted Execution Environment (TEE) hardware and firmware and it submits a quote with the claims to the Attestation Server. These measurements must match the trusted digests registered to the Trustee. This process ensures that the confidential VM (CVM) is running the expected software stack and has not been tampered with.
Procedure
Create an
rvps-configmap.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: rvps-reference-values namespace: trustee-operator-system data: reference-values.json: | [ ]
apiVersion: v1 kind: ConfigMap metadata: name: rvps-reference-values namespace: trustee-operator-system data: reference-values.json: | [
1 ]
- 1
- Leave this value empty.
Create the RVPS config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f rvps-configmap.yaml
$ oc apply -f rvps-configmap.yaml
8.16.2. Creating the attestation policy for IBM Secure Execution
You must create the attestation policy for IBM Secure Execution.
Procedure
Create an
attestation-policy.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: attestation-policy namespace: trustee-operator-system data: default.rego: | package policy import rego.v1 default allow = false converted_version := sprintf("%v", [input["se.version"]]) allow if { input["se.attestation_phkh"] == "<se.attestation_phkh>" input["se.image_phkh"] == "<se.image_phkh>" input["se.tag"] == "<se.tag>" converted_version == "256" }
apiVersion: v1 kind: ConfigMap metadata: name: attestation-policy namespace: trustee-operator-system data: default.rego: | package policy import rego.v1 default allow = false converted_version := sprintf("%v", [input["se.version"]]) allow if { input["se.attestation_phkh"] == "<se.attestation_phkh>" input["se.image_phkh"] == "<se.image_phkh>" input["se.tag"] == "<se.tag>" converted_version == "256" }
- default.rego
- Do not modify the policy name.
- <se.attestation_phkh>
-
Replace this with the attestation policy fields you obtained by running the
se_parse_hdr.py
script.
Create the attestation policy config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f attestation-policy.yaml
$ oc apply -f attestation-policy.yaml
8.16.3. Creating a secret with custom keys for clients
You can create a secret that contains one or more custom keys for Trustee clients.
In this example, the kbsres1
secret has two entries (key1
, key2
), which the clients retrieve. You can add additional secrets according to your requirements by using the same format.
Prerequisites
- You have created one or more custom keys.
Procedure
Create a secret for the custom keys according to the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply secret generic kbsres1 \ --from-literal key1=<custom_key1> \ --from-literal key2=<custom_key2> \ -n trustee-operator-system
$ oc apply secret generic kbsres1 \ --from-literal key1=<custom_key1> \
1 --from-literal key2=<custom_key2> \ -n trustee-operator-system
- 1
- Specify a custom key.
The
kbsres1
secret is specified in thespec.kbsSecretResources
key of theKbsConfig
custom resource.
8.16.4. Creating a secret for container image signature verification
If you use container image signature verification, you must create a secret that contains the public container image signing key.
The Confidential compute attestation Operator uses the secret to verify the signature, ensuring that only trusted and authenticated container images are deployed in your environment.
You can use Red Hat Trusted Artifact Signer or other tools to sign container images.
Procedure
Create a secret for container image signature verification by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply secret generic <type> \ --from-file=<tag>=./<public_key_file> \ -n trustee-operator-system
$ oc apply secret generic <type> \
1 --from-file=<tag>=./<public_key_file> \
2 -n trustee-operator-system
-
Record the
<type>
value. You must add this value to thespec.kbsSecretResources
key when you create theKbsConfig
custom resource.
8.16.5. Creating the container image signature verification policy
You create the container image signature verification policy because signature verification is always enabled. If this policy is missing, the pods will not start.
If you are not using container image signature verification, you create the policy without signature verification.
For more information, see containers-policy.json 5.
Procedure
Create a
security-policy-config.json
file according to the following examples:Without signature verification:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "default": [ { "type": "insecureAcceptAnything" }], "transports": {} }
{ "default": [ { "type": "insecureAcceptAnything" }], "transports": {} }
With signature verification:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "default": [ ], "transports": { "docker": { "<container_registry_url>/<username>/busybox:latest": [ { "type": "sigstoreSigned", "keyPath": "kbs:///default/img-sig/pub-key" } ] } } }
{ "default": [ ], "transports": { "docker": { "<container_registry_url>/<username>/busybox:latest":
1 [ { "type": "sigstoreSigned", "keyPath": "kbs:///default/img-sig/pub-key"
2 } ] } } }
Create the security policy by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply secret generic security-policy \ --from-file=osc=./<security-policy-config.json> \ -n trustee-operator-system
$ oc apply secret generic security-policy \ --from-file=osc=./<security-policy-config.json> \ -n trustee-operator-system
Do not alter the secret type,
security-policy
, or the key,osc
.The
security-policy
secret is specified in thespec.kbsSecretResources
key of theKbsConfig
custom resource.
8.16.6. Creating the resource access policy
You configure the resource access policy for the Trustee policy engine. This policy determines which resources Trustee can access.
The Trustee policy engine is different from the Attestation Service policy engine, which determines the validity of TEE evidence.
Procedure
Create a
resourcepolicy-configmap.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: ConfigMap metadata: name: resource-policy namespace: trustee-operator-system data: policy.rego: package policy default allow = true allow { input["tee"] == "se" }
apiVersion: v1 kind: ConfigMap metadata: name: resource-policy namespace: trustee-operator-system data: policy.rego: package policy default allow = true allow { input["tee"] == "se" }
- policy.rego
-
The name of the resource policy,
policy.rego
, must match the resource policy defined in the Trustee config map. - package policy
- The resource policy follows the Open Policy Agent specification.
Create the resource policy config map by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f resourcepolicy-configmap.yaml
$ oc apply -f resourcepolicy-configmap.yaml
8.17. Creating the KbsConfig custom resource
You create the KbsConfig
custom resource (CR) to launch Trustee.
Then, you check the Trustee pods and pod logs to verify the configuration.
Procedure
Create a
kbsconfig-cr.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: confidentialcontainers.org/v1alpha1 kind: KbsConfig metadata: labels: app.kubernetes.io/name: kbsconfig app.kubernetes.io/instance: kbsconfig app.kubernetes.io/part-of: trustee-operator app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: trustee-operator name: kbsconfig namespace: trustee-operator-system spec: kbsConfigMapName: kbs-config-cm kbsAuthSecretName: kbs-auth-public-key kbsDeploymentType: AllInOneDeployment kbsRvpsRefValuesConfigMapName: rvps-reference-values kbsSecretResources: ["kbsres1", "security-policy", "<type>"] kbsResourcePolicyConfigMapName: resource-policy kbsAttestationPolicyConfigMapName: attestation-policy kbsHttpsKeySecretName: kbs-https-key kbsHttpsCertSecretName: kbs-https-certificate kbsServiceType: NodePort ibmSEConfigSpec: certStorePvc: ibmse-pvc KbsEnvVars: SE_SKIP_CERTS_VERIFICATION: "false"
apiVersion: confidentialcontainers.org/v1alpha1 kind: KbsConfig metadata: labels: app.kubernetes.io/name: kbsconfig app.kubernetes.io/instance: kbsconfig app.kubernetes.io/part-of: trustee-operator app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: trustee-operator name: kbsconfig namespace: trustee-operator-system spec: kbsConfigMapName: kbs-config-cm kbsAuthSecretName: kbs-auth-public-key kbsDeploymentType: AllInOneDeployment kbsRvpsRefValuesConfigMapName: rvps-reference-values kbsSecretResources: ["kbsres1", "security-policy", "<type>"]
1 kbsResourcePolicyConfigMapName: resource-policy kbsAttestationPolicyConfigMapName: attestation-policy kbsHttpsKeySecretName: kbs-https-key kbsHttpsCertSecretName: kbs-https-certificate kbsServiceType: NodePort ibmSEConfigSpec: certStorePvc: ibmse-pvc KbsEnvVars: SE_SKIP_CERTS_VERIFICATION: "false"
2 Create the
KbsConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f kbsconfig-cr.yaml
$ oc apply -f kbsconfig-cr.yaml
8.18. Verifying the Trustee configuration
You verify the Trustee configuration by checking the Trustee pods and logs.
Procedure
Set the default project by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc project trustee-operator-system
$ oc project trustee-operator-system
Check the Trustee pods by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pods -n trustee-operator-system
$ oc get pods -n trustee-operator-system
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME READY STATUS RESTARTS AGE trustee-deployment-8585f98449-9bbgl 1/1 Running 0 22m trustee-operator-controller-manager-5fbd44cd97-55dlh 2/2 Running 0 59m
NAME READY STATUS RESTARTS AGE trustee-deployment-8585f98449-9bbgl 1/1 Running 0 22m trustee-operator-controller-manager-5fbd44cd97-55dlh 2/2 Running 0 59m
Set the
POD_NAME
environmental variable by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow POD_NAME=$(oc get pods -l app=kbs -o jsonpath='{.items[0].metadata.name}' -n trustee-operator-system)
$ POD_NAME=$(oc get pods -l app=kbs -o jsonpath='{.items[0].metadata.name}' -n trustee-operator-system)
Check the pod logs by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -n trustee-operator-system $POD_NAME
$ oc logs -n trustee-operator-system $POD_NAME
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow [2024-05-30T13:44:24Z INFO kbs] Using config file /etc/kbs-config/kbs-config.json [2024-05-30T13:44:24Z WARN attestation_service::rvps] No RVPS address provided and will launch a built-in rvps [2024-05-30T13:44:24Z INFO attestation_service::token::simple] No Token Signer key in config file, create an ephemeral key and without CA pubkey cert [2024-05-30T13:44:24Z INFO api_server] Starting HTTPS server at [0.0.0.0:8080] [2024-05-30T13:44:24Z INFO actix_server::builder] starting 12 workers [2024-05-30T13:44:24Z INFO actix_server::server] Tokio runtime found; starting in existing Tokio runtime
[2024-05-30T13:44:24Z INFO kbs] Using config file /etc/kbs-config/kbs-config.json [2024-05-30T13:44:24Z WARN attestation_service::rvps] No RVPS address provided and will launch a built-in rvps [2024-05-30T13:44:24Z INFO attestation_service::token::simple] No Token Signer key in config file, create an ephemeral key and without CA pubkey cert [2024-05-30T13:44:24Z INFO api_server] Starting HTTPS server at [0.0.0.0:8080] [2024-05-30T13:44:24Z INFO actix_server::builder] starting 12 workers [2024-05-30T13:44:24Z INFO actix_server::server] Tokio runtime found; starting in existing Tokio runtime
Verify that the
kbs-service
is exposed on a node port by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get svc kbs-service -n trustee-operator-system
$ oc get svc kbs-service -n trustee-operator-system
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kbs-service NodePort 198.51.100.54 <none> 8080:31862/TCP 23h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kbs-service NodePort 198.51.100.54 <none> 8080:31862/TCP 23h
Obtain the Trustee deployment pod name by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pods -n trustee-operator-system | grep -i trustee-deployment
$ oc get pods -n trustee-operator-system | grep -i trustee-deployment
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME READY STATUS RESTARTS AGE trustee-deployment-d746679cd-plq82 1/1 Running 0 2m32s
NAME READY STATUS RESTARTS AGE trustee-deployment-d746679cd-plq82 1/1 Running 0 2m32s
8.19. Verifying the attestation process
You can verify the attestation process by creating a BusyBox pod. The pod image deploys the confidential workload where you can retrieve the key.
This procedure is an example to verify that attestation is working. Do not write sensitive data to standard I/O because the data can be captured by using a memory dump. Only data written to memory is encrypted.
Procedure
Create a
busybox.yaml
manifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: v1 kind: Pod metadata: name: busybox namespace: default labels: run: busybox spec: runtimeClassName: kata-remote restartPolicy: Never containers: - name: busybox image: quay.io/prometheus/busybox:latest imagePullPolicy: Always command: - "sleep" - "3600"
apiVersion: v1 kind: Pod metadata: name: busybox namespace: default labels: run: busybox spec: runtimeClassName: kata-remote restartPolicy: Never containers: - name: busybox image: quay.io/prometheus/busybox:latest imagePullPolicy: Always command: - "sleep" - "3600"
Create the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create -f busybox.yaml
$ oc create -f busybox.yaml
Log in to the pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc exec -it busybox -n default -- /bin/sh
$ oc exec -it busybox -n default -- /bin/sh
Get the secret key by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow wget http://127.0.0.1:8006/cdh/resource/default/kbsres1/key1
$ wget http://127.0.0.1:8006/cdh/resource/default/kbsres1/key1
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Connecting to 127.0.0.1:8006 (127.0.0.1:8006) saving to 'key1' key1 100% |*******************************************| 8 0:00:00 ETA 'key1' saved
Connecting to 127.0.0.1:8006 (127.0.0.1:8006) saving to 'key1' key1 100% |*******************************************| 8 0:00:00 ETA 'key1' saved
Display the
key1
value by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow cat key1
$ cat key1
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow res1val1/ #
res1val1/ #
Chapter 9. Monitoring
You can use the OpenShift Container Platform web console to monitor metrics related to the health status of your sandboxed workloads and nodes.
OpenShift sandboxed containers has a pre-configured dashboard available in the OpenShift Container Platform web console. Administrators can also access and query raw metrics through Prometheus.
9.1. About metrics
OpenShift sandboxed containers metrics enable administrators to monitor how their sandboxed containers are running. You can query for these metrics in Metrics UI In the OpenShift Container Platform web console.
OpenShift sandboxed containers metrics are collected for the following categories:
- Kata agent metrics
-
Kata agent metrics display information about the kata agent process running in the 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.
9.2. Viewing 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-admin
role 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.
Additional resources
Chapter 10. Uninstalling
You can uninstall OpenShift sandboxed containers and remove the Confidential Containers environment.
10.1. Uninstalling OpenShift sandboxed containers
You can uninstall OpenShift sandboxed containers by using the OpenShift Container Platform web console or the command line.
You uninstall OpenShift sandboxed containers by performing the following tasks:
- Delete the workload pods.
-
Delete the
KataConfig
custom resource (CR). - Uninstall the OpenShift sandboxed containers Operator.
-
Delete the
KataConfig
custom resource definition (CRD).
You must delete the workload pods before deleting the KataConfig
CR. The pod names usually have the prefix podvm
and custom tags, if provided. If you deployed OpenShift sandboxed containers or Confidential Containers on a cloud provider and any resources remain after following these procedures, you might receive an unexpected bill for those resources from your cloud provider. Once you complete uninstalling OpenShift sandboxed containers on a cloud provider, check the cloud provider console to ensure that the procedures deleted all of the resources.
10.1.1. Uninstalling OpenShift sandboxed containers by using the web console
You can uninstall OpenShift sandboxed containers by using the OpenShift Container Platform web console.
10.1.1.1. Deleting workload pods
You can delete the OpenShift sandboxed containers workload pods by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. - You have a list of pods that use the OpenShift sandboxed containers runtime class.
Procedure
- In the OpenShift Container Platform web console, navigate to Workloads → Pods.
- Enter the name of the pod that you want to delete in the Search by name field.
- Click the pod name to open it.
-
On the Details page, check that
kata
orkata-remote
is displayed for Runtime class. -
Click the Options menu
and select Delete Pod.
- Click Delete.
Repeat this procedure for each pod.
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
10.1.1.2. Deleting the KataConfig custom resource
You can delete the KataConfig
custom resource (CR) by using the web console.
Deleting the KataConfig
CR removes and uninstalls the kata
or kata-remote
runtime and its related resources from your cluster.
Deleting 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 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 CPU and network.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
-
Enter
OpenShift sandboxed containers Operator
in the Search by name field. - Click the Operator to open it and then click the KataConfig tab.
-
Click the Options menu
and select Delete
KataConfig
. - Click Delete in the confirmation window.
Wait for the kata
or kata-remote
runtime and resources to uninstall and for the worker nodes to reboot before continuing to the next step.
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
10.1.1.3. Uninstalling the OpenShift sandboxed containers Operator
You can uninstall the OpenShift sandboxed containers Operator by using OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KataConfig
custom resource.
Procedure
- Navigate to Operators → Installed Operators.
-
Enter
OpenShift sandboxed containers Operator
in the Search by name field. On the right side of the Operator Details page, select Uninstall Operator from the Actions list.
An Uninstall Operator? dialog box is displayed.
- Click Uninstall to remove the Operator, Operator deployments, and pods.
- Navigate to Administration → Namespaces.
-
Enter
openshift-sandboxed-containers-operator
in the Search by name field. -
Click the Options menu
and select Delete Namespace.
-
In the confirmation dialog, enter
openshift-sandboxed-containers-operator
and click Delete.
10.1.1.4. Deleting the KataConfig CRD
You can delete the KataConfig
custom resource definition (CRD) by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KataConfig
custom resource. - You have uninstalled the OpenShift sandboxed containers Operator.
Procedure
- In the web console, navigate to Administration → CustomResourceDefinitions.
-
Enter the
KataConfig
name in the Search by name field. - Click the Options menu and select Delete CustomResourceDefinition.
- Click Delete in the confirmation window.
10.1.2. Uninstalling OpenShift sandboxed containers by using the CLI
You can uninstall OpenShift sandboxed containers by using the command-line interface (CLI).
10.1.2.1. Deleting workload pods
You can delete the OpenShift sandboxed containers workload pods by using the CLI.
Prerequisites
-
You have the JSON processor (
jq
) utility installed.
Procedure
Search for the pods by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pods -A -o json | jq -r '.items[] | \ select(.spec.runtimeClassName == "<runtime>").metadata.name'
$ oc get pods -A -o json | jq -r '.items[] | \ select(.spec.runtimeClassName == "<runtime>").metadata.name'
1 - 1
- Replace
<runtime>
withkata
for bare metal deployments, or withkata-remote
for AWS, Azure, IBM Z®, and IBM® LinuxONE deployments.
Delete each pod by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete pod <pod>
$ oc delete pod <pod>
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
10.1.2.2. Deleting the KataConfig custom resource
You can delete the KataConfig
custom resource (CR) by using the command line.
Deleting the KataConfig
CR removes the runtime and its related resources from your cluster.
Deleting 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 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 CPU and network.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
.
Procedure
Delete the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete kataconfig example-kataconfig
$ 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
KataConfig
CR, the CLI stops responding until all worker nodes reboot. You must wait for the deletion process to complete before performing the verification.Verify that the custom resource was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get kataconfig example-kataconfig
$ oc get kataconfig example-kataconfig
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow No example-kataconfig instances exist
No example-kataconfig instances exist
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
10.1.2.3. Uninstalling the OpenShift sandboxed containers Operator
You can uninstall the OpenShift sandboxed containers Operator by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KataConfig
custom resource.
Procedure
Delete the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete subscription sandboxed-containers-operator -n openshift-sandboxed-containers-operator
$ oc delete subscription sandboxed-containers-operator -n openshift-sandboxed-containers-operator
Delete the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete namespace openshift-sandboxed-containers-operator
$ oc delete namespace openshift-sandboxed-containers-operator
10.1.2.4. Deleting the KataConfig CRD
You can delete the KataConfig
custom resource definition (CRD) by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KataConfig
custom resource. - You have uninstalled the OpenShift sandboxed containers Operator.
Procedure
Delete the
KataConfig
CRD by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete crd kataconfigs.kataconfiguration.openshift.io
$ oc delete crd kataconfigs.kataconfiguration.openshift.io
Verify that the CRD was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get crd kataconfigs.kataconfiguration.openshift.io
$ oc get crd kataconfigs.kataconfiguration.openshift.io
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Unknown CRD kataconfigs.kataconfiguration.openshift.io
Unknown CRD kataconfigs.kataconfiguration.openshift.io
10.2. Removing the Confidential Containers environment
You can remove the Confidential Containers environment by using the OpenShift Container Platform web console or the command line.
You remove the Confidential Containers environment by performing the following tasks:
-
Delete the
KbsConfig
custom resource. - Uninstall the Confidential compute attestation Operator.
-
Delete the
KbsConfig
custom resource definition.
10.2.1. Removing the Confidential Containers environment by using the web console
You can remove the Confidential Containers environment by using the OpenShift Container Platform web console.
10.2.1.1. Deleting the KbsConfig custom resource
You can delete the KbsConfig
custom resource (CR) by using the web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. - You have uninstalled OpenShift sandboxed containers.
Procedure
- In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
-
Enter
Confidential compute attestation
in the Search by name field. - Click the Operator to open it and then click the KbsConfig tab.
-
Click the Options menu
and select Delete
KbsConfig
. - Click Delete in the confirmation window.
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
10.2.1.2. Uninstalling the Confidential compute attestation Operator
You can uninstall the Confidential compute attestation Operator by using OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KbsConfig
custom resource.
Procedure
- Navigate to Operators → Installed Operators.
-
Enter
Confidential compute attestation
in the Search by name field. On the right side of the Operator Details page, select Uninstall Operator from the Actions list.
An Uninstall Operator? dialog box is displayed.
- Click Uninstall to remove the Operator, Operator deployments, and pods.
- Navigate to Administration → Namespaces.
-
Enter
trustee-operator-system
in the Search by name field. -
Click the Options menu
and select Delete Namespace.
-
In the confirmation dialog, enter
trustee-operator-system
and click Delete.
10.2.1.3. Deleting the KbsConfig CRD
You can delete the KbsConfig
custom resource definition (CRD) by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KbsConfig
custom resource. - You have uninstalled the Confidential compute attestation Operator.
Procedure
- In the web console, navigate to Administration → CustomResourceDefinitions.
-
Enter the
KbsConfig
name in the Search by name field. - Click the Options menu and select Delete CustomResourceDefinition.
- Click Delete in the confirmation window.
10.2.2. Removing the Confidential Containers environment by using the CLI
You can remove the Confidential Containers environment by using the command-line interface (CLI).
10.2.2.1. Deleting the KbsConfig custom resource
You can delete the KbsConfig
custom resource (CR) by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role. - You have uninstalled OpenShift sandboxed containers.
Procedure
Delete the
KbsConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete kbsconfig kbsconfig
$ oc delete kbsconfig kbsconfig
Verify that the custom resource was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get kbsconfig kbsconfig
$ oc get kbsconfig kbsconfig
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow No kbsconfig instances exist
No kbsconfig instances exist
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
10.2.2.2. Uninstalling the Confidential compute attestation Operator
You can uninstall the Confidential compute attestation Operator by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted the
KbsConfig
custom resource.
Procedure
Delete the subscription by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete subscription trustee-operator -n trustee-operator-system
$ oc delete subscription trustee-operator -n trustee-operator-system
Delete the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete namespace trustee-operator-system
$ oc delete namespace trustee-operator-system
10.2.2.3. Deleting the KbsConfig CRD
You can delete the KbsConfig
custom resource definition (CRD) by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role. -
You have deleted all pods that use
kata
orkata-remote
as theruntimeClass
. -
You have deleted the
KbsConfig
custom resource. - You have uninstalled the Confidential compute attestation Operator.
Procedure
Delete the
KbsConfig
CRD by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete crd kbsconfigs.confidentialcontainers.org
$ oc delete crd kbsconfigs.confidentialcontainers.org
Verify that the CRD was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get crd kbsconfigs.confidentialcontainers.org
$ oc get crd kbsconfigs.confidentialcontainers.org
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Unknown CRD kbsconfigs.confidentialcontainers.org
Unknown CRD kbsconfigs.confidentialcontainers.org
Chapter 11. Upgrading
The upgrade of the OpenShift sandboxed containers components consists of the following steps:
-
Upgrade OpenShift Container Platform to update the
Kata
runtime and its dependencies. - Upgrade the OpenShift sandboxed containers Operator to update the Operator subscription.
You can upgrade OpenShift Container Platform before or after the OpenShift sandboxed containers Operator upgrade, with the one exception noted below. Always apply the KataConfig
patch immediately after upgrading the OpenShift sandboxed containers Operator.
11.1. Upgrading resources
Red Hat Enterprise Linux CoreOS (RHCOS) extensions deploy the OpenShift sandboxed containers resources onto the cluster.
The RHCOS extension sandboxed containers
contains the required components to run OpenShift sandboxed containers, such as the Kata containers runtime, the hypervisor QEMU, and other dependencies. You upgrade the extension by upgrading the cluster to a new release of OpenShift Container Platform.
For more information about upgrading OpenShift Container Platform, see Updating Clusters.
11.2. Upgrading the Operator
Use Operator Lifecycle Manager (OLM) to upgrade the OpenShift sandboxed containers Operator either manually or automatically. Selecting between manual or automatic upgrade during the initial deployment determines the future upgrade mode. For manual upgrades, the OpenShift Container Platform web console shows the available updates that the cluster administrator can install.
For more information about upgrading the OpenShift sandboxed containers Operator in Operator Lifecycle Manager (OLM), see Updating installed Operators.
11.3. Updating the pod VM image
For AWS, Azure, and IBM deployments, you must update the pod VM image. Upgrading the OpenShift sandboxed containers Operator when the enablePeerpods:
paramter is true
will not update the existing pod VM image automatically. To update the pod VM image after an upgrade you must delete and re-create the KataConfig
CR.
You can also check the peer pod config map for AWS and Azure deployments to ensure that the image ID is empty before re-creating the KataConfig
CR.
11.3.1. Deleting the KataConfig custom resource
You can delete the KataConfig
custom resource (CR) by using the command line.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Delete the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc delete kataconfig example-kataconfig
$ oc delete kataconfig example-kataconfig
Verify that the custom resource was deleted by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get kataconfig example-kataconfig
$ oc get kataconfig example-kataconfig
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow No example-kataconfig instances exist
No example-kataconfig instances exist
When uninstalling OpenShift sandboxed containers deployed using a cloud provider, you must delete all of the pods. Any remaining pod resources might result in an unexpected bill from your cloud provider.
11.3.2. Ensure peer pods CM image ID is empty
When you delete the KataConfig
CR, it should delete the peer pods CM image ID. For AWS and Azure deployments, check to ensure that the peer pods CM image ID is empty.
Procedure
Obtain the config map you created for the peer pods:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get cm -n openshift-sandboxed-containers-operator peer-pods-cm -o jsonpath="{.data.AZURE_IMAGE_ID}"
$ oc get cm -n openshift-sandboxed-containers-operator peer-pods-cm -o jsonpath="{.data.AZURE_IMAGE_ID}"
Use
PODVM_AMI_ID
for AWS. UseAZURE_IMAGE_ID
for Azure.- Check the status stanza of the YAML file.
-
If the
PODVM_AMI_ID
parameter for AWS or theAZURE_IMAGE_ID
parameter for Azure contains a value, set the value to "". If you have set the value to "", patch the peer pods config map:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc patch configmap peer-pods-cm -n openshift-sandboxed-containers-operator -p '{"data":{"AZURE_IMAGE_ID":""}}'
$ oc patch configmap peer-pods-cm -n openshift-sandboxed-containers-operator -p '{"data":{"AZURE_IMAGE_ID":""}}'
Use
PODVM_AMI_ID
for AWS. UseAZURE_IMAGE_ID
for Azure.
11.3.3. Creating the KataConfig custom resource
You must create the KataConfig
custom resource (CR) to install kata-remote
as a runtime class on your worker nodes.
Creating the KataConfig
CR triggers the OpenShift sandboxed containers Operator to do the following:
-
Create a
RuntimeClass
CR namedkata-remote
with a default configuration. This enables users to configure workloads to usekata-remote
as the runtime by referencing the CR in theRuntimeClassName
field. This CR also specifies the resource overhead for the runtime.
OpenShift sandboxed containers installs kata-remote
as a secondary, optional runtime on the cluster and not as the primary runtime.
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 OpenShift Container Platform 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 access to the cluster as a user with the
cluster-admin
role.
Procedure
Create an
example-kataconfig.yaml
manifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
apiVersion: kataconfiguration.openshift.io/v1 kind: KataConfig metadata: name: example-kataconfig spec: enablePeerPods: true logLevel: info # kataConfigPoolSelector: # matchLabels: # <label_key>: '<label_value>'
1 Create the
KataConfig
CR by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f example-kataconfig.yaml
$ oc apply -f example-kataconfig.yaml
The new
KataConfig
CR is created and installskata-remote
as a runtime class on the worker nodes.Wait for the
kata-remote
installation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
When the status of all workers under
kataNodes
isinstalled
and the conditionInProgress
isFalse
without specifying a reason, thekata-remote
is installed on the cluster.Verify the daemon set by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
$ oc get -n openshift-sandboxed-containers-operator ds/osc-caa-ds
Verify the runtime classes by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get runtimeclass
$ oc get runtimeclass
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
NAME HANDLER AGE kata kata 152m kata-remote kata-remote 152m
Chapter 12. Troubleshooting
When troubleshooting OpenShift sandboxed containers, you can open a support case and provide debugging information using the must-gather
tool.
If you are a cluster administrator, you can also review logs on your own, enabling a more detailed level of logs.
12.1. Collecting data for Red Hat Support
When opening a support case, it is helpful to provide debugging information about your cluster to Red Hat Support.
The must-gather
tool enables you to collect diagnostic information about your OpenShift Container Platform cluster, including virtual machines and other data related to OpenShift sandboxed containers.
For prompt support, supply diagnostic information for both OpenShift Container Platform and OpenShift sandboxed containers.
Using the must-gather tool
The oc adm must-gather
CLI command collects the information from your cluster that is most likely needed for debugging issues, including:
- Resource definitions
- Service logs
By default, the oc adm must-gather
command uses the default plugin image and writes into ./must-gather.local
.
Alternatively, you can collect specific information by running the command with the appropriate arguments as described in the following sections:
To collect data related to one or more specific features, use the
--image
argument with an image, as listed in a following section.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc adm must-gather --image=registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel9:1.9.0
$ oc adm must-gather --image=registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel9:1.9.0
To collect the audit logs, use the
-- /usr/bin/gather_audit_logs
argument, as described in a following section.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc adm must-gather -- /usr/bin/gather_audit_logs
$ 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 with must-gather.local
. This directory is created in the current working directory.
For example:
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 ...
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-gather
command in a specific namespace by using the --run-namespace
option.
For example:
oc adm must-gather --run-namespace <namespace> --image=registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel9:1.9.0
$ oc adm must-gather --run-namespace <namespace> --image=registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel9:1.9.0
12.2. Collecting log data
The following features and objects are associated with OpenShift sandboxed containers:
- All namespaces and their child objects that belong to OpenShift sandboxed containers resources
- All OpenShift sandboxed containers custom resource definitions (CRDs)
You can collect the following component logs for each pod running with the kata
runtime:
- Kata agent logs
- Kata runtime logs
- QEMU logs
- Audit logs
- CRI-O logs
12.2.1. Enabling debug logs for CRI-O runtime
You can enable debug logs by updating the logLevel
field in the KataConfig
CR. This changes the log level in the CRI-O runtime for the worker nodes running OpenShift sandboxed containers.
Prerequisites
-
You have installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Change the
logLevel
field in your existingKataConfig
CR todebug
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc patch kataconfig <kataconfig> --type merge --patch '{"spec":{"logLevel":"debug"}}'
$ oc patch kataconfig <kataconfig> --type merge --patch '{"spec":{"logLevel":"debug"}}'
Monitor the
kata-oc
machine config pool until the value ofUPDATED
isTrue
, indicating that all worker nodes are updated:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get mcp kata-oc
$ oc get mcp kata-oc
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE kata-oc rendered-kata-oc-169 False True False 3 1 1 0 9h
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug node/<node_name>
$ oc debug node/<node_name>
Change the root directory to
/host
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow chroot /host
# chroot /host
Verify the changes in the
crio.conf
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow crio config | egrep 'log_level
# crio config | egrep 'log_level
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow log_level = "debug"
log_level = "debug"
12.2.2. Viewing debug logs for 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
QEMU only generates warning and error logs. These warnings and errors print to the node journal in both the Kata runtime logs and the 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
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 installed the OpenShift CLI (
oc
). -
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
To review the Kata agent logs and guest console logs, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata -g “reading guest console”
$ 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata
$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata
To review the
virtiofsd
logs, run the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t virtiofsd
$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t virtiofsd
To review the QEMU logs, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata -g "qemuPid=\d+"
$ oc debug node/<nodename> -- journalctl -D /host/var/log/journal -t kata -g "qemuPid=\d+"
Additional resources
- Gathering data about your cluster in the OpenShift Container Platform documentation
Appendix A. KataConfig status messages
The following table displays the status messages for the KataConfig
custom resource (CR) for a cluster with two worker nodes.
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. Thestatus
reportsTrue
and themessage
isNode <node_name> Degraded: <error_message_from_the_node>
. -
BlockedByExistingKataPods
: This is reported if there are pods running on a cluster that use thekata-remote
runtime whilekata-remote
is being uninstalled. Thestatus
field isFalse
and themessage
isExisting 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.