Skip to content

feat(openshell-provider): connect to managed Kubernetes gateways - #13264

Merged
cv merged 2 commits into
v1from
feat/kubernetes-gateway-connections
Oct 15, 2026
Merged

cv merged 2 commits into
v1from
feat/kubernetes-gateway-connections

Conversation

@cv

@cv cv commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Part of #13254. Part of #13131.

Failure

OpenTofu can't reach a managed Kubernetes gateway on its own. The SDK opens a port-forward on the authored loopback port, writes the client certificate and a signed development token, and hands their variable names to OpenTofu. Only then do the openshell and fabric providers connect. A deployment therefore needs two OpenTofu runs with SDK work in between, which blocks compiling one root (#13254). Two providers also can't open their own forwards on one fixed port.

Decision

Providers connect to managed Kubernetes gateways themselves, the way OpenTofu's Kubernetes and Helm providers connect from a kubeconfig.

  • Gateway ref: the gateway ref gains kubernetes, the gateway's specification as JSON. It holds variable names, never secret values. data.openshell_gateway takes it as an input, and a managed Kubernetes deployment passes it instead of the four NEMOCLAW_MANAGED_K8S_* variable names.
  • Opening the forward: GatewayClient opens one port-forward per gateway on first use and keeps it for the provider process's lifetime. It uses Operations::from_environment with the kubeconfig the specification names and the state directory the SDK already passes (NEMOCLAW_KUBERNETES_STATE), so it reads the same client certificate and signs the same development token as before. Those values reach the client from memory, never the environment.
  • Free ports: Operations::connect binds a free loopback port, so the openshell and fabric processes don't collide. The gateway certificate names 127.0.0.1, not a port.
  • Fabric provider: fabric-provider enables a new kubernetes feature of openshell-provider (on by default), without the installers.
  • SDK: it no longer opens a connection for plan, apply, export, or teardown. connected(), the operation environment, and kubernetes::connection are removed.
  • Tests: in kubernetes_interruption, operations now stop at the OpenShell stage's plan rather than at the SDK's connection. Four tests whose premise was the SDK's own connection are removed: a failed connection keeping its error class (three tests), and cancelling while that connection waits.

Literal gateway objects: they need the new attribute. Hand-written HCL that writes the gateway ref as a literal object must add kubernetes = "", because OpenTofu requires every attribute of an object type. No example or document writes one; the contract tests are updated.

Follow-up: the configuration still requires an explicit port in a Kubernetes gateway.endpoint, although it's no longer bound. Relaxing that is a schema change, left for later.

Validation

  • cargo ci passes locally (1539 unit tests, 144 lifecycle tests).
  • cargo ci live-kind passes all five live tests on a fresh kind cluster. They include the SDK deploying a gateway and sandbox, so the providers' own forwards reached a real gateway.
  • New tests:
    • connect uses a free port even when the authored one is taken;
    • a Kubernetes ref opens one forward per gateway, reused across rows and planning;
    • a forward's credentials resolve from memory, not inherited variables;
    • an unknown kubernetes value waits for apply;
    • the compiled gateway data source carries exactly gateway_spec and no variable names.
    • The new provider tests are unit tests: the fake Kubernetes API has no port-forwarding, so the live kind run covers the real forward.

