|
| 1 | +# SPIRE Agent with x509pop attestation running in CoCo peer pod. |
| 2 | +# Uses CDH sealed secrets for agent credentials (cert/key fetched from KBS after TEE attestation). |
| 3 | +apiVersion: v1 |
| 4 | +kind: Pod |
| 5 | +metadata: |
| 6 | + name: spire-agent-cc |
| 7 | + namespace: zero-trust-workload-identity-manager |
| 8 | + labels: |
| 9 | + app: spire-agent-cc |
| 10 | +spec: |
| 11 | + runtimeClassName: kata-remote |
| 12 | + # shareProcessNamespace allows SPIRE agent to inspect workload processes for unix attestation |
| 13 | + # This is secure because the real isolation boundary is the confidential VM (peer-pod with TEE), |
| 14 | + # not individual containers. All containers in this pod are part of the same trust boundary. |
| 15 | + shareProcessNamespace: true |
| 16 | + serviceAccountName: spire-agent |
| 17 | + # TODO: Make imagePullSecrets configurable like qtodo chart pattern (values.yaml + conditional) |
| 18 | + # Currently hardcoded 'global-pull-secret' which must be manually created in the namespace |
| 19 | + # Should either: 1) use ServiceAccount.imagePullSecrets, or 2) be conditional from values |
| 20 | + imagePullSecrets: |
| 21 | + - name: global-pull-secret |
| 22 | + |
| 23 | + containers: |
| 24 | + # SPIRE Agent Sidecar |
| 25 | + - name: spire-agent |
| 26 | + image: registry.redhat.io/zero-trust-workload-identity-manager/spiffe-spire-agent-rhel9@sha256:4073ef462525c2ea1326f3c44ec630e33cbab4b428e8314a85d38756c2460831 |
| 27 | + command: ["/bin/sh", "-c"] |
| 28 | + args: |
| 29 | + - | |
| 30 | + echo "=== DEBUG: Checking /sealed mount ===" |
| 31 | + ls -laR /sealed || echo "/sealed does not exist" |
| 32 | + echo "=== DEBUG: Content of cert.pem (first 200 bytes) ===" |
| 33 | + head -c 200 /sealed/cert.pem 2>&1 || echo "Cannot read cert.pem" |
| 34 | + echo "=== DEBUG: Testing network connectivity to KBS (cluster-internal) ===" |
| 35 | + curl -k -I https://kbs-service.trustee-operator-system.svc.cluster.local:8080 2>&1 | head -20 |
| 36 | + echo "=== DEBUG: Testing network connectivity to KBS (public route) ===" |
| 37 | + curl -k -I https://kbs.apps.bleal-vp.azure.sandboxedcontainers.com 2>&1 | head -20 |
| 38 | + echo "=== DEBUG: Testing if CDH is running (HTTP on localhost:8006) ===" |
| 39 | + curl -v http://127.0.0.1:8006/cdh/resource/default/spire-cert-qtodo/cert 2>&1 | head -50 |
| 40 | + echo "=== DEBUG: Starting spire-agent ===" |
| 41 | + /spire-agent run -config /opt/spire/conf/agent/agent.conf |
| 42 | + env: |
| 43 | + - name: PATH |
| 44 | + value: "/opt/spire/bin:/bin" |
| 45 | + - name: MY_NODE_NAME |
| 46 | + value: "coco-vm-node" # Virtual node name for CoCo |
| 47 | + ports: |
| 48 | + - containerPort: 9982 |
| 49 | + name: healthz |
| 50 | + protocol: TCP |
| 51 | + livenessProbe: |
| 52 | + httpGet: |
| 53 | + path: /live |
| 54 | + port: healthz |
| 55 | + scheme: HTTP |
| 56 | + initialDelaySeconds: 15 |
| 57 | + periodSeconds: 60 |
| 58 | + readinessProbe: |
| 59 | + httpGet: |
| 60 | + path: /ready |
| 61 | + port: healthz |
| 62 | + scheme: HTTP |
| 63 | + initialDelaySeconds: 10 |
| 64 | + periodSeconds: 30 |
| 65 | + volumeMounts: |
| 66 | + - name: spire-config |
| 67 | + mountPath: /opt/spire/conf/agent |
| 68 | + readOnly: true |
| 69 | + - name: spire-bundle |
| 70 | + mountPath: /run/spire/bundle |
| 71 | + readOnly: true |
| 72 | + - name: spire-socket |
| 73 | + mountPath: /tmp/spire-agent/public |
| 74 | + - name: spire-persistence |
| 75 | + mountPath: /var/lib/spire |
| 76 | + - name: sealed-creds |
| 77 | + mountPath: /sealed |
| 78 | + readOnly: true |
| 79 | + securityContext: |
| 80 | + readOnlyRootFilesystem: true |
| 81 | + allowPrivilegeEscalation: false |
| 82 | + capabilities: |
| 83 | + drop: |
| 84 | + - ALL |
| 85 | + seccompProfile: |
| 86 | + type: RuntimeDefault |
| 87 | + |
| 88 | + # SPIFFE Helper Sidecar |
| 89 | + - name: spiffe-helper |
| 90 | + image: ghcr.io/spiffe/spiffe-helper:0.10.1 |
| 91 | + imagePullPolicy: IfNotPresent |
| 92 | + args: |
| 93 | + - "-config" |
| 94 | + - "/etc/helper.conf" |
| 95 | + volumeMounts: |
| 96 | + - name: spiffe-helper-config |
| 97 | + readOnly: true |
| 98 | + mountPath: /etc/helper.conf |
| 99 | + subPath: helper.conf |
| 100 | + - name: spire-socket |
| 101 | + readOnly: true |
| 102 | + mountPath: /tmp/spire-agent/public |
| 103 | + - name: svids |
| 104 | + mountPath: /svids |
| 105 | + securityContext: |
| 106 | + allowPrivilegeEscalation: false |
| 107 | + capabilities: |
| 108 | + drop: |
| 109 | + - ALL |
| 110 | + readOnlyRootFilesystem: false |
| 111 | + seccompProfile: |
| 112 | + type: RuntimeDefault |
| 113 | + |
| 114 | + # Test Workload Container |
| 115 | + - name: test-workload |
| 116 | + image: registry.redhat.io/ubi9/ubi-minimal:latest |
| 117 | + command: ["/bin/sh", "-c"] |
| 118 | + args: |
| 119 | + - | |
| 120 | + echo "=== SPIRE Agent CoCo Test Started ===" |
| 121 | + echo "Waiting for SPIFFE certificates..." |
| 122 | +
|
| 123 | + # Wait for SPIFFE certificates |
| 124 | + while [ ! -f /svids/svid.pem ]; do |
| 125 | + echo "Waiting for SPIFFE certificates..." |
| 126 | + sleep 2 |
| 127 | + done |
| 128 | +
|
| 129 | + echo "SPIFFE certificates found!" |
| 130 | + ls -la /svids/ |
| 131 | +
|
| 132 | + echo "=== Testing SPIFFE X.509 certificates ===" |
| 133 | + echo "Certificate details:" |
| 134 | + openssl x509 -in /svids/svid.pem -text -noout | head -20 |
| 135 | +
|
| 136 | + echo "=== Sleeping for manual inspection ===" |
| 137 | + sleep 3600 |
| 138 | + volumeMounts: |
| 139 | + - name: svids |
| 140 | + mountPath: /svids |
| 141 | + readOnly: true |
| 142 | + securityContext: |
| 143 | + allowPrivilegeEscalation: false |
| 144 | + capabilities: |
| 145 | + drop: |
| 146 | + - ALL |
| 147 | + readOnlyRootFilesystem: false |
| 148 | + seccompProfile: |
| 149 | + type: RuntimeDefault |
| 150 | + |
| 151 | + volumes: |
| 152 | + - name: spire-config |
| 153 | + configMap: |
| 154 | + name: spire-agent-coco |
| 155 | + - name: spiffe-helper-config |
| 156 | + configMap: |
| 157 | + name: spiffe-helper-config |
| 158 | + - name: spire-bundle |
| 159 | + configMap: |
| 160 | + name: spire-bundle |
| 161 | + - name: spire-socket |
| 162 | + emptyDir: {} |
| 163 | + - name: spire-persistence |
| 164 | + emptyDir: {} |
| 165 | + - name: sealed-creds |
| 166 | + secret: |
| 167 | + secretName: {{ .Values.sealedSecret.name }} |
| 168 | + - name: svids |
| 169 | + emptyDir: {} |
0 commit comments