Generate policy annotations and manifest
This step updates your deployment files with policy annotations and automatically generates the deployment manifest.
Applicability
This step is required for all Contrast deployments.
Prerequisites
- Set up cluster
- Install CLI
- Deploy the Contrast runtime
- Add Coordinator to resources
- Prepare deployment files
- Configure TLS (optional)
- Enable GPU support (optional)
How-to
Run the generate
command to add the necessary components to your deployment files.
This will add the Contrast Initializer to every workload with the specified contrast-cc
runtime class
and the Contrast Service Mesh to all workloads that have a specified configuration.
After that, it will generate the execution policies and add them as annotations to your deployment files.
A manifest.json
with the reference values of your deployment will be created.
- AKS
- Bare metal (SEV-SNP)
- Bare metal (SEV-SNP, with GPU support)
- Bare metal (TDX)
contrast generate --reference-values aks-clh-snp resources/
contrast generate --reference-values k3s-qemu-snp resources/
On bare-metal SEV-SNP, contrast generate
is unable to fill in the MinimumTCB
values as they can vary between platforms and CPU models.
They will have to be filled in manually.
If you don't know the values from the firmware you installed, you can use the snphost
tool to retrieve the current TCB.
snphost show tcb
Reported TCB: TCB Version:
Microcode: 72
SNP: 23
TEE: 0
Boot Loader: 9
FMC: None
Platform TCB: TCB Version:
Microcode: 72
SNP: 23
TEE: 0
Boot Loader: 9
FMC: None
Use the values from Platform TCB
to fill in the MinimumTCB
values in the generated manifest.json
file.
This must be done on a trusted machine, with a secure and trusted connection to it.
contrast generate --reference-values k3s-qemu-snp-gpu resources/
On bare-metal SEV-SNP, contrast generate
is unable to fill in the MinimumTCB
values as they can vary between platforms and CPU models.
They will have to be filled in manually.
If you don't know the values from the firmware you installed, you can use the snphost
tool to retrieve the current TCB.
snphost show tcb
Reported TCB: TCB Version:
Microcode: 72
SNP: 23
TEE: 0
Boot Loader: 9
FMC: None
Platform TCB: TCB Version:
Microcode: 72
SNP: 23
TEE: 0
Boot Loader: 9
FMC: None
Use the values from Platform TCB
to fill in the MinimumTCB
values in the generated manifest.json
file.
This must be done on a trusted machine, with a secure and trusted connection to it.
contrast generate --reference-values k3s-qemu-tdx resources/
On bare-metal TDX, contrast generate
is unable to fill in the MinimumTeeTcbSvn
and MrSeam
TCB values as they can vary between platforms.
They will have to be filled in manually.
MrSeam
is the SHA384 hash of the TDX module. You can retrieve it by executing
sha384sum /boot/efi/EFI/TDX/TDX-SEAM.so | cut -d' ' -f1
MinimumTeeTcbSvn
is contained in the TDX-SEAM.so.sigstruct
and can be extracted via
xxd -ps -s 948 -l 8 /boot/efi/EFI/TDX/TDX-SEAM.so.sigstruct
This must be done on a trusted machine, with a secure and trusted connection to it.
The generate
command needs to pull the container images to derive policies.
Running generate
for the first time can take a while, especially if the images are large.
If your container registry requires authentication, you can create the necessary credentials with docker login
or podman login
.
Be aware of the registry authentication limitation on bare metal.
Please be aware that runtime policies currently have some blind spots. For example, they can't guarantee the starting order of containers. See the current limitations for more details.
Running contrast generate
for the first time creates some additional files in the working directory:
seedshare-owner.pem
is required for handling the secret seed and recovering the Coordinator (see Secrets & recovery).workload-owner.pem
is required for manifest updates after the initialcontrast set
.rules.rego
andsettings.json
are the basis for runtime policies.layers-cache.json
caches container image layer information for your deployments to speed up subsequent runs ofcontrast generate
.
Fine-tuning initializer injection
If you don't want the Contrast Initializer to automatically be added to your workloads, there are two ways you can skip the Initializer injection step, depending on how you want to customize your deployment.
--skip-initializer
flag
You can disable the Initializer injection completely by specifying the
--skip-initializer
flag in the generate
command.
- AKS
- Bare metal (SEV-SNP)
- Bare metal (SEV-SNP, with GPU support)
- Bare metal (TDX)
contrast generate --reference-values aks-clh-snp --skip-initializer resources/
contrast generate --reference-values k3s-qemu-snp --skip-initializer resources/
contrast generate --reference-values k3s-qemu-snp-gpu --skip-initializer resources/
contrast generate --reference-values k3s-qemu-tdx --skip-initializer resources/
skip-initializer
annotation
If you want to disable the Initializer injection for a specific workload with
the contrast-cc
runtime class, you can do so by adding an annotation to the workload.
metadata: # apps/v1.Deployment, apps/v1.DaemonSet, ...
annotations:
contrast.edgeless.systems/skip-initializer: "true"
Manual Initializer injection
When disabling the automatic Initializer injection, you can manually add the
Initializer as a sidecar container to your workload before generating the
policies. Configure the workload to use the certificates written to the
contrast-secrets
volumeMount
.
# v1.PodSpec
spec:
initContainers:
- env:
- name: COORDINATOR_HOST
value: coordinator-ready
image: "ghcr.io/edgelesssys/contrast/initializer:v1.11.0@sha256:06298428e65532dfe9bb8390149776b7e9d7edad1cdf0a0b8df37b8952993f95"
name: contrast-initializer
volumeMounts:
- mountPath: /contrast
name: contrast-secrets
volumes:
- emptyDir: {}
name: contrast-secrets
Fine-tuning service mesh injection
The service mesh is only injected for workload that have a service mesh annotation.
--skip-service-mesh
flag
You can disable the service mesh injection completely by specifying the
--skip-service-mesh
flag in the generate
command.
- AKS
- Bare metal (SEV-SNP)
- Bare metal (SEV-SNP, with GPU support)
- Bare metal (TDX)
contrast generate --reference-values aks-clh-snp --skip-service-mesh resources/
contrast generate --reference-values k3s-qemu-snp --skip-service-mesh resources/
contrast generate --reference-values k3s-qemu-snp-gpu --skip-service-mesh resources/
contrast generate --reference-values k3s-qemu-tdx --skip-service-mesh resources/
In this case, you can manually add the service mesh sidecar container to your workload before generating the policies, or authenticate peers on the application level.