Repository navigation
feat(k8s): implement the external network enforcer and native-network mode (RFC 0029) - #6170
Gal-Zaidman wants to merge 26 commits into
Conversation
Record the per-node model as the next one after the per-gateway model. Each shared supervisor proves its Pod with a pod-bound token, a per-node supervisor can claim only its own node's member ID, and a per-node sandbox never falls back to a supervisor on another node. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
All shared supervisor Pods present the same gateway-minted supervisor token, so anyone holding a copy of the token Secret could attach as a supervisor. The gateway now accepts the supervisor token only beside a projected ServiceAccount token (audience openshell-supervisor) that TokenReview and a live-Pod check resolve to a Pod of shared_supervisor.service_account_name. - shared_supervisor.service_account_name is required; the driver registers it with the controller, and the gateway refuses to start the topology without it. - The supervisor sends the token from --identity-token-file in the x-openshell-host-identity-token header, re-read on every attempt. - Helm renders the supervisor ServiceAccount without RBAC, runs the supervisor as it, and mounts a 10-minute projected token. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Accept supervisor_topology = "node". The gateway records the node that a supervisor's pod identity token proves on HostIdentity, and in the node topology the driver binds pool members to nodes, so the gateway refuses host streams whose pool member ID is not that node. Launches stay refused until node-local placement lands. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Carry the pool member through SharedSupervision::launch, PlacementRequest, the stored assignment record, and recovery, and restrict launch, takeover, and unowned placement of a pinned instance to that member. With members bound to nodes, the pool never places an unpinned instance: one launched under the gateway topology stays where it is until the recovery timeout ends it. In the node topology the Kubernetes driver ungates the workload Pod, waits for the scheduler to bind it, launches on that node's supervisor, records the member on the Sandbox resource for recovery, and creates the bootstrap Secret last. Supervisors started with --node-supervisor (OPENSHELL_SUPERVISOR_NODE) no longer leave the pool on shutdown, and a suspended generation forgets its member. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
With supervisor_topology = "node", the chart renders the supervisor as a DaemonSet on every node, started with --node-supervisor and with the node name as each Pod's pool member ID. The Service keeps runtimes on their own node with internalTrafficPolicy: Local, and the node topology renders no PodDisruptionBudget or HPA. supervisor.tolerations and supervisor.nodeSelector place supervisors on tainted or selected sandbox nodes, such as GPU nodes. Adds the e2e:kubernetes:shared-supervisor-node task on a two-node k3d cluster, and documents the topology, its platform preconditions, and that switching topologies ends running shared sandboxes. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
With supervisor_topology = "node", create and restart now return after the driver removes the scheduling gate. The bootstrap launches on the node once the scheduler binds the workload Pod, and a failed launch or a Pod that isn't scheduled within runtime_bootstrap_grace_seconds is logged and rolls the bootstrap back like any stale bootstrap. A shared supervisor now marks its boundary as stopping on every requested stop, so stopping a workload that is already gone no longer waits for a reconnect to time out and stall later instance removals. Update the Kubernetes HA docs, the driver README, and the debug-openshell-cluster skill to match. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
The gateway no longer refuses [openshell.supervisor.network] additional_ca_bundle with the shared supervisor topology. The Kubernetes driver carries the normalized PEM in each generation's launch material, and the shared host writes it to the instance's private directory for the network supervisor to append. With a shared topology the gateway refuses at startup a bundle that, with the supervisor OTLP TLS files, exceeds 192 KiB, leaving 64 KiB for the rest of the launch material. Older supervisors refuse launch material carrying the bundle, so upgrade supervisors before configuring it. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
RFC 0029 lets an external enforcer enforce a native-network sandbox's network policy and inject its credentials. It connects to the gateway as a supervisor host in an enforcer role, reads configuration and provider environment through the supervisor RPCs, and acknowledges with ReportSandboxConfiguration. The gateway holds a generation's agent until the enforcer accepts it, holds credential rotations until the enforcer has them, and makes a policy revision current once both sides apply it. The Kubernetes driver selects the mode with an external_enforcer table, and RFC 0012 admits it as the one exception to egress mediation. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
[openshell.drivers.kubernetes.external_enforcer] declares an external enforcer that enforces network policy outside the Pod. Its presence launches every new sandbox in native-network mode: the driver writes the resource claim openshell.native_network = "true" into the boundary config and runtime descriptor, on the shared supervisor path only. network.sandbox names a Multus network attachment that replaces every new workload Pod's cluster network, an optional extended resource that the driver requests once on the agent container, overriding caller values, and the sandboxes' one to three distinct nameservers. A resource in the kubernetes.io domain is refused. Resource admission accepts the configured resource next to nvidia.com/gpu at create and when reconcile re-admits stored specs. Validation requires supervisor_topology = "node" and refuses a Multus annotation domain in allowed_pod_annotations. Without the table, Pods are unchanged. The gateway learns the mode and the resolvers through the new ComputeDriverFactory::native_network hook, stores them on the compute runtime, and refuses config_delivery_mode = "push" with the mode. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Add external_enforcer.network.supervisor to the Kubernetes driver. With it set, each new sandbox dials its node supervisor's address on that Multus network instead of the supervisor Service ClusterIP. After the scheduler binds the workload Pod, the driver lists the Pods the supervisor Service selects on that node and reads the address of the named attachment from their network-status. The launch fails when the node has no Ready supervisor or no single agreed IPv4 address; unroutable addresses in network-status are ignored. The setting refuses the supervisor app listener, whose endpoints require the advertised runtime address to be the Pod IP. The supervisor gains --pool-advertise-interface, which advertises the only non-link-local IPv4 address of an interface in place of --pool-advertise-ip. Helm renders externalEnforcer into the driver's external_enforcer table and refuses a hand-written one. externalEnforcer.network.supervisor also reaches the node supervisor DaemonSet: the net1 network annotation, the device resource and the advertise interface. The gateway's peer Role gains list on Pods in the supervisor namespace only when the supervisor network is set. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
…ost token The gateway mints an enforcer token from the supervisor token's authority under its own type and subject, maps it to a supervisor principal in the enforcer role, and admits it only to the assignment stream and the sandbox configuration methods. external_enforcer gains namespace and token_secret_name. The enforcer runs in its own namespace, distinct from the supervisor's, and the Kubernetes driver delivers the enforcer token to the token Secret there. Helm creates that Secret in externalEnforcer.namespace with a Role that lets the gateway update it. Host identity becomes per role: each role's host token is accepted only beside a pod-bound token for that role's ServiceAccount, with the role's own audience, and a role without a registered account has every token refused. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
…st stream An enforcer attaches with the enforcer token, a pod-bound identity token for external_enforcer.service_account_name, and the configured sandbox nameservers. Its sessions are kept apart from pool members and are sent the pool's whole desired set by sandbox and generation, once a view was listed after the stream attached. external_enforcer gains service_account_name, the enforcer's ServiceAccount in its namespace. Helm renders it from externalEnforcer.serviceAccountName and lets the gateway get the enforcer's Pods there. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
An enforcer replica may declare HostStatus.enforced_shards, a shard count and shard IDs. The gateway then sends it only the instances on nodes of those shards, where a node's shard is the FNV-1a 32-bit hash of its name modulo the count, and resends that replica a whole snapshot when its declaration changes. Declared IDs may come in any order and repeat. A replica that declares nothing receives every instance, as before. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Both built-in descriptor decoders, the dedicated one and the routed one for shared instances, read the openshell.native_network resource claim into LaunchIdentity.native_network, exposed as SelectedBackend::native_network(). The supervisor and the sandbox decide the mode with the same helper, native_network_claimed. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
… on the native-network enforcer In native-network mode the enforcer becomes a second party to each sandbox's configuration. It selects a sandbox with the new GetSandboxConfigRequest sandbox_id, which other callers must leave empty and which the enforcer can't combine with a name or workspace scope, and reads the configuration without the activation hold, with the runtime generation as its instance ID. Its ACCEPTED or REJECTED report is stored as SandboxStatus.enforcer_admission. A report for another generation is refused, a report on a configuration that changed or that the gateway no longer admits returns Aborted, and a rejection of a configuration the enforcer already accepted is ignored. A restart that claims a new generation resets the supervisor's admission, and an enforcer admission for an older generation no longer counts. The Kubernetes driver publishes the gateway's runtime generation on the sandbox resource so the enforcer can match workload Pods to it. Until the supervisor first accepts a configuration, its snapshot is not admitted and sets activation_pending while the enforcer hasn't accepted the current generation; the supervisor waits without reporting and logs the hold as an OCSF event. Readiness reports EnforcerPending during the hold and EnforcerRejected, with a False DesiredConfigurationReady condition, while the enforcer refuses the configuration; a provisioning deadline that expires on a rejection keeps its reason. A policy revision becomes current only once both sides accept it, and policy status reports a revision only the supervisor loaded as PENDING. An enforcer rejection names the revision by version and marks it failed without overwriting a supervisor failure; a later acceptance returns it to the status the supervisor's result gives it. The CLI policy wait explains when only the enforcer is outstanding, and the TUI shows the rejection. The enforcer substitutes static credentials for the placeholders the workload holds, so its GetSandboxProviderEnvironment read carries each static credential's workload placeholder, computed with the new openshell_core::secrets::workload_placeholder helper the supervisor's resolver also uses. A polling native-network supervisor installs a rotated provider revision only once it equals the snapshot's enforcer_provider_env_revision. The enforcer runs the middleware chain, so native-network snapshots carry no supervisor middleware services and built-in openshell/ middleware is rejected. The enforcer must request the provider environment with both placeholder capabilities. A supervisor that echoes an enforcer rejection keeps the EnforcerRejected reason. The Kubernetes driver marks each Sandbox with the mode it was created in and suspends, and refuses to restart, a sandbox created under the other mode. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Native-network mode no longer requires supervisor_topology=node. In the gateway topology the driver launches a native-network sandbox once its workload Pod is scheduled and records the node with the pool instance and in the Sandbox's openshell.ai/sandbox-runtime-node annotation, so enforcer shards select it. Records written before the node fall back to their pinned member, which is the node in the node topology. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
…ndboxes With LaunchIdentity.native_network, startup starts neither the egress proxy nor policy DNS and skips the agent trace relay: the external enforcer filters the workload's connections and answers its DNS. The supervisor still writes the workload's trust files and never reads the image's policy. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
A sandbox whose descriptor carries the openshell.native_network claim runs in the native-network mode for its life. An external enforcer filters the workload's connections, so the workload listener notifies only signals and opens and the broker creates no INET sockets. The DNS relay is unchanged: it serves only registered sockets, so it serves nothing in this mode. The sandbox emits one ConfigStateChange event when the mode is enabled. Node and Deno trust the combined CA bundle, so they accept the operator's additional CA, which holds the enforcer's CA when it terminates TLS. The gateway configuration docs describe the mode, what agents see in it, and the guarantees the deployment must provide. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
A native-network workload's sockets reach the routed runtime listener directly, so one sandbox could hold every shared handshake permit and lock the other sandboxes out of their supervisor. Each canonicalized source IP now gets one handshake outside the shared bound of 64, for up to 1024 sources. The external enforcer pins each Pod's source address, so a sandbox can't take other sources' slots. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
The workload Pod's dnsConfig of every native-network sandbox names the sandbox network's nameservers instead of the supervisor's policy DNS, and the launch posture check holds the Pod to them, so the enforcer answers and filters the workload's DNS. A restart applies the current list. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
… sandboxes In native-network mode a sandbox created without a policy gets the restrictive default policy stored on the gateway. The external enforcer programs the network from the stored policy, so the image's /etc/openshell/policy.yaml is ignored in this mode. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
…odes In native-network mode the Kubernetes driver adds node-restriction.kubernetes.io/openshell-external-enforcer-ready: "true" to every workload Pod's nodeSelector, overriding a caller's value for that key, and Helm gives the node supervisor DaemonSet the same selector. The enforcer must keep that label on exactly the nodes where it enforces, so a sandbox never lands on a node it doesn't cover. Pods stay Pending while no node carries the label. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
A gateway built without the experimental feature bundle refuses to start with the Kubernetes driver's external_enforcer configured, so stable builds never run sandboxes in native-network mode. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
…e credentials past a rejected policy The enforcer reads and reports only for sandboxes created in native-network mode that have a runtime generation, never a stock sandbox left from before the mode was enabled. While the enforcer holds back a policy update, it may accept the current provider revision under the policy it already enforces. The supervisor then installs the rotated credentials, and the rejected update stays reported. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
…isode Draining the free slots to half the cap re-arms the warning, so a listener that is exhausted again later warns again. Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
|
Medium / P2 — Require an exact supervisor load result before advancing the policy version Taking the minimum of these version numbers can make a For example, start with v1 current. The enforcer accepts v2, then v3 is The gateway then reports v2 as current and resets endpoint status using Please require a successful supervisor load result for the exact revision crates/openshell-server/src/grpc/policy.rs, lines 5599–5601. |
|
Medium / P2 — Wait for enforcer acceptance of the provider revision during startup Any accepted enforcer admission for the runtime generation If the enforcer accepts provider revision R1 and credentials rotate to R2 For credentials with revision-dependent placeholders, the agent can Please apply the provider-revision acceptance gate during startup as well crates/openshell-server/src/grpc/policy/enforcer.rs, lines 178–180. |
Summary
Draft PR to triage the implementation of RFC 0029: an external network enforcer that enforces a sandbox's network policy and injects its credentials, and the Kubernetes native-network mode that gives it the agent's traffic. It is open to show the work to maintainers and is not ready for review; it depends on three open PRs and will be rebased after they land.
Related Issue
Closes #6122
Depends on:
Commit Range
The branch carries its dependencies, so GitHub shows 26 commits. Only the last 18 belong to this PR:
a2243ab07..633b7883e(6)09fe9d415(1)51b3a8218(1)0f661b192..081896ea1(18)To review only this PR's changes, compare
51b3a8218...081896ea1.Changes
[openshell.drivers.kubernetes.external_enforcer]table selects native-network mode for every new sandbox. It requires thegatewayornodesupervisor topology,config_delivery_mode = "poll", and a gateway built with theexperimentalfeature.SupervisorHoststream, receives snapshots filtered by the node shards it declares, and can read and acknowledge sandbox configuration only.EnforcerPendingandEnforcerRejected). A policy revision is current only once both the supervisor and the enforcer apply it. The supervisor doesn't install a credential revision the enforcer hasn't accepted, and the enforcer can accept a credential rotation while it rejects a policy update.openshell.native_networkclaim, the sandbox runtime leaves the agent's sockets to the kernel, and the supervisor starts neither the egress proxy nor policy DNS. Workload DNS points at the configured resolvers.node-restriction.kubernetes.io/openshell-external-enforcer-ready=true. The supervisor and sandbox Multus networks are configured under theexternal_enforcertable.policy.yamlis ignored. Built-inopenshell/middleware is refused in this mode.externalEnforcervalues, the enforcer token Secret and Role, and node-topology wiring, with Helm unit tests.proto/README.md, and thedebug-openshell-clusterskill.Testing
Not yet verified on this branch as a whole; it will be once its dependencies land and it is rebased.
Checklist