Skip to content

feat(kubernetes): authenticate a managed gateway through an existing OIDC issuer - #13414

Merged
cv merged 4 commits into
v1from
feat/kubernetes-oidc
Oct 18, 2026
Merged

cv merged 4 commits into
v1from
feat/kubernetes-oidc

Conversation

@cv

@cv cv commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #12692.

Failure

A managed Kubernetes or OpenShift gateway could only authenticate users through a development issuer the SDK runs in its namespace, which isn't an identity service. Production identity required running your own gateway (gateway.management: external).

Decision

gateway.kubernetes.authentication.profile: oidc points the managed gateway at an existing issuer, as decided on #12692:

  • Settings: issuer (https), audience, optional rolesClaim, adminRole and userRole (both or neither, as OpenShell requires), scopesClaim, and caConfigMap, an existing ConfigMap in the deployment's namespace. They pass through to the gateway chart's OIDC settings. NemoClaw creates no development issuer, signing key or token for this profile.
  • Token: tokenEnv names the variable holding the bearer token. The SDK and providers send it with the client certificate. It reaches OpenTofu with the other credential variables and never enters state. NemoClaw runs no OAuth flows; the identity provider's tooling gets and refreshes the token.
  • Validation: the schema requires issuer, audience and tokenEnv for oidc, rejects OIDC fields under development, and applies the kubeconfig variable's reserved-name rules to tokenEnv.
  • Auth resource: with no issuer objects, the auth resource is identified by its namespace once ready.
  • Settings in rows and graphs: they travel as an oidc attribute backed by an oidc_json field, like environment.
  • Clippy: ManagedGateway.kubernetes is now boxed, to stay under its enum-size limit.
  • Docs:

Validation

  • New tests:
    • The configuration accepts a minimal oidc profile and rejects:
      • a missing issuer, audience or tokenEnv;
      • an http issuer, or one with credentials or a query;
      • a reserved or lowercase tokenEnv, or an invalid caConfigMap;
      • an unpaired adminRole;
      • OIDC fields under development.
    • A compile test checks the chart's OIDC values, the CA ConfigMap with and without it, the auth resource's settings, and that tokenEnv reaches OpenTofu.
    • The row round-trip test covers the oidc profile.
  • cargo ci passes locally (1,556 unit and 153 lifecycle tests), and fern check reports 0 errors.

Live qualification

This PR now also closes #12692. A live Kind test, kubernetes_live::oidc, runs the SDK's development issuer image in its own namespace as a stand-in for an existing identity provider. It checks that:

  • the gateway accepts a deployment with the issuer's token from tokenEnv;
  • no development issuer runs in the deployment's namespace;
  • a plan with a token for another audience, signed with the same key, is refused without echoing the token;
  • export recovers the authored configuration;
  • destroy keeps the gateway's storage.

The test found three defects in the first version of this PR, now fixed:

  • the compiler emitted the oidc settings as an object, where the provider takes JSON text;
  • export's gateway-only environment didn't include tokenEnv; a unit test now checks it;
  • export read the observed settings under the field name instead of the attribute.

The new test replaces an_agent_sandbox_starts_and_destroy_keeps_storage, whose checks (agent starts, export, destroy keeps storage) it now performs. The development profile stays covered by the registry and gateway tests. That keeps the live Kind suite within its 270-second budget: locally, 7 tests in 228 seconds, the OIDC test taking 77.

limits.md drops the #12692 row.

Closes #12692.

…OIDC issuer

The oidc authentication profile passes an existing issuer's settings to the
gateway chart and sends the bearer token from the variable tokenEnv names,
instead of running a development issuer. NemoClaw runs no OAuth flows and
keeps the token out of state.
@cv
cv enabled auto-merge (squash) October 18, 2026 11:04
cv added 3 commits October 18, 2026 05:09
A live kind test runs the development issuer as an existing issuer. It found
three defects: the compiler emitted the oidc settings as an object where the
provider takes JSON text; export's gateway-only environment lacked tokenEnv;
and export read the observed settings under the field name instead of the
attribute. The test also replaces the plain agent test it duplicated, keeping
the live suite within its budget.
Like other optional strings, it now renders as a string in the configuration
reference instead of any JSON value, and rejects null.
@cv
cv merged commit c0b306e into v1 Oct 18, 2026
@cv
cv deleted the feat/kubernetes-oidc branch October 18, 2026 12:29
@github-actions

