Skip to content

Commit eae948d

Browse files
authored
Merge pull request #246 from Jakob-Naucke/decouple-tec-pcr-compute
Remove images from TEC definition & run watchers independently of TECs
2 parents 6a095bc + 062603f commit eae948d

25 files changed

Lines changed: 623 additions & 508 deletions

.github/workflows/rust.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: "cargo build"
4747
run: cargo build --all-targets
4848
- name: "cargo test"
49-
run: cargo test --bins
49+
run: cargo test --bins --lib
5050
tests-release-stable:
5151
name: "Tests (release), stable toolchain"
5252
runs-on: "ubuntu-24.04"
@@ -70,7 +70,7 @@ jobs:
7070
- name: "cargo build (release)"
7171
run: cargo build --lib --release
7272
- name: "cargo test (release)"
73-
run: cargo test --bins --release
73+
run: cargo test --bins --lib --release
7474
tests-release-msrv:
7575
name: "Tests (release), minimum supported toolchain"
7676
runs-on: "ubuntu-24.04"
@@ -100,7 +100,7 @@ jobs:
100100
- name: "cargo build (release)"
101101
run: cargo build --lib --release
102102
- name: "cargo test (release)"
103-
run: cargo test --bins --release
103+
run: cargo test --bins --lib --release
104104
tests-other-channels:
105105
name: "Tests, unstable toolchain"
106106
runs-on: "ubuntu-24.04"
@@ -128,4 +128,4 @@ jobs:
128128
- name: "cargo build"
129129
run: cargo build --lib
130130
- name: "cargo test"
131-
run: cargo test --bins
131+
run: cargo test --bins --lib

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ COPY operator/src/lib.rs operator/src/
1818
# Set only required crates as members to minimize rebuilds upon changes.
1919
RUN sed -i 's/members = .*/members = ["lib", "operator"]/' Cargo.toml && \
2020
sed -i '/\[dev-dependencies\]/,$d' operator/Cargo.toml && \
21+
sed -i '/trusted-cluster-operator-test-utils/d' lib/Cargo.toml && \
2122
make crds-rs
2223

2324
# In debug builds, build dependencies to avoid full rebuild.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ equal-conditions:
204204
lint: fmt-check clippy vet equal-conditions
205205

206206
test: crds-rs
207-
cargo test --workspace --bins
207+
cargo test --workspace --bins --lib
208208

209209
test-release: crds-rs
210-
cargo test --workspace --bins --release
210+
cargo test --workspace --bins --lib --release
211211

212212
integration-tests: generate trusted-cluster-gen crds-rs
213213
RUST_LOG=info REGISTRY=$(REGISTRY) TAG=$(TAG) \

api/trusted-cluster-gen.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ func generateOperator(args *Args) error {
9292
Name: name,
9393
Image: args.image,
9494
Command: []string{"/usr/bin/operator"},
95+
Env: []corev1.EnvVar{
96+
{
97+
Name: "RELATED_IMAGE_TRUSTEE",
98+
Value: args.trusteeImage,
99+
},
100+
{
101+
Name: "RELATED_IMAGE_COMPUTE_PCRS",
102+
Value: args.pcrsComputeImage,
103+
},
104+
{
105+
Name: "RELATED_IMAGE_REGISTRATION_SERVER",
106+
Value: args.registerServerImage,
107+
},
108+
{
109+
Name: "RELATED_IMAGE_ATTESTATION_KEY_REGISTER",
110+
Value: args.attestationKeyRegisterImage,
111+
},
112+
},
95113
},
96114
},
97115
},
@@ -140,10 +158,6 @@ func generateTrustedExecutionClusterCR(args *Args) error {
140158
Namespace: args.namespace,
141159
},
142160
Spec: v1alpha1.TrustedExecutionClusterSpec{
143-
TrusteeImage: &args.trusteeImage,
144-
PcrsComputeImage: &args.pcrsComputeImage,
145-
RegisterServerImage: &args.registerServerImage,
146-
AttestationKeyRegisterImage: &args.attestationKeyRegisterImage,
147161
PublicAttestationKeyRegisterAddr: nil,
148162
PublicTrusteeAddr: nil,
149163
TrusteeSecret: nil,

api/v1alpha1/crds.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ var (
3535
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=trustedexecutionclusters/status;machines/status;approvedimages/status;attestationkeys/status,verbs=get;patch;update
3636

3737
// TrustedExecutionClusterSpec defines the desired state of TrustedExecutionCluster
38-
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.trusteeImage) || has(self.trusteeImage)", message="Value is required once set"
39-
// +kubebuilder:validation:XValidation:rule="has(oldSelf.trusteeImage) == has(self.trusteeImage)", message="Value must be set at creation"
40-
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.pcrsComputeImage) || has(self.pcrsComputeImage)", message="Value is required once set"
41-
// +kubebuilder:validation:XValidation:rule="has(oldSelf.pcrsComputeImage) == has(self.pcrsComputeImage)", message="Value must be set at creation"
42-
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.registerServerImage) || has(self.registerServerImage)", message="Value is required once set"
43-
// +kubebuilder:validation:XValidation:rule="has(oldSelf.registerServerImage) == has(self.registerServerImage)", message="Value must be set at creation"
44-
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.attestationKeyRegisterImage) || has(self.attestationKeyRegisterImage)", message="Value is required once set"
45-
// +kubebuilder:validation:XValidation:rule="has(oldSelf.attestationKeyRegisterImage) == has(self.attestationKeyRegisterImage)", message="Value must be set at creation"
4638
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.publicAttestationKeyRegisterAddr) || has(self.publicAttestationKeyRegisterAddr)", message="Value is required once set"
4739
// +kubebuilder:validation:XValidation:rule="has(oldSelf.publicAttestationKeyRegisterAddr) == has(self.publicAttestationKeyRegisterAddr)", message="Value must be set at creation"
4840
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.attestationKeyRegisterSecret) || has(self.attestationKeyRegisterSecret)", message="Value is required once set"
@@ -59,30 +51,6 @@ var (
5951
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.attestationKeyRegisterPort) || has(self.attestationKeyRegisterPort)", message="Value is required once set"
6052
// +kubebuilder:validation:XValidation:rule="has(oldSelf.attestationKeyRegisterPort) == has(self.attestationKeyRegisterPort)", message="Value must be set at creation"
6153
type TrustedExecutionClusterSpec struct {
62-
// Image reference to Trustee all-in-one image.
63-
// If not specified, uses RELATED_IMAGE_TRUSTEE environment variable from operator deployment.
64-
// +optional
65-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
66-
TrusteeImage *string `json:"trusteeImage,omitempty"`
67-
68-
// Image reference to trusted-cluster-operator's compute-pcrs image.
69-
// If not specified, uses RELATED_IMAGE_COMPUTE_PCRS environment variable from operator deployment.
70-
// +optional
71-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
72-
PcrsComputeImage *string `json:"pcrsComputeImage,omitempty"`
73-
74-
// Image reference to trusted-cluster-operator's register-server image.
75-
// If not specified, uses RELATED_IMAGE_REGISTRATION_SERVER environment variable from operator deployment.
76-
// +optional
77-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
78-
RegisterServerImage *string `json:"registerServerImage,omitempty"`
79-
80-
// Image reference to trusted-cluster-operator's attestation-key-register image.
81-
// If not specified, uses RELATED_IMAGE_ATTESTATION_KEY_REGISTER environment variable from operator deployment.
82-
// +optional
83-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
84-
AttestationKeyRegisterImage *string `json:"attestationKeyRegisterImage,omitempty"`
85-
8654
// Address where attester can connect to Attestation Key Register
8755
// +optional
8856
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"

attestation-key-register/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ COPY attestation-key-register/src/lib.rs attestation-key-register/src/
1515

1616
# Set only required crates as members to minimize rebuilds upon changes.
1717
RUN sed -i 's/members =.*/members = ["lib", "attestation-key-register"]/' Cargo.toml && \
18+
sed -i '/trusted-cluster-operator-test-utils/d' lib/Cargo.toml && \
1819
make crds-rs
1920

2021
# In debug builds, build dependencies to avoid full rebuild.

compute-pcrs/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ COPY compute-pcrs/src/lib.rs compute-pcrs/src/
1616

1717
# Set only required crates as members to minimize rebuilds upon changes.
1818
RUN sed -i 's/members =.*/members = ["compute-pcrs", "lib"]/' Cargo.toml && \
19+
sed -i '/trusted-cluster-operator-test-utils/d' lib/Cargo.toml && \
1920
git clone --depth 1 https://github.com/trusted-execution-clusters/reference-values && \
2021
make crds-rs
2122

docs/design/reference-values.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,16 @@ A reference value listing for Trustee could then look like this:
9393
## Data flow
9494

9595
![](../pics/rv-flow.png)
96+
97+
## Ownership
98+
99+
Unlike `reference-values`, `ApprovedImages` can live independently of a `TrustedExecutionCluster` object.
100+
They can be created without one existing, and reference values are written by jobs (that the `ApprovedImages` also own) to the `image-pcrs` ConfigMap, which is created by the operator and is also independent of `TrustedExecutionClusters`.
101+
102+
However, the `ApprovedImages` are adopted by the `TrustedExecutionCluster` object, both when created with a `TrustedExecutionCluster` existing and retroactively when created before `TrustedExecutionCluster` creation.
103+
This ensures that removal of a `TrustedExecutionCluster` acts as a complete uninstallation.
104+
Finalizers on the `ApprovedImages` ensure the PCR values are removed back out of `image-pcrs` again.
105+
106+
## Ownership flow
107+
108+
![](../pics/image-flow.png)

docs/pics/image-flow.png

126 KB
Loading

0 commit comments

Comments
 (0)