Este conteúdo não está disponível no idioma selecionado.
Chapter 2. Deploying confidential containers on bare metal
You can deploy confidential containers workloads on a Red Hat OpenShift Container Platform cluster running on bare metal.
Confidential containers on bare metal 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.
2.1. Preparation Copiar o linkLink copiado para a área de transferência!
Review these prerequisites and concepts before you deploy confidential containers on bare metal.
2.1.1. Prerequisites Copiar o linkLink copiado para a área de transferência!
- You have installed the latest version of Red Hat OpenShift Container Platform on the cluster where you are running your confidential containers workload.
- You have deployed Red Hat build of Trustee on an OpenShift Container Platform cluster in a trusted environment. For more information, see Deploying Red Hat build of Trustee.
2.1.2. Initdata Copiar o linkLink copiado para a área de transferência!
The initdata specification provides a flexible way to initialize a pod with workload-specific data at runtime, avoiding the need to embed such data in the virtual machine (VM) image.
This approach enhances security by reducing the 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.regofile to enforce runtime behavior when overriding the default Kata Agent policy.
The initdata content configures the following components:
- Attestation Agent (AA), which verifies the trustworthiness of the pod by sending evidence for attestation.
- Confidential Data Hub (CDH), which manages secrets and secure data access within the pod VM.
- Kata Agent, which enforces runtime policies and manages the lifecycle of the containers inside the pod VM.
You create an initdata.toml file and convert it to a Base64-encoded, gzip-format string. You apply the initdata string to your workload by adding an annotation to the pod manifest.
2.1.3. Kata runtime deployment modes Copiar o linkLink copiado para a área de transferência!
You can choose how the Operator installs and configures the Kata runtime using the deployment modes MachineConfig, DaemonSet, or DaemonSetFallback. You specify the data.deploymentMode key in the osc-feature-gates config map. This flexibility allows the Operator to work consistently in clusters with or without the Machine Config Operator (MCO).
MachineConfig-
For clusters that use the Machine Config Operator (MCO). If the
deploymentModekey is missing in the config map, the Operator defaults to theMachineConfigfor backward compatibility. DaemonSet-
For clusters without the MCO. The Operator uses a
DaemonSetto install kata-containers RPMs and manage CRI-O configuration by using host drop-in files. Installation progress is tracked through node labels (for example,installing,installed). DaemonSetFallback-
Enables conditional deployment based on the cluster environment. When set, the operator checks for the presence of the MCO. It uses
DaemonSetif theMachineConfigadd-on is unavailable and defaults toMachineConfigotherwise.
2.2. Deployment overview Copiar o linkLink copiado para a área de transferência!
You deploy confidential containers on bare metal by performing the following steps:
- Create MachineConfig for TDX.
- Install the OpenShift sandboxed containers Operator.
- Configure the TDX remote attestation infrastructure for TDX workloads.
- Enable the confidential containers feature gate.
-
Create the
KataConfigCR. - Verify the attestation process.
2.3. Creating MachineConfig config map for TDX Copiar o linkLink copiado para a área de transferência!
If you use Intel Trust Domain Extensions (TDX), you must create a MachineConfig object before you install the Red Hat build of Trustee Operator.
Procedure
Create a
tdx-machine-config.yamlmanifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify
masterfor single-node OpenShift orkata-ocfor a multi-node cluster.
Create the TDX config map by running the following command:
oc create -f tdx-config.yaml
$ oc create -f tdx-config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Installing the OpenShift sandboxed containers Operator Copiar o linkLink copiado para a área de transferência!
You install the OpenShift sandboxed containers Operator by using the command line interface (CLI).
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
Create an
osc-namespace.yamlmanifest file:apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operator
apiVersion: v1 kind: Namespace metadata: name: openshift-sandboxed-containers-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the namespace by running the following command:
oc apply -f osc-namespace.yaml
$ oc apply -f osc-namespace.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an
osc-operatorgroup.yamlmanifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the operator group by running the following command:
oc apply -f osc-operatorgroup.yaml
$ oc apply -f osc-operatorgroup.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an
osc-subscription.yamlmanifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the subscription by running the following command:
oc create -f osc-subscription.yaml
$ oc create -f osc-subscription.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the Operator is correctly installed by running the following command:
oc get csv -n openshift-sandboxed-containers-operator
$ oc get csv -n openshift-sandboxed-containers-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command can take several minutes to complete.
Watch the process by running the following command:
watch oc get csv -n openshift-sandboxed-containers-operator
$ watch oc get csv -n openshift-sandboxed-containers-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.11.0 1.10.3 Succeeded
NAME DISPLAY VERSION REPLACES PHASE openshift-sandboxed-containers openshift-sandboxed-containers-operator 1.11.0 1.10.3 SucceededCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5. Configuring auto-detection of TEEs Copiar o linkLink copiado para a área de transferência!
You must configure your nodes so that the OpenShift sandboxed containers Operator can detect the Trusted Execution Environments (TEEs).
You label the nodes by installing and configuring the Node Feature Discovery (NFD) Operator.
2.5.1. Creating a NodeFeatureDiscovery custom resource Copiar o linkLink copiado para a área de transferência!
You create a NodeFeatureDiscovery custom resource (CR) to define the configuration parameters that the Node Feature Discovery (NFD) Operator checks to automatically detect your TEE.
Prerequisites
- You have installed the NFD Operator. For more information, see Node Feature Discovery Operator in the OpenShift Container Platform documentation.
Procedure
Create a
my-nfd.yamlmanifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
NodeFeatureDiscoveryCR:oc create -f my-nfd.yaml
$ oc create -f my-nfd.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5.2. Creating the NodeFeatureRule custom resource Copiar o linkLink copiado para a área de transferência!
Create a NodeFeatureRule custom resource for your Trusted Execution Environment (TEE).
Procedure
Create a custom resource manifest named
my-nodefeaturerule.yamlfor your TEE:Copy to Clipboard Copied! Toggle word wrap Toggle overflow AMD SEV-SNP:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Intel TDX:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Create the
NodeFeatureRuleCR by running the following command:oc create -f my-nodefeaturerule.yaml
$ oc create -f my-nodefeaturerule.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
A relabeling delay of up to 1 minute might occur.
2.6. Configuring the TDX remote attestation infrastructure for TDX workloads Copiar o linkLink copiado para a área de transferência!
You can deploy pod VM images for confidential containers bare-metal infrastructure, which includes the following components that provide remote attestation for Intel Trust Domain Extensions (TDX):
- In-cluster Provisioning Certificate Caching Service (PCCS) deployment
- Automatic per-node PCK Cert ID Retrieval Tool based platform (re-)registration
- Per-node TDX-QGS quoting service
You can set up the namespaces, secrets, certificates, and environment variables required for your deployment.
Prerequisites
- You have installed the Intel Device Plugins Operator and created an instance of the Intel Software Guard Extensions Device Plugin. For details, see Installing from the software catalog by using the web console in the OpenShift Container Platform documentation.
- The node on which you deploy PCCS must have Internet access.
Procedure
Create the
intel-dcapnamespace by running the following command:oc create namespace intel-dcap
$ oc create namespace intel-dcapCopy to Clipboard Copied! Toggle word wrap Toggle overflow Switch to the
intel-dcapproject by running the following command:oc project intel-dcap
$ oc project intel-dcapCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update the Security Context Constraint by running the following command:
oc adm policy add-scc-to-user privileged -z default
$ oc adm policy add-scc-to-user privileged -z defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Switch to the default project by running the following command:
oc project default
$ oc project defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
PCCS_API_KEYvariable by running the following command:export PCCS_API_KEY="${PCCS_API_KEY:-}"$ export PCCS_API_KEY="${PCCS_API_KEY:-}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow PCCS_API_KEY- The API key for Intel® SGX and Intel® TDX Provisioning Certification Service. Navigate to Intel Trusted Services API portal, sign in, and subscribe to the Intel® SGX and Intel® TDX Provisioning Certification Service. The API key is displayed on the Manage Subscriptions page.
Set the
PCCS_USER_TOKENvariable by running the following command:export PCCS_USER_TOKEN="${PCCS_USER_TOKEN:-mytoken}"$ export PCCS_USER_TOKEN="${PCCS_USER_TOKEN:-mytoken}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow PCCS_USER_TOKEN- Specify the PCCS user token. For details, see the Design Guide for Intel® SGX Provisioning Certificate Caching Service (Intel® SGX PCCS).
Set the
PCCS_ADMIN_TOKENvariable by running the following command:export PCCS_ADMIN_TOKEN="${PCCS_ADMIN_TOKEN:-mytoken}"$ export PCCS_ADMIN_TOKEN="${PCCS_ADMIN_TOKEN:-mytoken}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow PCCS_ADMIN_TOKEN- Specify the PCCS administration token. For details, see the Design Guide for Intel® SGX Provisioning Certificate Caching Service (Intel® SGX PCCS).
Set the value for the
PCCS_NODEvariable to the name of the control plane node by running the following command:export PCCS_NODE=$(oc get nodes \ -l 'node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=' \ -o jsonpath='{.items[0].metadata.name}')$ export PCCS_NODE=$(oc get nodes \ -l 'node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=' \ -o jsonpath='{.items[0].metadata.name}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the cluster-wide proxy variable:
If you are using a cluster-wide proxy, run the following command:
export CLUSTER_HTTPS_PROXY="$(oc get proxy/cluster \ -o jsonpath={.spec.httpsProxy})"$ export CLUSTER_HTTPS_PROXY="$(oc get proxy/cluster \ -o jsonpath={.spec.httpsProxy})"Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you are not using a proxy, run the following command:
export CLUSTER_NO_PROXY="$(oc get proxy/cluster \ -o jsonpath={.spec.noProxy})"$ export CLUSTER_NO_PROXY="$(oc get proxy/cluster \ -o jsonpath={.spec.noProxy})"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Generate a SHA-512 hash of the PCCS user token by running the following command:
export PCCS_USER_TOKEN_HASH=$(echo -n "$PCCS_USER_TOKEN" | sha512sum | tr -d '[:space:]-')
$ export PCCS_USER_TOKEN_HASH=$(echo -n "$PCCS_USER_TOKEN" | sha512sum | tr -d '[:space:]-')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a SHA-512 hash of the PCCS admin token by running the following command:
export PCCS_ADMIN_TOKEN_HASH=$(echo -n "$PCCS_ADMIN_TOKEN" | sha512sum | tr -d '[:space:]-')
$ export PCCS_ADMIN_TOKEN_HASH=$(echo -n "$PCCS_ADMIN_TOKEN" | sha512sum | tr -d '[:space:]-')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a temporary directory for the PCCS certificate and key by running the following command:
PCCS_PEM_CERT_PATH=$(mktemp -d)
$ PCCS_PEM_CERT_PATH=$(mktemp -d)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a self-signed PCCS certificate and private key by running the following command:
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \ -keyout $PCCS_PEM_CERT_PATH/private.pem \ -out $PCCS_PEM_CERT_PATH/certificate.pem \ -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
$ openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \ -keyout $PCCS_PEM_CERT_PATH/private.pem \ -out $PCCS_PEM_CERT_PATH/certificate.pem \ -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the value of the
PCCS_PEMto the Base64-encoded PCCS private key by running the following command:export PCCS_PEM=$(cat "$PCCS_PEM_CERT_PATH"/private.pem | base64 | tr -d '\n')
$ export PCCS_PEM=$(cat "$PCCS_PEM_CERT_PATH"/private.pem | base64 | tr -d '\n')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the value of
PCCS_CERTto the Base64-encoded PCCS certificate by running the following command:export PCCS_CERT=$(cat "$PCCS_PEM_CERT_PATH"/certificate.pem | base64 | tr -d '\n')
$ export PCCS_CERT=$(cat "$PCCS_PEM_CERT_PATH"/certificate.pem | base64 | tr -d '\n')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a generic secret for PCCS by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.7. Creating the osc-feature-gates config map Copiar o linkLink copiado para a área de transferência!
You enable the confidential containers feature gate and specify the deployment mode by creating the config map.
Procedure
Create a
my-feature-gate.yamlmanifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where
<deployment_mode>On OpenShift Container Platform clusters with the Machine Config Operator (MCO), the
deploymentModefield is optional and can be omitted. Specifies the strategy for installing and configuring the Kata runtime. Specify the deployment mode:-
MachineConfigfor clusters that always use the MCO -
DaemonSetfor clusters that never use the MCO -
DaemonSetFallbackfor clusters that sometimes use the MCO
-
Create the
my-feature-gatesconfig map by running the following command:oc create -f my-feature-gate.yaml
$ oc create -f my-feature-gate.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.8. Creating initdata Copiar o linkLink copiado para a área de transferência!
You create initdata to securely initialize a pod with sensitive or workload-specific data at runtime, thus avoiding the need to embed this data in a virtual machine image. This approach provides additional security by reducing the risk of exposure of confidential information and eliminates the need for custom image builds.
You must delete the kbs_cert setting if you configure insecure_http = true in the kbs-config config map for Red Hat build of Trustee.
Procedure
Create the
initdata.tomlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - url
- Specify the Red Hat build of Trustee
- <kbs_certificate>
- Specify the Base64-encoded TLS certificate for the attestation agent.
- kbs_cert
-
Delete the
kbs_certsetting if you configureinsecure_http = truein thekbs-configconfig map for Red Hat build of Trustee. - image_security_policy_uri
-
Optional, only if you enabled the container image signature verification policy. Replace
<secret-policy-name>and<key>with the secret name and key, respectively specified in Creating the KbsConfig custom resource.
Convert the
initdata.tomlfile to a Base64-encoded string in gzip format in a text file by running the following command:cat initdata.toml | gzip | base64 -w0 > initdata.txt
$ cat initdata.toml | gzip | base64 -w0 > initdata.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow Record this string to use in the pod manifest.
Calculate the SHA-256 hash of an
initdata.tomlfile and assign its value to thehashvariable by running the following command:hash=$(sha256sum initdata.toml | cut -d' ' -f1)
$ hash=$(sha256sum initdata.toml | cut -d' ' -f1)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Assign 32 bytes of 0s to the
initial_pcrvariable by running the following command:initial_pcr=0000000000000000000000000000000000000000000000000000000000000000
$ initial_pcr=0000000000000000000000000000000000000000000000000000000000000000Copy to Clipboard Copied! Toggle word wrap Toggle overflow Calculate the SHA-256 hash of
hashandinitial_pcrand assign its value to thePCR8_HASHvariable by running the following command:PCR8_HASH=$(echo -n "$initial_pcr$hash" | xxd -r -p | sha256sum | cut -d' ' -f1) && echo $PCR8_HASH
$ PCR8_HASH=$(echo -n "$initial_pcr$hash" | xxd -r -p | sha256sum | cut -d' ' -f1) && echo $PCR8_HASHCopy to Clipboard Copied! Toggle word wrap Toggle overflow Record the
PCR8_HASHvalue for the RVPS config map.
2.9. Applying initdata to a pod Copiar o linkLink copiado para a área de transferência!
Prerequisite
- You have created an initdata string.
Procedure
Add the initdata string to the pod manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the pod by running the following command:
oc create -f my-pod.yaml
$ oc create -f my-pod.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.10. Creating the KataConfig custom resource Copiar o linkLink copiado para a área de transferência!
You must create the KataConfig custom resource (CR) to install kata-cc as a runtime class on your worker nodes.
OpenShift sandboxed containers installs kata-cc 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 can increase the reboot time:
- A large 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.
Procedure
Create an
example-kataconfig.yamlmanifest file according to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
KataConfigCR by running the following command:oc create -f example-kataconfig.yaml
$ oc create -f example-kataconfig.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow The new
KataConfigCR is created and installskata-ccas a runtime class on the worker nodes.Wait for the
kata-ccinstallation to complete and the worker nodes to reboot before verifying the installation.Monitor the installation progress by running the following command:
watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"
$ watch "oc describe kataconfig | sed -n /^Status:/,/^Events/p"Copy to Clipboard Copied! Toggle word wrap Toggle overflow When the status of all workers under
kataNodesisinstalledand the conditionInProgressisFalsewithout specifying a reason, thekata-ccis installed on the cluster.Verify the runtime classes by running the following command:
oc get runtimeclass
$ oc get runtimeclassCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME HANDLER AGE kata-cc kata-tdx 152m
NAME HANDLER AGE kata-cc kata-tdx 152mCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.11. Verifying attestation Copiar o linkLink copiado para a área de transferência!
You can verify the attestation process by creating a test pod to retrieve a specific resource from Red Hat build of Trustee.
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
test-pod.yamlmanifest file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the pod by running the following command:
oc create -f test-pod.yaml
$ oc create -f test-pod.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Log in to the pod by running the following command:
oc exec -it ocp-cc-pod -- bash
$ oc exec -it ocp-cc-pod -- bashCopy to Clipboard Copied! Toggle word wrap Toggle overflow Fetch the Red Hat build of Trustee resource by running the following command:
curl http://127.0.0.1:8006/cdh/resource/default/attestation-status/status
$ curl http://127.0.0.1:8006/cdh/resource/default/attestation-status/statusCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
success #/
success #/Copy to Clipboard Copied! Toggle word wrap Toggle overflow