Skip to content

Commit df6a799

Browse files
drewTaylorMutch
andauthored
feat(gateway): broker stable sandbox SPIFFE provider tokens (#4732)
* feat(gateway): broker stable sandbox SPIFFE provider tokens Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(gateway): rename SPIFFE delegation configuration Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(provider): reuse broker channels and attribute grant failures Signed-off-by: Drew Newberry <anewberry@nvidia.com> * test(provider): satisfy broker logging lint checks Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(provider): harden broker caching and deployment prerequisites Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(identity): extract SPIRE sandbox identity adapter Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(identity): move shared SPIFFE types out of core Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(supervisor): follow the sandbox reconciler leader (#4853) * chore(sdk): drop regenerated frozen Go bindings Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(spiffe): verify provider tokens across supervisor failover Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * feat(crypto): verify TLS peers by SPIFFE identity Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * feat(spiffe): use Broker API for sandbox identity issuance Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(spiffe): verify broker authorization and credential rotation Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * docs(spiffe): clean up broker troubleshooting and test wording Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * feat(spiffe): authorize Broker agents across Kubernetes nodes Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(spiffe): send canonical credential keys to the gateway Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * perf(providers): resolve only the requested token grant profile Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(providers): bound broker admission and refresh expired cache hits Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * chore(server): remove unused protobuf codec dependency Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(spiffe): classify identity failures without retrying configuration errors Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(spiffe): unify gateway identity configuration and document shared grants Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(providers): verify targeted snapshot freshness and cache reuse Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(spiffe): support remote fixtures and remove CSI consumers before teardown Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(providers): validate uncached sources before selecting a grant Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(spiffe): validate agent replacement and remote supervisor failover Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * feat(spiffe): connect the gateway to its node-local Broker agent Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(spiffe): validate node-local Broker routing across gateway relocation Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(ci): satisfy certificate test lint and refresh merged lockfile Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(crypto): initialize OpenSSL for SPIFFE certificate verification Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * chore(spiffe): remove prototype tooling and stale guidance Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(providers): share acquisition failures with waiting requests Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * fix(core): initialize provider-token channels without eager connects Signed-off-by: Taylor Mutch <taylormutch@gmail.com> --------- Signed-off-by: Drew Newberry <anewberry@nvidia.com> Signed-off-by: Taylor Mutch <taylormutch@gmail.com> Co-authored-by: Taylor Mutch <taylormutch@gmail.com>
1 parent 78ba347 commit df6a799

90 files changed

Lines changed: 6589 additions & 569 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,53 @@ OPENSHELL_E2E_KUBE_IMAGE_PULL_SECRET=e2e-regcred \
107107
mise run e2e:kubernetes:shared-supervisor
108108
```
109109

110+
`mise run e2e:kubernetes:shared-supervisor-spiffe` installs pinned SPIRE charts
111+
(`ci/values-spire-broker-stack.yaml`) and the `openshell.gateway.spiffe_broker`
112+
overlay (`ci/values-supervisor-spiffe.yaml`). It exercises provider exchange and
113+
abrupt supervisor takeover over TLS, using Sandbox CR UID registrations and
114+
enforced Kubernetes authorization. Workload generation, Pod, process, and stable
115+
SPIFFE identity survive; the new owner acquires a fresh provider token and the
116+
broker rejects the old bearer. The fixture's 30-second workload X.509-SVIDs
117+
exercise acquisition after credential rotation. The gateway Pod must pass
118+
Restricted Pod Security admission. The task owns its SPIRE install and cluster.
119+
120+
The task creates three nodes (`HELM_K3S_AGENT_COUNT=2` adds two k3d agents) and
121+
requires three SPIRE agents. Its cluster-scoped `server_spiffe_id_prefix` accepts
122+
the concrete node identities, and a node alias distributes Sandbox registrations
123+
to all eligible agents. The test selects each Broker backend in turn and forces
124+
a new generation's acquisition, then replaces one agent and checks acquisition
125+
without re-registering the sandbox. Exact-ID mode remains available for a fixed
126+
endpoint. The installed SPIRE version and operator must expose the experimental
127+
Broker API.
128+
129+
For remote clusters, set `OPENSHELL_E2E_HOST_GATEWAY_IP` to a host reachable
130+
from Pods. Optional `OPENSHELL_E2E_SPIFFE_STS_PORT` and
131+
`OPENSHELL_E2E_SPIFFE_TARGET_PORT` fix the test's host listener ports so an
132+
operator can forward them through a reverse tunnel. Keep the tunnel available
133+
through the test and remove it afterward. Use an explicit kubeconfig and context
134+
to avoid repository environment defaults targeting a local cluster.
135+
`OPENSHELL_E2E_SPIFFE_DRIVER_CONFIG_JSON` can pass a driver override to test
136+
sandbox creation, such as a node selector for a Landlock-capable pool. Enable
137+
`allow_driver_config` in the test gateway when using this override. GKE COS
138+
nodes may lack Landlock; use compatible Ubuntu nodes for sandbox workloads.
139+
For remote abrupt-failover coverage, set
140+
`OPENSHELL_E2E_SUPERVISOR_PROCESS_CONTROL=1`. Before creating sandboxes, the test
141+
adds an unprivileged process-control sidecar and enables the supervisor Pod's
142+
shared process namespace. The sidecar sends SIGKILL to the supervisor as the
143+
same UID; it needs no host PID namespace, capabilities, or runtime socket.
144+
The default k3d/kind test continues to kill through the node container runtime.
145+
110146
### Shared supervisor high availability
111147

148+
`mise run e2e:kubernetes:shared-supervisor-spiffe-node-local` validates direct
149+
node-local Broker TCP routing. The chart injects `OPENSHELL_NODE_IP` from
150+
`status.hostIP` for `spiffe_broker.node_local_port`; it creates no Broker Service.
151+
The task uses an external PostgreSQL fixture and a gateway Deployment, moves
152+
the gateway across the SPIRE nodes, restricts Broker egress to its current node,
153+
and forces fresh token acquisition on each node and after local agent replacement.
154+
The shared-supervisor failover, credential rotation, and identity fencing checks
155+
also run. Keep gateway/supervisor/sandbox images from the same branch.
156+
112157
The shared supervisor is always a pool of `supervisor.replicas` members
113158
(default 1), or an HPA-managed pool when `supervisor.autoscaling.enabled=true`.
114159
`ci/values-supervisor-autoscaling.yaml` enables the memory HPA (default `512Mi`

‎.config/nextest.toml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test-group = "kubernetes-ha"
3232
# they kill members or gateways, or scale the pool. Never run them at once.
3333
# Test names, not binary(), for the reason above.
3434
[[profile.e2e-kubernetes.overrides]]
35-
filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|supervisors_spread_evenly_across_gateways)$/)"
35+
filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity|supervisors_spread_evenly_across_gateways)$/)"
3636
test-group = "kubernetes-shared-supervisor-pool"
3737

3838
# Scaling the pool runs two bounded Helm upgrades (up to 6 minutes each), waits
@@ -47,6 +47,12 @@ slow-timeout = { period = "60s", terminate-after = 20 }
4747
filter = "test(/^pool_sessions_follow_their_supervisors_gateway$/)"
4848
slow-timeout = { period = "60s", terminate-after = 20 }
4949

50+
[[profile.e2e-kubernetes.overrides]]
51+
filter = "test(/^shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity$/)"
52+
# Fresh acquisitions through every node and a replacement agent precede
53+
# supervisor failover and credential rotation.
54+
slow-timeout = { period = "60s", terminate-after = 15 }
55+
5056
# One bounded rollout per supervisor and one for the gateway, each followed by
5157
# a settle round.
5258
[[profile.e2e-kubernetes.overrides]]

‎AGENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Do not rely on this file for a full inventory. The detailed public and contribut
4444
| `crates/openshell-gateway/` | Gateway binary composition | Links selected first-party compute drivers into the backend-agnostic server registry |
4545
| `crates/openshell-sdk/` | Shared client SDK | Async Rust gateway client (gRPC transport, TLS, OIDC refresh, edge tunnel); consumed by CLI, TUI, and `@openshell/sdk` |
4646
| `crates/openshell-providers/` | Provider management | Credential provider backends |
47+
| `crates/openshell-spiffe/` | SPIFFE identity types | Dependency-light SPIFFE ID mapping, claim parsing, and the sandbox identity provider interface |
48+
| `crates/openshell-spire/` | SPIRE adapter | Gateway-owned SPIFFE Broker API client that issues and verifies stable sandbox JWT-SVIDs |
4749
| `crates/openshell-tui/` | Terminal UI | Ratatui-based dashboard for monitoring |
4850
| `crates/openshell-driver-kubernetes-secrets/` | Kubernetes Secrets credential driver | In-process `CredentialDriver` backend for OpenShell-managed K8s Secret storage |
4951
| `crates/openshell-driver-vault/` | Vault credential driver | In-process `CredentialDriver` backend for Vault-compatible KV storage |

‎Cargo.lock‎

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

‎crates/openshell-cli/tests/ensure_providers_integration.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ impl TestOpenShell {
8080

8181
#[tonic::async_trait]
8282
impl OpenShell for TestOpenShell {
83+
async fn get_sandbox_provider_access_token(
84+
&self,
85+
_request: tonic::Request<openshell_core::proto::GetSandboxProviderAccessTokenRequest>,
86+
) -> Result<Response<openshell_core::proto::GetSandboxProviderAccessTokenResponse>, Status>
87+
{
88+
Err(Status::unimplemented("not used by this test server"))
89+
}
90+
8391
async fn peer_notify_config_update(
8492
&self,
8593
_request: tonic::Request<openshell_core::proto::PeerNotifyConfigUpdateRequest>,

0 commit comments

Comments
 (0)