cv added 2 commits October 15, 2026 05:37
The SDK opened a port-forward to a managed Kubernetes gateway and handed
OpenTofu the variables naming its token and client certificate, so a
deployment needed SDK work between two OpenTofu runs. The gateway ref now
carries the gateway's specification, and the openshell and fabric
providers each open their own forward on a free loopback port, reading
the same certificate and signing the same token from the state directory
the SDK passes. The SDK no longer connects for plan, apply, export, or
teardown.
The Kubernetes gateway endpoint's description changed with the
provider-managed connection, but only its generated reference page was
committed.
@cv
cv enabled auto-merge (squash) October 15, 2026 12:55
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 8a6772f into v1 Oct 15, 2026
@cv
cv deleted the feat/kubernetes-gateway-connections branch October 15, 2026 13:15
@wscurran wscurran added area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening feature PR adds or expands user-visible functionality platform: k8s Affects Kubernetes deployments labels Oct 15, 2026
cv added a commit that referenced this pull request Oct 15, 2026
…fu root (#13286)

Part of #13254. Builds on #13264, #13265, #13282 and #13283, all merged.

## Failure

The SDK ran each deployment as two OpenTofu roots: a runtime stage
(managed gateway, model servers, storage) and an OpenShell stage
(workspace, inference, sandboxes, Fabric agents). Each had its own
state, plan, apply, destroy, export and recovery markers. Every
operation ran OpenTofu twice, with stage-specific deferrals, markers and
rules in between. Hand-written HCL never needed any of that.

## Decision

Compile, plan, apply, export and destroy one root, with one state in the
deployment's state directory.

- **Compilation:** `compile::deployment_graph` merges the runtime graph
into the object graph.
- **Gateway reads:** the runtime's gateway read, which waits for the
gateway it installs, replaces the plan-time read. On a fresh install or
a pending gateway change it moves to apply; otherwise it runs at plan.
- **Ordering:** every object already waits on the apply-time gateway
read, which now waits on every runtime resource and readiness read. So
the runtime settles before any object changes, within one apply. A spike
with the bundled OpenTofu confirmed that destroy follows the same chain,
removing objects before the runtime.
- **Plan and apply:** one saved plan, checked against runtime bindings
(bound process specifications, retained storage) and object targets
together.
- **Docker models:** the protection against disrupting a running model
applies to that plan.
- **Lost creations:** only OpenShell and Fabric creations are recorded,
since OpenTofu saves every other ID. After a failed apply, the record
forgets creations this apply added but OpenTofu never started; a failure
stops OpenTofu before everything that depends on what failed. A creation
whose apply started, or whose address OpenTofu didn't report, stays
pending, and so does any earlier unresolved one.
- **Teardown:** one teardown graph and one destroy, with Helm
checkpointing around it as before. The retained workspace binding is
required only once OpenShell objects are bound.
- **Export:** one refresh-only observation over the single state.
- **Removed:**
  - the runtime stage and its state subdirectory;
  - the runtime pending and destroy markers;
  - the gateway-not-running deferral and its message;
- `OperationResult::deferred_resources`, and the CLI section that
printed it;
  - the Kubernetes "unfinished platform apply" rule.

Per the decisions on #13254: no compatibility work, and a gateway that's
down is an ordinary failure.

## Validation

- `cargo ci` passes locally: 1527 unit tests, 145 lifecycle tests.
- `cargo ci live-docker` passes: 9 tests, including the managed
gateway's plan, apply, no-op, destroy and recovery with real Docker and
OpenTofu.
- **New unit test:**
`a_failed_apply_forgets_only_new_creations_it_never_started`.
- **Updated tests:**
- **Two-stage expectations:** the Helm recovery, remote-service and
Kubernetes interruption tests used the second state directory,
stage-specific command scripts and runtime-only markers. They now use
one state; tests of removed rules are deleted.
- **Live tests:** Brev, Spark, hosted parity and the dummy agent now
expect one plan that creates runtime and objects together. These need
their own hardware and weren't run here.

The architecture, apply-flow and state docs still describe two stages;
the docs PR for #13254 updates them.
gaveezy added a commit that referenced this pull request Oct 18, 2026
…rnetes gateways

## Failure

On a managed Kubernetes gateway, apply failed with "observation
authentication failed" for any inference provider with a `credential`.
The gateway never received `CreateProvider`.

Since #13264, the provider reaches such a gateway through a port-forward
and resolves every secret reference through `ForwardSecrets`. That map
holds only the forward's own bearer token and TLS file paths, under the
names `token`, `ca`, `certificate` and `key`. A provider's
`credential_env`, such as `QWEN_INFERENCE_KEY`, was looked up in that map
and missed. A `credential_env` that matched one of those names did
resolve, and sent the forward's value to OpenShell as the provider's
credential.

The live run for #13063 hit this with a key-protected vLLM server in the
cluster. The same path serves every credentialed provider on a managed
Kubernetes gateway, HTTPS included; that case was not run.

## Decision

- The forward's secrets now authenticate only the connection. Objects
  resolve their references from the environment, as on a direct
  connection, so no reference reaches the forward's values, whatever its
  name.
- `OpenShell::connect_with_credentials` takes the two resolvers
  separately; `connect_with_services` passes the same one for both, so
  direct connections are unchanged.
- A missing or empty variable still fails with `Authentication`.

## Validation

- Two fake-gateway tests reach a fixture gateway that requires mutual
  TLS and the forward's bearer token, through `GatewayClient` with a
  fake forward. Both failed before the change:
  - a provider whose `credential_env` is `PATH` registers with this
    process's `PATH`; before: `Some(Authentication)`;
  - a provider naming `token`, `ca`, `certificate` or `key` fails with
    `Authentication`, and the gateway receives no provider; before,
    `token` registered with the forward's token.
- `cargo test -p openshell-provider --lib` passes (60 tests), and
  `cargo clippy -p openshell-provider --all-targets -D warnings` is clean.
- `rcgen` is a new dev-dependency of `openshell-provider`, for the
  fixture's certificates; the lock file already held it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cv added a commit that referenced this pull request Oct 18, 2026
… servers (#13063)

Sandboxes on a Kubernetes or OpenShift gateway can now use a model
server that the user runs in the same cluster, addressed by its Service
name: `http://<service>.<namespace>.svc.cluster.local:<port>/v1`,
optionally with a key. NemoClaw places nothing on the cluster. This is
the "Placing servers" model of #13131: the platform owns placement,
readiness and the key.

The PR also fixes a `v1` bug that the key needs: on a managed Kubernetes
gateway, any provider with a `credential` failed at apply with
"observation authentication failed".

Supersedes the earlier stacked version of this PR; #13061 and #13062 are
parked.

## Why

Before this PR, YAML that names an in-cluster Service failed in two
places (both seen by compiling
`examples/kubernetes/managed-development.yaml` with the endpoint
changed):

- **Without `credential`:** plan and compile failed with "inference
discovery inputs are invalid". The control-host model-catalog read
accepts plain HTTP only to a literal loopback or private address
(`nemoclaw-backend` `validate_endpoint`), and the machine running
NemoClaw usually cannot resolve cluster DNS anyway.
- **With `credential`:** the schema rejected the document, because
`config/schema/validation.rs` forbade `credential` on every `http:`
endpoint.

A YAML user could reach an in-cluster server only by a literal ClusterIP
and without a key, and that address changes when the Service is
recreated. HCL users can already do this with a literal
`openshell_inference` server (`docs/inference.md`, "Supply the Key on
Other Platforms").

The first live run of the keyed form on kind then failed at apply in
`v1` itself, before OpenShell received the provider (fix in commit 4
below).

## What changes

Six commits and three merges of `v1`. The first merge took `v1`'s tree
unchanged (parents `46eea8340` and `ef3115d4e`). The second,
`2fa69d20a`, merges `v1` at `7d7772eda` (#13411), and the third,
`c9136276a`, merges `v1` at `64c384eff` (#13413); their conflicts and
test adaptations are listed after the commits.

1. **Route without a catalog read** (`feat(sdk): route Kubernetes
sandboxes to in-cluster Services`)
- `inference_discovery::is_cluster_service_endpoint` accepts exactly
`http://<service>.<namespace>.svc.cluster.local:<port>` with an optional
path: a DNS-1035 service label, a DNS-1123 namespace label, and an
explicit, nonzero, unpadded port. Nothing else matches.
- `EndpointRequest::for_provider` skips the catalog read for that form
when `gateway.runtime.provider` is `kubernetes` or `openshift`. Plan
(`endpoint_requests`) and onboarding (`inference_request_for_document`)
both use it, so they ask the same questions.
- Docker and Podman gateways, and every other endpoint, keep their
reads; the Service form still fails planning on Docker and Podman.
- Compile needed no change. The graph registers the literal
`openshell_inference` server with that endpoint, gives the sandbox an
FQDN rule without `allowed_ips` or `cluster_grants`, and passes the
endpoint to Fabric as `base_url`.
2. **Optional key** (`feat(sdk): accept a key for in-cluster Service
endpoints`), a separate commit so it can be dropped (Q1 below)
- `credential` is allowed on the Service form only when the gateway
runtime is `kubernetes` or `openshift`. The provider definition still
forbids a key on every other `http:` endpoint, and a document-level rule
forbids it on the Service form with Docker or Podman, in all five places
a provider can be declared.
   - Both rejections name the rule instead of a bare `not`.
3. **Docs and examples** (`docs(kubernetes): use a model server that
runs in the cluster`)
- `docs/kubernetes.md`, "Use a Model Server in the Cluster": the
endpoint form and its limits, then a procedure that runs NemoClaw's vLLM
runtime from `vllm_runtime`'s spec, `launch` and `requirements`: a
Secret for the key, a ConfigMap for the spec, a PVC, a `Recreate`
Deployment with `/health` startup and readiness probes, a ClusterIP
Service, an ingress NetworkPolicy that admits only OpenShell supervisor
Pods, and waiting for the rollout, because apply does not check the
server.
- `examples/kubernetes/in-cluster-vllm.yaml` (endpoint and `credential`)
and `in-cluster-ollama.yaml` (endpoint only).
- `docs/inference.md` (service-mode row, the HTTPS exception, link from
"Supply the Key on Other Platforms"), `docs/limits.md` (the #12641 row
now covers only services NemoClaw places) and `docs/security.md` (who
can read the key; the plain-HTTP exception).
- `schemas/nemoclaw-v1alpha1.schema.json` and
`docs/reference/configuration.md` are regenerated.
4. **Provider fix** (`fix(openshell-provider): resolve credential
variables on managed Kubernetes gateways`)
- **Why it is here:** the key from commit 2 cannot reach OpenShell on a
managed Kubernetes gateway without it. It also fixes every other
provider with a `credential` on such a gateway, HTTPS included.
- **Failure:** since #13264, the provider reaches a managed Kubernetes
gateway through a port-forward and resolved every secret reference
through `ForwardSecrets`. That map holds only the forward's bearer token
and TLS file paths, named `token`, `ca`, `certificate` and `key`. A
provider's `credential_env`, such as `QWEN_INFERENCE_KEY`, missed it, so
apply failed with "observation authentication failed" and the gateway
received no `CreateProvider`. A `credential_env` named `token` resolved,
and sent the gateway's bearer token to OpenShell as the provider's
credential.
- **Change:** the forward's secrets authenticate only the connection.
Objects resolve their references from the environment, as on a direct
connection, so no reference reaches the forward's values, whatever its
name. `OpenShell::connect_with_credentials` (crate-private) takes the
two resolvers separately; `connect_with_services` passes the same one
for both, so direct connections are unchanged. A missing or empty
variable still fails with `Authentication`.
- The first live run used a scratch fix that fell back to the
environment for names the forward lacks. This commit does not do that:
under that approach `token` still resolved to the gateway's token, which
the second new test catches. The second live run used this commit.
5. **Docs corrections from review and the first live run**
(`docs(kubernetes): correct the in-cluster model server steps`)
- Step 1 sets `memory { gpu_memory_gib = 20, kv_cache_gib = 6 }`.
Without it, Qwen3-4B's 7.5 GiB of weights, the default 8 GiB KV cache
and 2 GiB exceed the default 16 GiB budget, and the server crash-loops
with "model weights exceed the declared GPU memory budget".
`docs/provider.md`'s `vllm_runtime` example gets the same block.
- Step 1 sets `tool_parser = "hermes"` and `reasoning_parser = "qwen3"`;
without a tool parser, vLLM answers OpenClaw with HTTP 400.
- A "Run Ollama Instead" subsection replaces the one-line Ollama
instruction: `ollama_runtime` on port 11434, the Ollama runtime image,
the names `ollama`, no key, probes on `GET /api/version` (Ollama has no
`/health`), and the example's sandbox namespace.
- `runtimeClassName` where the node's default container runtime is not
NVIDIA's.
- The NetworkPolicy paragraph says that anyone who can create a Pod in
the sandbox namespace can carry the supervisor labels and reach the
server, and that the policy is a keyless server's only access control.
- The ports OpenShell refuses for declared hosts: 2379, 2380, 6443,
10250 and 10255 (`BLOCKED_CONTROL_PLANE_PORTS`, OpenShell `5a7728c`).
- Changing the key: a new variable name, because apply does not notice a
new value behind the same name; replace the Secret, restart the server,
then apply, which updates OpenShell's registration in place. Requests
fail in between.
- A `docs/limits.md` row for what has been tried and what is untested.
6. **Docs from the second live run** (`docs(kubernetes): finish the
in-cluster server steps from the live run`)
- Both examples set `maxTokens: 2048` on the route, with a comment.
Without it, OpenClaw asked vLLM for `max_completion_tokens=166699`, and
vLLM, with a 32768-token context, answered 400; 8192 also failed,
because OpenClaw's prompt is about 22-28k tokens. `v1`'s OpenClaw
examples all set `maxTokens`, and `examples/managed-ollama-gpu.yaml`
uses 2048 for the same Ollama model.
- "Run Ollama Instead" names every change: the `ollama` provider and the
`data.ollama_runtime.ollama.spec` output in step 1, the ConfigMap
`ollama-runtime` in step 2, and `configMapKeyRef.name` `ollama-runtime`
and `claimName` `ollama-data` in step 3. It replaces the copied probe
comment "GET /health needs no key".
- For Ollama, `rollout status` finishes as soon as Ollama listens,
before the runtime has loaded the model, so step 4 also waits for the
runtime's log line "ready: managed service readiness confirmed".
- "You need" states the node memory that both runtimes check at start:
`host_reserve_gib` (default 32) plus 20 GiB of the node's available
memory for a GPU with its own memory, or the GPU budget plus 20 GiB on
`dgx-spark` and `rtx-spark` (`vllm::hardware_capacity::check_memory`,
`ollama::hardware_capacity::check_memory`).
- After a key change, readers remove the old key from their secret
manager and unset its variable.
- One sentence says that OpenClaw, which both examples use, cannot start
in OpenShell sandboxes with the pinned Fabric (#13372).
- The `docs/limits.md` row now says the vLLM and Ollama runtimes were
tried on one kind cluster; OpenShift and other network plugins are
untested.

The second `v1` merge:

- `deployment_journey` counts 40 single-sandbox examples: `v1` added
eight and this branch adds two.
- The configuration reference keeps `v1`'s `api` description and this
branch's `credential` and `endpoint` descriptions; `schema --check`
reports both generated files current.
- #13384 made `policy.managed` an unlabeled list, so two tests from this
branch now find the inference grant by its `name`.

The third `v1` merge (#13390, #13388, #13409, #13413):

- One conflict, in `docs/security.md`'s inference transport row. #13388
says NemoClaw accepts HTTP and HTTPS URLs and recommends HTTPS for
credentialed endpoints; this branch adds that a key for an in-cluster
Service endpoint crosses the cluster network over plain HTTP. The row
keeps both, next to `v1`'s new onboarding catalog row.
- `schema --check` reports both generated files current after #13390's
`imagePullSecrets`.

`git diff --stat upstream/v1 HEAD`:

```
 Cargo.lock                                         |   1 +
 crates/nemoclaw-authoring/src/discovery_queries.rs |   4 +-
 .../nemoclaw-authoring/tests/deployment_journey.rs |   2 +-
 .../nemoclaw-authoring/tests/discovery_queries.rs  |  39 +++
 crates/nemoclaw-sdk/src/config/constraints.rs      |   3 +
 .../nemoclaw-sdk/src/config/schema/validation.rs   |  32 +-
 crates/nemoclaw-sdk/src/config/types.rs            |   4 +-
 crates/nemoclaw-sdk/src/inference_discovery.rs     |  56 ++-
 crates/nemoclaw-sdk/tests/kubernetes_inference.rs  | 390 +++++++++++++++++++++
 crates/nemoclaw-sdk/tests/main.rs                  |   2 +
 crates/openshell-provider/Cargo.toml               |   2 +
 crates/openshell-provider/src/client.rs            |  18 +-
 crates/openshell-provider/src/connected.rs         |   1 +
 .../openshell-provider/src/fake_gateway_tests.rs   | 235 +++++++++++++
 crates/openshell-provider/src/transport.rs         |  21 +-
 docs/inference.md                                  |   3 +
 docs/kubernetes.md                                 | 304 +++++++++++++++-
 docs/limits.md                                     |   3 +-
 docs/provider.md                                   |   5 +
 docs/reference/configuration.md                    |   4 +-
 docs/security.md                                   |   3 +-
 examples/kubernetes/in-cluster-ollama.yaml         |  53 +++
 examples/kubernetes/in-cluster-vllm.yaml           |  55 +++
 schemas/nemoclaw-v1alpha1.schema.json              | 224 +++++++++++-
 24 files changed, 1442 insertions(+), 22 deletions(-)
```

Production code is about 125 lines; the schema grows because the
document-level key rule repeats for each provider location. `rcgen` is a
new dev-dependency of `openshell-provider`, for the fake gateway's
certificates; the lock file already held it.

## Breaking or user-visible changes

- **Accepted now:** with a Kubernetes or OpenShift gateway, a provider
endpoint of the Service form plans and compiles, and may carry
`credential`. Plan and onboarding read no model catalog for it, so a
successful plan does not show that the server runs or serves the route's
model.
- **Fixed:** on a managed Kubernetes gateway, a provider's `credential`
variable resolves from the environment where `nemoclaw` runs, as on
every other gateway, instead of failing apply. A variable named `token`,
`ca`, `certificate` or `key` no longer resolves to the forward's own
credentials.
- **Unchanged:** Docker and Podman gateways still reject the Service
form, with or without a key. Every other `http:` endpoint still takes no
key.
- **Key transport:** a key for the Service form crosses the cluster
network over plain HTTP unless the network plugin or a service mesh
encrypts Pod traffic. The docs say so.
- **Error text:** a key on a plain-HTTP endpoint now fails with
"credential requires an HTTPS endpoint, or an
http://SERVICE.NAMESPACE.svc.cluster.local:PORT endpoint with a
Kubernetes or OpenShift gateway" instead of "...: not". A key on the
Service form with Docker or Podman fails with "credential on an
http://SERVICE.NAMESPACE.svc.cluster.local endpoint requires a
Kubernetes or OpenShift gateway".
- **Examples:** two new single-sandbox examples, both with OpenClaw. The
authoring example check now covers 40, and onboarding generates two more
example journeys. With the pinned Fabric v0.5.0, OpenClaw does not start
in OpenShell sandboxes (#13372), as for every OpenClaw example on `v1`.
- **Rust API** (`publish = false` crates): new
`nemoclaw_sdk::inference_discovery::is_cluster_service_endpoint` and
`EndpointRequest::for_provider`.
`nemoclaw_authoring::inference_request_for_document` returns `None` for
such a route, as it does for a managed-service route.
- No change to compiled graphs, state, or provider schemas.

## Test proof

### `cargo ci --full` (linux_arm64, final head)

It ran on head `eda1e3fbe`, tree `27f526e77`, with `upstream/v1` at
`64c384eff`.

```
ok tools in 0s
ok fmt in 1s
ok clippy in 27s
ok build in 48s
     Summary [  20.436s] 1568 tests run: 1568 passed, 204 skipped
ok test in 26s
ok schema in 0s
ok bundle in 66s
     Summary [ 116.878s] 153 tests run: 153 passed, 51 skipped
ok lifecycle in 122s
All selected CI steps passed in 292s
cargo-ci-exit=0 elapsed=295s
```

- The test step's 4 doctests passed. It ran 1568 tests, 4 more than at
`59545ebf4`: the third merge's `v1` commits add 4 tests to this step.
This PR's 14 new names are its 12 tests and the 2 generated onboarding
journeys
(`tui::tests::example_journeys::kubernetes_in_cluster_{vllm,ollama}`).
- Lifecycle ran 153 tests, as before the third merge; this PR adds none.
- Timing budgets, reported only on this host: every step and every
budgeted binary is within budget (`openshell-provider::contract` 99.3 s
of 105 s).

### New tests: red without the production change, green with it

Twelve new tests, plus two onboarding example journeys that the build
generates from the new examples. Red runs reverted only production
sources in the working tree, or ran before they existed; the final
`cargo ci --full` ran on the committed tree.

| Test | Red: before its production change | Green |
|---|---|---|
|
`kubernetes_inference::a_cluster_service_endpoint_is_an_http_service_dns_name_with_an_explicit_port`
(7 accepted and 38 rejected endpoints) | the function does not exist;
the red run used a panicking stand-in, which fails | passes |
|
`kubernetes_inference::cluster_gateways_read_no_model_catalog_for_a_cluster_service`
(Kubernetes and OpenShift, external and managed) | `endpoint_requests`
fails: "HTTP requires a literal loopback address or private inference
address" | no catalog read |
|
`kubernetes_inference::a_cluster_service_compiles_to_a_literal_server_and_an_fqdn_sandbox_rule`
| compile fails: "inference discovery inputs are invalid" | literal
server, FQDN rule without `allowed_ips` or `cluster_grants`, Fabric
`base_url` |
|
`discovery_queries::a_cluster_service_route_has_no_control_host_catalog_to_read`
(authoring) | `inference_request_for_document` returns
`Some(EndpointRequest { endpoint:
"http://qwen.models.svc.cluster.local:8000/v1", .. })` | `None`; neither
plan nor onboarding reads a catalog |
|
`kubernetes_inference::a_cluster_service_endpoint_takes_a_key_only_with_a_cluster_gateway`
(5 provider locations; compiled `credential_env`) | the input schema
rejects the key on Kubernetes | accepted on Kubernetes and OpenShift,
rejected on Docker and Podman with the named error |
|
`kubernetes_inference::a_constructed_document_cannot_send_a_key_to_a_service_from_a_local_gateway`
| the Kubernetes document with a key does not parse ("violates schema …
: not") | `validate` rejects the document after its gateway moves to
Docker |
|
`kubernetes_inference::only_the_service_form_takes_a_key_over_plain_http`
| the Service form with a key does not parse (`left: false, right:
true`) | an `http:` endpoint with a key parses exactly when
`is_cluster_service_endpoint` accepts it |
| `openshell-provider`
`fake_gateway_tests::a_managed_kubernetes_gateway_resolves_provider_credentials_from_the_environment`
| `provider: Some(Authentication)`, the live failure | the fake gateway
stores the provider with this process's `PATH` as its credential |
| `openshell-provider`
`fake_gateway_tests::a_providers_credential_variable_never_resolves_to_the_forwards_credentials`
| `token` registers with the forward's bearer token (`left: None, right:
Some(Authentication)`) | `token`, `ca`, `certificate` and `key` each
fail with `Authentication`, and the gateway receives no provider |

The two provider tests reach the fake gateway through `GatewayClient`
with a fake forward that supplies a bearer token and mutual-TLS files,
as `SdkKubernetes` does; the fixture gateway requires both, so the
workspace and profile they create first also show that the forward still
authenticates the connection. `PATH` stands in for a key because a test
cannot set a variable safely while other tests run. With the first live
run's scratch fallback in place of the fix (mutation), the first test
passes and the second fails at `token`.

Guards and characterization, which pass before and after by design:

-
`kubernetes_inference::local_gateways_still_reject_a_cluster_service_endpoint`
fails when the skip ignores the gateway runtime (mutation).
-
`kubernetes_inference::other_endpoints_on_cluster_gateways_keep_their_catalog_reads`
fails when any `http:` name containing `.svc` counts as a Service
(mutation); that mutation also fails the endpoint table.
- Dropping the sandbox `agent.inference` location from the
document-level key rule fails
`a_cluster_service_endpoint_takes_a_key_only_with_a_cluster_gateway` at
"docker agent inference" (mutation).
- `openshell-provider`
`fake_gateway_tests::a_service_name_profile_and_a_sandbox_without_grants_pass_endpoint_ambiguity_checks`
(rows from the `local` and `hermes-auth` fixtures, unauthenticated and
authenticated): it composes the provider profile and the sandbox policy
that the fake gateway received with OpenShell's own
`compose_effective_policy` and `find_endpoint_ambiguities`. The check
finds no ambiguity, and a ClusterIP on the sandbox's rule alone gives
exactly one `allowed_ips` conflict. It passes on `v1` with no production
change; the first live run confirmed it on an OpenShell v0.1.4 gateway,
and the second stored the same rule.

### Other checks

- The docs' `vllm_runtime` and `ollama_runtime` blocks, including the
Ollama block's new `spec` output, and `docs/provider.md`'s
`vllm_runtime` example compute their specs with OpenTofu 1.12.6 and the
`vllm` and `ollama` providers of the final head's bundle.
`ollama_runtime` reports port 11434, `/data` and no `key_env`, and both
specs carry `hostReserveGiB` 32, the default the node-memory bullet
names.
- The documented Secret and ConfigMap commands, and the Secret
replacement for a key change, produce the expected objects in a
`kubectl` client dry run against an empty kubeconfig; the second live
run ran the Secret and ConfigMap commands on a cluster. The key change
was never run on a cluster.
- `nemoclaw-build docs`, then `docs --check`, pass on the final head,
including link and anchor checks. `nemoclaw-build fern check` needs
Node.js, which this host lacks; deferred to CI.
- Not run live: commit 6 as committed (the vLLM route's `maxTokens:
2048` ran; the Ollama example's did not, and the Ollama readiness wait
was observed, not run as written), the third `v1` merge, the key change,
OpenShift, and other network plugins.

### Live evidence (not qualification; #12732 stays open)

The second live run, on 2026-10-18, used head `59545ebf4`: `v1`
`7d7772eda` and commits 1-5. Since then the branch gained commit 6,
which makes the docs changes this run called for, and the third `v1`
merge (`64c384eff`); this PR's own code did not change, and `v1`'s
changes from that merge did not run live.

**Setup.** A kind cluster with one GB300 worker and the `nvidia`
RuntimeClass (the worker's containerd default runtime is `runc`). The
linux_arm64 bundle came from that head's `cargo ci --full`; the vLLM
runtime, Ollama runtime and OpenClaw agent images were built from that
head and loaded on the worker by digest. The docs steps ran as written,
except for the namespaces, the image digests, the deployment UID and
context, `hardware` (`gb300`, `arm64`), and `runtimeClassName: nvidia`,
which step 3 says to set on such a node.

**Locally modified agent image.** With the pinned Fabric v0.5.0,
OpenClaw cannot start in OpenShell sandboxes (`v1` #13372). The first
apply registered the keyed provider and created the sandbox, then
stopped at the agent with `start_failed`; Fabric's start reported
`setpriv: activate capabilities: Operation not permitted`, with and
without the key. Every later apply in this run used the head's OpenClaw
image with `/usr/bin/setpriv` removed, built locally for this run only.
Without `setpriv`, Fabric's adapter runs the OpenClaw gateway directly.

**Keyed vLLM** (`in-cluster-vllm.yaml` with `QWEN_INFERENCE_KEY` set):

- **Provider fix:** apply registered the keyed provider `qwen` on the
managed Kubernetes gateway. At `620ea6966` this step failed with
"observation authentication failed".
- **Server:** steps 1-4 created the Secret, ConfigMap, PVC, Deployment,
Service and NetworkPolicy, and `rollout status` finished in 296 s.
Inside the model Pod, `/health` answered 200 without a key; `/v1/models`
answered 401 without a key and with a wrong key, and chat 401 without a
key; with the key, `/v1/models` and a chat with tools and `tool_choice:
auto` answered 200.
- **Policy rule:** a read-only `GetSandbox` showed one network rule, the
same after each sandbox replacement:

  ```
sandbox assistant phase SANDBOX_PHASE_READY policy version 1;
policy-input cluster_grants: []; managed rules:
["nemoclaw-inference-qwen-eb79800cf1772956a635ba0b"]
rule nemoclaw-inference-qwen-eb79800cf1772956a635ba0b:
qwen.nemoclaw-pr13063-r2-models.svc.cluster.local:8000 ports [8000]
protocol=rest allowed_ips=[] binaries=2
rules with allowed_ips: []; Service ClusterIP 10.96.23.27 appears in
policy: 0
  ```

The agent's model entry names that endpoint as `base_url`, and its key
variable holds an `openshell:resolve:env:` placeholder.
- **OpenClaw turn:** with the example's route as committed before commit
6, the turn failed with vLLM 400 (`max_completion_tokens=166699 cannot
be greater than max_model_len`); with `maxTokens: 8192` it failed the
same way (prompt of at least 24,577 tokens). With `maxTokens: 2048` the
turn `succeeded`: 6 × `POST /v1/chat/completions -> 200`, all from the
sandbox's OpenShell supervisor Pod; the sandbox's workload Pod never
reached the server. The 4B model did not reply with the requested words;
it tried a messaging tool.
- **401 without the key:** a Pod with the supervisor labels in the
sandbox namespace got `GET /v1/models` 401 without a key, while the
supervisor's requests got 200, so OpenShell supplied the key.
- **Key exposure, 0 matches in each place:** the sandbox environment
(only the placeholder variable and `NEMOCLAW_ANONYMOUS_API_KEY="unused"`
name a key); all 24 sandbox files under `/sandbox` and `/tmp` outside
the Node compile cache, including OpenClaw's configuration, its SQLite
WAL and its log; `export`; the deployment state directory; ConfigMaps in
both namespaces; Secrets in the gateway namespace, raw and base64; the
logs of 4 gateway-namespace containers; the model Pod log.
- **Export:** keeps `credential: {env: QWEN_INFERENCE_KEY}` and
`maxTokens: 2048`; planning the export reports no changes.

**Keyless Ollama** ("Run Ollama Instead" steps 1-4, then
`in-cluster-ollama.yaml` without `maxTokens`):

- `rollout status` finished in 25 s; plan and apply succeeded; one turn
replied "in-cluster ok" with 1 × `POST /v1/chat/completions -> 200` from
the supervisor Pod.
- The stored policy held one rule,
`ollama.nemoclaw-pr13063-r2-omodels.svc.cluster.local:11434 ports
[11434] protocol=rest allowed_ips=[]`, with `cluster_grants: []`. The
agent uses `NEMOCLAW_ANONYMOUS_API_KEY`.
- The rollout finished 45 s before the runtime logged "ready: managed
service readiness confirmed"; commit 6 adds that wait to step 4.
- Planning the export reports no changes.

**NetworkPolicy:**

- vLLM: plain Pods in the sandbox namespace, the server namespace and
`default` timed out, and so did a Pod with the supervisor labels in
`default`.
- Ollama: plain Pods timed out; a Pod with the supervisor labels in the
sandbox namespace got 200 on `/api/version` and `/v1/models`. Without a
key, the NetworkPolicy is the only access control, as the docs say.

**Earlier findings.** The first live run (2026-10-16, head `620ea6966`
on `v1` `ef3115d4e`) found the provider bug that commit 4 fixes and the
docs gaps that commit 5 fixes; this run confirmed both. Its
re-apply-after-destroy failure is fixed in `v1` by #13408: here, destroy
and a new apply with the same state succeeded.

**`v1` observations, not this PR:** after the failed agent start, `plan
--destroy` and destroy succeeded. After that start failure, apply
refused to replace the sandbox for a changed `image.ref` ("apply cannot
replace sandbox 'assistant'; its files and conversation history are not
separately retained"), but replaced it for a changed route `maxTokens`,
which deletes the same files.

**Cleanup.** Both destroys completed; the run's namespaces and their PVs
were deleted; the cluster's namespaces, PVs, PVCs and cluster-scoped
objects match the start; GPU memory was 0 MiB at the end. The key file
was deleted after the last check.

## Review items left unchanged

- On a cluster gateway, a mistyped Service endpoint (for example
`http://qwen.models.svc:8000/v1`) fails planning with the generic
"inference discovery inputs are invalid" (`discovery.rs` drops the
cause). The text predates this PR; a hint naming the accepted form could
follow separately.
- A trailing space or NUL in a Service endpoint is accepted, because
`validate_endpoint_url` rejects only some control characters. The host
stays the Service, so the key goes nowhere else; the fix belongs in
endpoint validation for every endpoint, separately.
- The `feat` commit messages say "Q1" and call the endpoint table red;
the PR body is what lands on squash merge, and it describes both
correctly.

## Questions pending with the maintainers (#12641)

- **Q1, key over in-cluster HTTP:** may a YAML provider set `credential`
on the Service form with a Kubernetes or OpenShift gateway? HCL already
allows it, and managed Docker vLLM already sends its key over private
HTTP. If not, drop the second commit and the key parts of the docs and
the vLLM example; the routing half needs no decision, and commit 4
stands on its own.
- **Q2, discovery:** may compile skip the control-host catalog read for
these endpoints? The control host cannot resolve cluster DNS; this
follows #13291.
- **Q3, cluster domain:** this PR accepts only the lowercase
`<service>.<namespace>.svc.cluster.local` form. OpenShell's own
`is_kubernetes_service_host` (`profiles.rs`, `5a7728c`) also accepts
`<service>.<namespace>.svc`, any letter case, and a trailing dot. Should
NemoClaw accept those, or a custom cluster domain?
- **Q4, NetworkPolicy selector:** the docs admit Pods labelled
`openshell.ai/boundary-role=supervisor` (with
`openshell.ai/managed-by=openshell`), OpenShell's own labels at
`5a7728c`. Anyone who can create a Pod in the sandbox namespace can set
them. Is that stable enough to document, or should we ask OpenShell for
a supported selector?

🤖 Generated with [Claude Code](https://claude.com/claude-code)


## Update (maintainer)

Merged `v1` and reworked, following the principle settled in #13131:
NemoClaw does what it owns, and leaves destination policy to OpenShell
(#13232).

- **No cluster-DNS special cases.** Removed
`is_cluster_service_endpoint`, `CLUSTER_SERVICE_ENDPOINT`, the
cluster-only credential exception, and the rule rejecting a cluster
address with a key on Docker or Podman. Instead, the general provider
rule forbidding a `credential` on `http:` endpoints is gone. OpenShell
decides where a sandbox's key may go, as it already decides where its
traffic goes.
- **Catalog reads.** Plans no longer read catalogs (#13291). Discovery
now builds a catalog query only for endpoints NemoClaw's own connection
rules allow (HTTPS, or HTTP to a literal loopback or private address).
Others, such as a cluster Service, get none, rather than making
compilation fail. Onboarding then can't suggest that server's models.
- **Kept:** the credential fix for Kubernetes gateways (the connection's
secrets are separate from those of the objects it manages), its
fake-gateway tests, the compile test for routing to a cluster Service,
and both examples. `kubernetes_inference.rs` now checks that any HTTP or
HTTPS endpoint takes a key on any gateway, wherever the provider is
declared.
- **Docs:** "Use a Model Server in the Cluster" is now a short section.
The server is deployed with the platform's own tools, and "Supply the
Key on Other Platforms" covers the key. The step-by-step runbook was
removed. `inference.md` and `security.md` say to prefer HTTPS for
credentialed endpoints, because over plain HTTP the key travels
unencrypted. `limits.md` keeps the two model-server rows and drops the
resolved #12692 and #12709 rows.

`cargo ci` passes locally: 1,565 unit tests and 153 lifecycle tests.
`fern check` reports 0 errors.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
@wscurran wscurran added the v1 NemoClaw v1 branch label Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening feature PR adds or expands user-visible functionality platform: k8s Affects Kubernetes deployments v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants