Repository navigation
Add SPIFFE mTLS and an artifact server endpoint - #533
Merged
Merged
Conversation
- OpenTelemetry v1.47.0 (contrib v0.72.0) - gRPC v1.84.0 - Prometheus client_golang v1.25.0 - golang.org/x/net v0.61.0 govulncheck: no vulnerabilities found.
Each backend goroutine reassigned the handler's ctx variable, so with more than one backend the goroutines raced on it and stacked each other's client trace hooks. Use a goroutine-local context instead. Found with go test -race (TestEchoHandler_MultipleBackends).
SPIFFE mTLS on the secure port: - New flags --spiffe-endpoint-socket and --spiffe-authorized-ids. When the socket is set, the HTTPS server gets its X.509 SVID from the SPIFFE Workload API (go-spiffe v2) instead of --cert-path and requires a client SVID. Clients are authorized by ID, or by the server's trust domain when no IDs are given. - The plain HTTP server and liveness start right away. The server retries until the SVID is issued and becomes ready only once the TLS listener is up, so a missing registration never restarts the pod. - Shutdown aborts a pending SVID wait and closes the source. - Invalid IDs or a missing --secure-port fail at startup. - The request log adds spiffe_id and /headers returns X-Spiffe-Id for clients with an SVID. Artifact route: - GET/HEAD /artifact serves --artifact-path (default ./kustomize, now copied into the image) as a deterministic tar.gz with its sha256 digest in X-Artifact-Digest, so podinfo can act as a Flux artifact server. Payload logging: - /api/echo without backends logs the request body at debug level, embedding JSON bodies as objects in the log line.
- New spiffe.* values: when enabled (requires tls.enabled), the TLS port gets its SVID from the SPIFFE Workload API mounted by the SPIFFE CSI driver instead of the tls secret, and spiffe.authorizedIDs sets the allowed client IDs. Renders are unchanged when spiffe is disabled. - New Helm test, rendered only with spiffe.enabled: fetches a client SVID with spire-agent and checks that podinfo accepts it and rejects a client without one. The tls test is skipped in SPIFFE mode. - New test/e2e-spiffe.sh and kind-spiffe CI job: installs SPIRE, checks podinfo stays live but not ready until it is registered, then becomes ready without a restart, serves /artifact from the image, passes the Helm tests and rejects an SVID not in authorizedIDs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes podinfo a SPIFFE workload and a minimal Flux artifact server, so the Flux and Flux Operator SPIFFE mTLS e2e tests can replace their purpose-built test apps with a pinned podinfo release.
Changes
SPIFFE mTLS on the secure port
--spiffe-endpoint-socketand--spiffe-authorized-ids. When the socket is set, the HTTPS server gets its X.509 SVID from the SPIFFE Workload API (go-spiffe v2) instead of--cert-path, and requires a client SVID. Clients are authorized by ID, or by podinfo's trust domain when no IDs are given.--secure-portfail at startup.spiffe_id, and/headersreturnsX-Spiffe-Idfor SPIFFE clients. A client-suppliedX-Spiffe-Idheader is never echoed.GET/HEAD /artifact--artifact-path(default./kustomize, now copied into the image) as a deterministic tar.gz, with the sha256 digest inX-Artifact-Digest. Every replica and restart of an image serves the same bytes. An empty path disables the route; a missing dir returns 404.Payload logging
/api/echowithout backends logs the request body at debug level, embedding JSON bodies as objects so tests can filter withjq '.payload.reportingController'.Helm chart
spiffe.*values (requirestls.enabled): mounts the Workload API socket from the SPIFFE CSI driver instead of the tls secret. Renders are unchanged whenspiffe.enabledis false.spiffe.enabled: fetches a client SVID withspire-agentand checks that podinfo accepts it and rejects a client without one. The tls test is skipped in SPIFFE mode.Other
/echowith multiple backends (found withgo test -race, already on master)./artifact.Testing
--unready, shutdown while waiting; artifact determinism, HEAD, symlinks, missing dir; payload logging. All pass with-race.test/e2e-spiffe.shandkind-spiffeCI job on kind with SPIRE: podinfo stays live but not ready until registered, then turns ready without a restart;/artifactis served from the image; the Helm tests pass; an SVID not inauthorizedIDsis rejected. Passed locally.Note for the SPIRE Helm chart: its controller manager ignores ClusterSPIFFEIDs without
spec.className(<namespace>-<release>, e.g.spire-system-spire); the e2e and README example set it.