Allow configuring TPM init container security context#676
Allow configuring TPM init container security context#676jmbass wants to merge 1 commit intospiffe:mainfrom
Conversation
- let the TPM init container run as root so the plugin copy succeeds on root-owned PVCs - add values to control the init container security context, chown behaviour, mount and state paths - update chart docs/version and ensure configmap uses the new helper values - helm lint charts/spire Signed-off-by: jo.perez <jo.perez@criteo.com>
3258720 to
552cddb
Compare
|
Hello. Thanks for contributing to the chart. I'm a little confused as to what is being attempted to be accomplished. I believe the tpm plugin has to be run as root to function properly. But the current design of spire requires spire itself to exec the tpm plugin, so it has to run as root too for that to happen. Am I missing something? |
|
@kfox1111 Hi! Appreciate the quick review, and happy to clarify. The SPIRE agent needs root access when it talks to /dev/tpm*, but this patch is in the server chart. The tpm_direct node-attestor plugin that the server execs never touches the TPM device; it only validates the payloads coming from the agents and keeps some state in /run/spire/data. We’ve been running spire-server (and the plugin it forks) as an arbitrary non-root UID successfully as long as the staged files are owned by that UID. The issue was the init container that copies the plugin onto the PVC. It inherited the server’s non-root UID, but the PVC surfaces as root-owned on hardened clusters, so the copy (and the directory creation) failed. The new initSecurityContext lets us run the init container as root by default just long enough to copy the binary and chown the state directory back to the pod UID/GID. If a downstream already has a writable location they can override that value and keep the init container non-root as well. The main server container—and the TPM plugin it execs—remain non-root throughout. |
|
Oh, right. ok.... Could it be that we just need to move the existing initContainer, name: chown |
|
Thanks for your response and insights. You’re right to look at the existing chown init container but I think that unfortunately it doesn’t help in the cases that fail: It’s only rendered when Even when it is present, it currently runs Most importantly, the copy step fails before any later init containers run. The TPM init container inherits the pod’s non-root UID, so |
|
we could fix up he chown to make sure all the important bits are the right permissions. I'm a little confused why the pvc would be root owned though, unless it was created initially as root, then the chart was upgraded to use a different user? That could be a problem in other configs too? This patch also makes several things configurable that are internal implementation details. Is there actually a need to configure those things? |
|
@jmbass Do you have time to follow up on the comments on this pr? |
Summary
Testing