Copy link
Copy Markdown
Contributor

gaveezy added a commit that referenced this pull request Oct 19, 2026
The OIDC profile from #13414 named the variable holding the managed
gateway's bearer token as a bare `tokenEnv` string, so it was the one
secret reference outside SecretRef. It is now `token: {env: NAME}`.

- SecretRef's `env` rules apply to it. The token property adds the
  kubeconfig reference's reserved names, as tokenEnv did, because the
  token reaches OpenTofu beside the kubeconfig.
- A reserved name now reports `secret reference …` for the SDK prefixes
  and `token environment reference …` for the kubeconfig names.
- The provider's `oidc` attribute is the serialized settings, so it now
  carries `token.env`. Retained state written with `tokenEnv` fails as
  an invalid managed Kubernetes attribute instead of being adopted.
- Update the Kubernetes and credential rotation guides and regenerate
  the schema and configuration reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cv pushed a commit that referenced this pull request Oct 19, 2026
…eRef (#13222)

## Summary

Splits the configuration's one `Credential` type into `SecretRef`, whose
environment variable holds a bearer or API credential, and `FileRef`,
whose variable holds the path of a local file.
Existing references keep their `{env: NAME}` YAML; the managed
Kubernetes OIDC token moves from `tokenEnv: NAME` to `token: {env:
NAME}`. This is shape change 2 of #13080.

## Why

One type held both kinds of reference, so the schema, the generated
reference, and editors could not say whether a variable must contain a
secret or a path
([types.rs](https://github.com/NVIDIA/NemoClaw/blob/9a90ce7e7/crates/nemoclaw-sdk/src/config/types.rs#L76-L84)).

| Field | Runtime use of the variable's value | Type |
|---|---|---|
| `gateway.credential` (external) | Bearer token for the gateway
connection | `SecretRef` |
| `inferenceProviders[].credential`, inline route providers | Registered
provider credential | `SecretRef` |
| Web-search `integrations.<name>.credential` | Search provider API key
| `SecretRef` |
| API `integrations.<name>.credential` (#13403) | Key OpenShell injects
into requests to the API endpoint | `SecretRef` |
| `gateway.kubernetes.authentication.token` (#13414; was `tokenEnv`) |
Bearer token NemoClaw sends to a managed gateway with the OIDC profile |
`SecretRef` |
| `gateway.tls.ca`, `certificate`, `key` | Read as files | `FileRef` |
| `gateway.kubernetes.kubeconfig` | Made absolute and passed as the
kubeconfig path | `FileRef` |
| `sandboxes[].image.metadata` | Absolute path of an OCI metadata
bundle, read as a file | `FileRef` |

## Change

- `SecretRef` and `FileRef` replace `Credential` in the Rust types, the
schema, and the reference. There is no alias, so a misclassified
reference is a compile error.
- Both keep the existing `env` rules: the variable-name pattern and the
reserved `NEMOCLAW_KUBERNETES_STATE`, `NEMOCLAW_MANAGED_K8S_`, `HELM_`,
and `KUBE_` names. The kubeconfig and `environment` rules are unchanged.
A rejected name now reports `secret reference …` or `file reference …`.
- As cv's review asked, there is no `file` form for secrets and no
`kubernetesSecret` form: reading secrets from files changes the
credential model, and OpenShell cannot bind a Secret by reference yet.
Adding either later is additive.
- The OIDC token was the one secret reference held as a bare string
(`tokenEnv`). It is now a `SecretRef` under `token`. Its property keeps
the kubeconfig reference's reserved names, which `tokenEnv` also
excluded, because the token reaches OpenTofu beside the kubeconfig. A
reserved SDK prefix reports `secret reference …`; a kubeconfig-reserved
name reports `token environment reference …`.

Breaking for Rust SDK callers that name `Credential` or
`KubernetesAuthentication::token_env`, and for documents using the OIDC
profile, which must replace `tokenEnv: NAME` with `token: {env: NAME}`.
Other authored documents are unchanged.

Retained state is unchanged except for OIDC deployments made since
#13414: the `openshell_kubernetes_auth` resource's `oidc` attribute is
the serialized settings, so state that holds `tokenEnv` now fails as an
invalid managed Kubernetes attribute and is not adopted.
Development-profile state stores no settings and is unaffected.

## Validation

- New test
`config_kubernetes::a_reserved_reference_name_states_whether_the_reference_holds_a_secret_or_a_file_path`
failed before the change with the shared credential message. It checks
each `SecretRef` and `FileRef` field, including the API integration key
from #13403 and the OIDC token, along with the schema location and the
message, and that the name is not echoed.
-
`config_kubernetes::an_oidc_profile_requires_its_issuer_and_development_takes_no_oidc_settings`
and the reference-kind test failed on `token` as an unknown field before
the token change. The OIDC test now also rejects `tokenEnv` and a bare
string `token`.
- Settings that hold `tokenEnv` fail to deserialize into
`KubernetesAuthentication` with an unknown-field error, which
`Spec::from_row` maps to the invalid-attribute error. This was checked
with a temporary test that is not committed.
- `cargo ci` at `64cfa22e5` (linux_arm64; `v1` at `1802b0611` merged
in): every step passed (`tools`, `fmt`, `clippy`, `build`, `test`,
`schema`, `bundle`, and `lifecycle`). `test`: 1,601 tests, 19.2 s wall
against a 45 s budget. `lifecycle`: 150 tests, 106.9 s wall against 300
s. Contract binaries summed 8.4 s of 25 s (fabric-provider), 42.0 s of
45 s (nemoclaw-provider), and 101.6 s of 105 s (openshell-provider).
`nemoclaw-build docs --check` also passed.
- `5ecebeb63` merges `v1` at `d33d50647` (#13460), which changes only
build tooling. After the merge, `cargo fmt --check`, the
`nemoclaw-build` tests, `schema --check`, and `docs --check` passed.
- Not run: the live TLS, `kubernetes_live`, and `kubernetes_oidc`
suites, which need live clusters and an issuer. They compile under
clippy.

Part of #13080.

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

---------

Signed-off-by: Hai Nguyen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
cv added a commit that referenced this pull request Oct 19, 2026
…in-cluster route (#13484)

## Failure

#12734 asks for unit and fixture coverage of managed-gateway OIDC
authentication, token refresh and authentication failures, and of
per-agent identity and routing for agents that use cluster-local
inference. The Kubernetes gateway code that #13414 and #13063 added had
little of either.

**OIDC.** Every SDK Kubernetes operations and connect test used the
development profile, so the `oidc` branches from #13414 had no unit or
fixture test: the auth resource identified by its namespace once ready,
no issuer objects or signing material, and the token read from the
variable `tokenEnv` names. The forwarded fake-gateway tests always
supplied the token the gateway expected. Only the live
`kubernetes_live::oidc` test refuses a token on the managed Kubernetes
path, and it checks neither the error class nor that nothing changed.

**Several agents on an in-cluster model.** `kubernetes_inference`
covered one sandbox, from the `local.yaml` fixture. No test checked
per-agent names or routes for the three-agent cluster examples:
`example_configurations_are_valid_fabric_configurations` compiles them
only to validate their Fabric configurations. The #13063 commit message
names catalog-skip tests, such as
`kubernetes_inference::cluster_gateways_read_no_model_catalog_for_a_cluster_service`,
that v1 does not have.

## Decision

These tests characterize existing behavior; no production code changes.

### OIDC

- `kubernetes_operations`: with an `oidc` spec, `ensure` of the auth
resource adds no cluster objects and no local signing material. `read`
reports no identity before the resource is ready, and the namespace UID
after.
- `kubernetes_connect`: `running` takes the spec to prepare from. A
connection's token equals the value of the variable `tokenEnv` names,
and no state file contains it. When that variable is unset or empty,
`connect` fails with the `tokenEnv` message.
- Tests can't safely set a variable while others run, so `tokenEnv`
names variables that Cargo and nextest set for every test process:
`CARGO_MANIFEST_DIR` holds a token, and `CARGO_PKG_LICENSE_FILE` is
empty because the package declares an SPDX license. `PATH`, the
precedent in `fake_gateway_tests`, can't be used: the schema forbids it
as `tokenEnv`, so the operations refuse the spec with `Query` before
`connect` reads a token.
- `fake_gateway_tests`: the `Forward` stub's token is now a field, and
`Forward::client` opens a new `GatewayClient`. A gateway that requires a
fresh token refuses every call with a stale one, so nothing changes, and
the provider reports `ObservationError::Authentication` without state.
That variant carries no gateway text, so it can't echo the token. A new
client with the fresh token then succeeds, as the next command's
provider process would; a `GatewayClient` keeps its client for the
process's lifetime.

No test changes a variable's value between commands. That a refreshed
token takes effect on the next command follows from these tests and
`an_existing_issuers_token_reaches_gateway_only_runs`, which resolves
`tokenEnv` into OpenTofu's environment on each command.

### Three agents on one in-cluster route


`three_agents_on_a_cluster_gateway_share_one_service_registration_with_their_own_rules`
compiles `examples/kubernetes/external-gateway.yaml` and
`examples/openshift/external-gateway.yaml` with the provider endpoint
set to `http://qwen.models.svc.cluster.local:8000/v1`. It checks:

- one `openshell_inference` whose server is the Service endpoint with
the example provider's credential, and no `cluster_source`;
- in each of the three sandboxes, an FQDN rule for the Service's host,
port and `/v1/**`, without `allowed_ips` or `cluster_grants`;
- one `fabric_agent` per sandbox, named by that sandbox's `agent.name`,
whose models use the Service as `base_url`;
- the same graph with `spec.sandboxes` reversed.

`examples/kubernetes/managed-development.yaml` keeps its hosted
endpoint, because its explicit policies name it, and is checked only for
agent names. The test reads agent names from each document: `main` in
the external examples, `primary` in managed-development.


`a_cluster_service_endpoint_reads_no_catalog_while_https_and_private_addresses_keep_theirs`
pins the skip that #13063 landed in `endpoint_requests`: an endpoint
that fails `validate_endpoint`, such as plain HTTP to a Service name,
has no catalog request, while an HTTPS endpoint and plain HTTP to
`10.0.0.5` each keep one.

The rule lookup and the expected Service rule endpoints move into
helpers that the single-sandbox test also uses. Its assertions are
unchanged.

## Validation

The tests passed when added. If one fails later, the fix belongs in its
own PR, with that test as its failing test.

- `cargo ci` passed: tools, fmt, clippy, build, test (1606 passed),
schema, bundle, and lifecycle (150 passed), within budget.
- `cargo nextest run -p nemoclaw-sdk -E
'test(/kubernetes_connect|kubernetes_operations|kubernetes_inference|inference_discovery/)'`
and `cargo nextest run -p openshell-provider --lib` pass.
- `cargo test -p nemoclaw-sdk --test integration` on the three new OIDC
tests passes, so both Cargo variables are set under `cargo test` too.
- Each key assertion failed against a temporary change, since reverted.
- OIDC inputs and fixtures: development auth on `ensure`; an existing
auth directory; a receipt already marked ready; `tokenEnv` naming
another variable; the token copied into the state directory; a set
variable in the missing-token test; a missing client TLS Secret; the
stale forward supplying the fresh token; a gateway accepting any token;
a new client with a third token.
- Production mutations: `operations.rs` identifying the `oidc` auth
resource by its first issuer object; `operations.rs` accepting an empty
token; `Mutation::failed` carrying state; no credential on a
registration that several sandboxes share.
- Routing inputs: a second registration, another Service port, a
`cluster_source`, a cluster grant or `allowed_ips` on one sandbox,
agents named after their sandboxes (also for managed-development alone),
another model `base_url`, agent metadata that depends on sandbox order,
no validation skip, rejected private HTTP, and skipped HTTPS.
- On a single-node k3s v1.36.5 cluster (linux_arm64) with Agent Sandbox
v0.5.0, the `live-kind` profile without the kind-only registry test
passed:
`kubernetes_live::the_gateway_installs_authenticates_and_is_removed_keeping_storage`,
`kubernetes_live::on_openshift_the_sandbox_runs_as_the_namespace_uid`,
`kubernetes_live::oidc::a_managed_gateway_accepts_an_existing_issuers_tokens_and_refuses_another_audience`,
and the three `kubernetes_chart` tests. The agent was the Pi image from
v1 CI's `live-images-linux_arm64` artifact for `d33d50647`, imported
into k3s by digest. 6 passed in 82 s.
- Deferred to CI: `cargo ci live-docker`, and `cargo ci live-kind` on
kind including `kubernetes_live::registry`, which `cargo ci` selects
because `openshell-provider` changed. Docker isn't installed on this
host.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
@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 v1 NemoClaw v1 branch labels Oct 23, 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