Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add demo for workload secrets #1045

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

davidweisse
Copy link
Contributor

This adds a demo application running a MySQL server with an encrypted volume mount, similar to the volume-tester. For this, the cryptsetup init container uses the workload secret to set up a LUKS partition that is mounted to /var/lib/mysql. The demo is also provided as a release artifact as mysql-demo.yml.

@davidweisse davidweisse added the documentation Improvements for user docs label Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://edgelesssys.github.io/contrast/pr-preview/pr-1045/
on branch gh-pages at 2024-12-02 13:34 UTC

Copy link
Contributor

@burgerdev burgerdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

:::note[Runtime class and Initializer]

The deployment YAML shipped for this demo is already configured to be used with Contrast.
A [runtime class](https://docs.edgeless.systems/contrast/components/runtime) `contrast-cc-<platform>-<runtime-hash>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: only during generate is contrast-cc expanded to contrast-cc-<platform>-<hash>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be patched for the Emojivoto docs.

A [runtime class](https://docs.edgeless.systems/contrast/components/runtime) `contrast-cc-<platform>-<runtime-hash>`
was added to the pods to signal they should be run as Confidential Containers. During the generation process,
the Contrast [Initializer](../components/overview.md#the-initializer) will be added as an init container to these
workloads to facilitate the attestation and certificate pulling before the actual workload is started.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention here that it's also responsible for fetching the workload secret.

During the initialization process of the workload pod, the Contrast Initializer
sends an attestation report to the Coordinator and retrieves a randomly
generated workload secret, seeded with the workload secret ID specified in the
manifest, and writes it to a `volumeMount`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should emphasize here that this is a secure-memory-backed mount.

Comment on lines +212 to +213
Using the `mysql` command line interface, you can connect to the database as the
root user with the password specified in the deployment YAML (`password`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this setup does not sound ideal, even for a demo. Could we maybe mention the service mesh here to ensure only Contrast deployments can access the MySQL server?

deterministically generate the same key again and open the already partitioned
LUKS device.

For example, after making changes to the deployment files, the runtime policies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The advice here is not correct. If you change the deployment, you're likely to get a different policy hash, resulting in a different workload secret. This is where the WorkloadSecretID comes in, which may be, well, underdocumented right now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a disclaimer here, mentioning:

  1. Risk of data loss without backups.
  2. Workload owner vs data owner concerns.
  3. Security concerns with unauthenticated encryption, PBKDF2 defaults, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, we might want those disclaimers in the general architecture/feature description and likely only refer to them here, right?

Comment on lines +635 to +636
# cryptsetup complains if there is no /run directory.
mkdir /run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an emptyDir mount instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also already have the same(?) script in https://github.com/edgelesssys/contrast/blob/main/internal/kuberesource/sets.go#L504. We likely want to build a function returning the string (maybe add some templating if needed) and use it in both places.

# No matter if this is the first initialization derive the key (again) and open the device.
uuid=$(blkid "${device}" -s UUID -o value)
openssl kdf -keylen 32 -kdfopt digest:SHA2-256 -kdfopt key:$(cat "${workload_secret_path}") \
-kdfopt info:${uuid} -binary HKDF | base64 | tr -d '\n' > "${disk_encryption_key_path}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-kdfopt info:${uuid} -binary HKDF | base64 | tr -d '\n' > "${disk_encryption_key_path}"
-kdfopt info:${uuid} -binary HKDF | base64 -w0 > "${disk_encryption_key_path}"

-kdfopt info:${uuid} -binary HKDF | base64 | tr -d '\n' > "${disk_encryption_key_path}"
cryptsetup luksUUID "${device}"
cryptsetup open "${device}" state -d "${disk_encryption_key_path}"
mkdir -p /data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover?

WithFailureThreshold(20).
WithPeriodSeconds(5).
WithExec(applycorev1.ExecAction().
WithCommand("/bin/sh", "-c", "cat /done"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WithCommand("/bin/sh", "-c", "cat /done"),
WithCommand("/bin/test", "-f", "/done"),

... might be clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements for user docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants