Skip to content

Commit f12a4a0

Browse files
butler54claude
andauthored
fix: rewrite firmware collection to use veritas container approach (#94)
* feat: add label-based exclusion for firmware collection pods Add exclude block to inject-coco-initdata Kyverno policy to skip pods with label coco.io/skip-initdata: "true". Update firmware collection script to add this label to the pod, preventing Kyverno from trying to inject init_data (which would fail since the pod doesn't have coco.io/initdata-configmap annotation). The firmware collection pod doesn't need init_data injection because it only collects measurements from the TEE device - it doesn't attest to KBS or request secrets. Fixes error: mutation policy inject-coco-initdata error: failed to evaluate preconditions: failed to substitute variables in condition key Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: rewrite firmware collection to use veritas container approach Complete rewrite based on Red Hat documentation and veritas usage: - Runs veritas via podman container (quay.io/openshift_sandboxed_containers/coco-tools:1.12) - No cluster pods needed - computes firmware values locally from OCP release artifacts - Auto-detects OCP version from cluster or accepts --ocp-version flag - Extracts reference-values.json from veritas ConfigMap output - Saves to ~/.coco-pattern/firmware-reference-values.json - Uses --hw-xfam-allow x87,sse,avx to prevent attestation failures Previous approach was fundamentally wrong: - Tried to run veritas inside a kata pod on the cluster - Tried to "collect" from /dev/tdx_guest (doesn't work that way) - Veritas doesn't collect from running hardware - it computes expected values from OCP release artifacts (kata RPMs, edk2 firmware, etc.) Now follows the documented approach: https://docs.redhat.com/en/documentation/openshift_sandboxed_containers/1.12 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: transform veritas array output to object format for RVPS policy Veritas outputs firmware reference values as a JSON array: [{"name": "mr_td", "value": [...]}, ...] But the trustee-chart RVPS ConfigurationPolicy template expects an object format: {"mr_td": [...], "rtmr_1": [...], ...} Transform the veritas output using jq: [.[] | {(.name): .value}] | add This fixes the RVPS policy error: can't evaluate field mr_td in type []interface {} Also added jq to prerequisites check. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: add -r flag to yq for cross-version compatibility yq v3 (kislyuk/yq) outputs JSON strings with quotes by default, so the embedded JSON in the YAML ConfigMap stays quoted and jq receives a string instead of an array. Adding -r outputs the raw string, which both yq v3 and v4 handle correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: unify reference value collection for azure and baremetal Generalize collect-firmware-refvals.sh to support both platforms via --platform flag (baremetal default, azure optional). This replaces get-pcr.sh for Azure deployments — veritas pulls the same dm-verity image, verifies its signature via cosign, and extracts PCR values. Azure: outputs to ~/.coco-pattern/measurements.json (pcrStash secret) Baremetal: outputs to ~/.coco-pattern/firmware-reference-values.json Also adds yq -r fix for v3/v4 cross-compatibility and a new 'make collect-azure-refvals' Makefile target. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: update RHDP wrappers to use unified reference value collection Replace get-pcr.sh call with collect-firmware-refvals.sh --platform azure in wrapper.sh. Add missing reference value collection step to wrapper-multicluster.sh (was never collecting PCR values for Vault). Update RHDP README with prerequisites, env vars, and all deployment modes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent bfc6374 commit f12a4a0

6 files changed

Lines changed: 188 additions & 191 deletions

File tree

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
include Makefile-common
66

7-
##@ Firmware Reference Values
7+
##@ Reference Value Collection
88
.PHONY: collect-firmware-refvals
9-
collect-firmware-refvals: ## Collect firmware reference values from bare metal cluster
9+
collect-firmware-refvals: ## Collect firmware reference values (bare metal, default)
1010
@scripts/collect-firmware-refvals.sh
1111

12-
.PHONY: collect-firmware-refvals-merge
13-
collect-firmware-refvals-merge: ## Collect and merge with existing firmware refvals
14-
@scripts/collect-firmware-refvals.sh --merge
12+
.PHONY: collect-azure-refvals
13+
collect-azure-refvals: ## Collect PCR reference values (Azure)
14+
@scripts/collect-firmware-refvals.sh --platform azure

charts/all/coco-kyverno-policies/templates/inject-coco-initdata.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ spec:
2424
- Pod
2525
operations:
2626
- CREATE
27+
exclude:
28+
any:
29+
- resources:
30+
selector:
31+
matchLabels:
32+
coco.io/skip-initdata: "true"
2733
preconditions:
2834
all:
2935
- key: "{{ "{{" }}request.object.spec.runtimeClassName || '' {{ "}}" }}"

rhdp/README.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
Red Hat demo platform is a system for employees and red hat partners to generate test infrastructure.
44
The scripts in this directory help users of that platform automate deployments.
55

6+
## Prerequisites
7+
8+
- `podman` installed and running (used for reference value collection)
9+
- `yq`, `jq` installed
10+
- OpenShift pull secret at `~/pull-secret.json`
11+
- SSH key at `~/.ssh/id_rsa` (RSA)
12+
- RHDP environment variables loaded (see below)
13+
14+
## Environment variables
15+
16+
Provided by your RHDP Azure Open Environment:
17+
18+
```shell
19+
export GUID=
20+
export CLIENT_ID=
21+
export PASSWORD=
22+
export TENANT=
23+
export SUBSCRIPTION=
24+
export RESOURCEGROUP=
25+
```
26+
627
## To deploy
728

829
1. Stand up the 'Azure Subscription Based Blank Open Environment'
@@ -12,13 +33,23 @@ The scripts in this directory help users of that platform automate deployments.
1233

1334
### Single Cluster Deployment
1435

15-
1. `bash ./rhdp/wrapper.sh eastasia`
16-
2. The wrapper script **requires** an azure region code this code SHOULD be the same as what was selected in RHDP.
36+
1. Set `main.clusterGroupName: simple` in `values-global.yaml`
37+
2. `bash ./rhdp/wrapper.sh eastasia`
38+
3. The wrapper script **requires** an azure region code. This code SHOULD be the same as what was selected in RHDP.
39+
4. Optionally use `--prefix` for custom cluster naming: `bash ./rhdp/wrapper.sh --prefix dev1 eastasia`
40+
41+
The wrapper handles: cluster provisioning, secret generation, PCR reference value collection (via veritas), and pattern installation.
1742

1843
### Multi-Cluster Deployment (Hub and Spoke)
1944

20-
1. `bash ./rhdp/wrapper-multicluster.sh eastasia`
21-
2. This creates two clusters: `coco-hub` and `coco-spoke` in the same region
22-
3. The pattern is deployed only on the hub cluster
23-
4. Hub cluster kubeconfig: `./openshift-install-hub/auth/kubeconfig`
24-
5. Spoke cluster kubeconfig: `./openshift-install-spoke/auth/kubeconfig`
45+
1. Set `main.clusterGroupName: trusted-hub` in `values-global.yaml`
46+
2. `bash ./rhdp/wrapper-multicluster.sh eastasia`
47+
3. This creates two clusters: `coco-hub` and `coco-spoke` in the same region
48+
4. The pattern is deployed on the hub cluster; the spoke is imported into ACM
49+
5. Hub cluster kubeconfig: `./openshift-install-hub/auth/kubeconfig`
50+
6. Spoke cluster kubeconfig: `./openshift-install-spoke/auth/kubeconfig`
51+
52+
### Cluster Only (no pattern install)
53+
54+
1. `bash ./rhdp/wrapper-cluster-only.sh eastasia`
55+
2. Provisions the cluster without installing secrets or the pattern

rhdp/wrapper-multicluster.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ echo "---------------------"
144144
echo "setting up secrets"
145145
bash ./scripts/gen-secrets.sh
146146

147+
echo "---------------------"
148+
echo "retrieving PCR measurements"
149+
echo "---------------------"
150+
bash ./scripts/collect-firmware-refvals.sh --platform azure
151+
147152
echo "---------------------"
148153
echo "starting pattern install on hub cluster"
149154
echo "---------------------"

rhdp/wrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ bash ./scripts/gen-secrets.sh
189189
echo "---------------------"
190190
echo "retrieving PCR measurements"
191191
echo "---------------------"
192-
bash ./scripts/get-pcr.sh
192+
bash ./scripts/collect-firmware-refvals.sh --platform azure
193193

194194
sleep 60
195195
echo "---------------------"

0 commit comments

Comments
 (0)