Commit Graph
38 Commits
Author SHA1 Message Date
Miancheng Lin a83ace8713 refactor(controller): render the release CRDs from the controller chart (#2350)
* refactor(controller): render the release CRDs from the controller chart

The NVKE controller and management-engine no longer share CRDs, so the
nvke-crds subchart only added a helm dependency build step. Render the
three release CRDs from the controller chart's own files/crds and remove
the subchart, its Chart.lock and the build plumbing around it.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* fix(controller): address review of the chart-owned release CRDs

Embed the controller chart file by file, so a stale charts/nvke-crds-*.tgz in
an existing checkout is not embedded and rendered a second time. Point the
generated-CRD check at the generator's fixed output path instead of the
overridable CHART. Keep the .gitignore entries for built chart dependencies and
dist/, which existing checkouts and the CLI build still use.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

---------

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-11-18 15:13:21 -05:00
Mark Stillwell 08d0bcd575 refactor(helm): extract shared NVKE catalog CRDs (#2166)
Extract the shared MachineImage, ClusterRelease and NodePoolRelease definitions into a catalog chart, preserving the NVKE controller’s default installation and ownership. Reuse canonical definitions across Helm, Kustomize, generation and CLI packaging.

Closes #2165

Created with AI assistance

Signed-off-by: Mark Stillwell <mstillwell@nvidia.com>
2026-11-09 16:17:45 +00:00
Aaron Patten 55b2a0029a refactor(dev)!: remove the deprecated CWE_* and NKE_CONTROLLER_* setting names (#2114)
* refactor(dev)!: remove the deprecated CWE_* and NKE_CONTROLLER_* setting names

The controller's development, test and build settings read only their
NVKE_CONTROLLER_* names now. The CWE_* and NKE_CONTROLLER_* aliases,
deprecated since v0.23.0, are gone from the Makefiles, Tiltfiles, hack and
CI scripts, the e2e framework and tests, and the docs. So are CWE_IMAGE
(use CONTROLLER_IMAGE), the cwe_image key in tilt_config.json (use
nvke_controller_image), --cwe-api in get-kubeconfig.sh (use
--controller-api) and the cwe-name input of qualify-e2e.yml (use
controller-name). local-backend-e2e.sh reads LOCAL_NVKE_CONTROLLER_IMAGE
instead of LOCAL_CWE_IMAGE.

BREAKING CHANGE: a value set under an old name, in .env, .env.tilt,
tilt_config.json, a shell profile or a repository variable, is now ignored
without a warning. Rename CWE_X and NKE_CONTROLLER_X to NVKE_CONTROLLER_X,
except CWE_API (use NVKE_CONTROLLER_API_URL) and CWE_IMAGE in
make -C cli images (use CONTROLLER_IMAGE). Rename LOCAL_CWE_IMAGE to
LOCAL_NVKE_CONTROLLER_IMAGE and the cwe_image key to nvke_controller_image.
get-kubeconfig.sh rejects --cwe-api (use --controller-api), and
qualify-e2e.yml has no cwe-name input (use controller-name).

Signed-off-by: Aaron Patten <apatten@nvidia.com>

* ci: fail when a removed controller setting name comes back

make name-check, which the merge gate runs, now also runs
hack/removed-settings-check.py. It fails on any removed CWE_* or
NKE_CONTROLLER_* setting name, LOCAL_CWE_IMAGE, cwe_image, --cwe-api or
cwe-name in a tracked file, so a branch cut before the removal cannot bring
a reader of an old name back. CHANGELOG.md is not scanned, and two
look-alikes that are not controller settings are allowed by file.

Signed-off-by: Aaron Patten <apatten@nvidia.com>

---------

Signed-off-by: Aaron Patten <apatten@nvidia.com>
2026-11-04 12:29:02 -05:00
Dan Budris d6eeda75cc fix(controller): parse tenant kubeconfigs with an allowlist (#2093)
The controller builds tenant API clients from the admin.conf a
control-plane node returns, and from the kubeconfig Secrets it
publishes. Both were parsed with clientcmd.RESTConfigFromKubeConfig,
which honors every kubeconfig field. Parse them with an allowlist:

- A node's admin.conf may set only an https server, inline CA data,
  and an inline client certificate and key. Tenant access publishes
  a kubeconfig rebuilt from those fields, and skips a node that
  returns anything else, as it skips a node that does not answer.
- A published Secret may hold that form, or the SPIRE exec kubeconfig
  whose audience is the cluster name. The exec plugin is limited to
  the SPIRE command, with client-go's plugin allowlist set to match.
  A Secret in any other form fails to load.
- A reused breakglass kubeconfig is rebuilt from the stored breakglass
  certificate and key and admin.conf's server and CA, so only the
  breakglass user carries over.

The gofail tenant API fixture now serves TLS and sets CA data, which
the allowlist requires.

Signed-off-by: dbudris <dbudris@nvidia.com>
2026-11-03 11:12:16 -05:00
Aaron Patten 68c0294c0a refactor(dev): rename the controller's NKE_CONTROLLER_* dev and test settings to NVKE_CONTROLLER_* (#1771)
The NVKE controller's development, test and build settings now use the
NVKE_CONTROLLER_* prefix that AGENTS.md sets for settings that name the
controller. The deployed controller reads none of them.

Where a developer sets a value (Tiltfiles, Makefiles, hack and CI entry
scripts, the e2e, gofail and integration test readers), the old
NKE_CONTROLLER_* name is still read after the new one and before the
existing CWE_* alias. #1399 removes both. Where our own scripts hand a
value to another script, to Tilt or to a test, the writer and the reader
both use only the new name.

Signed-off-by: Aaron Patten <apatten@nvidia.com>
2026-10-21 08:17:38 -07:00
Miancheng Lin 9cd7d0199d feat(controller): exit at startup when the release CRDs are missing (#1230)
* feat(controller): exit at startup when the release CRDs are missing

The worker checks that MachineImage, ClusterRelease and NodePoolRelease are
installed before it serves anything, and exits 1 naming the kind that is not.
There is no retry: every path that starts CWE installs the CRDs first.

A release that a cluster selects but the site has not applied is not gated. It
fails at provisioning time, as it did before.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* fix(controller): use the NVKE name for the CRD probe

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

---------

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-10-19 16:02:04 +00:00
Terry Howe 6e8871aa40 feat!: make the management namespace configurable and default it to nvke-system (#1698)
* feat(controller): make the management namespace configurable

The shared management-plane namespace was the compile-time constant
constants.NamespaceNVKESystem. It is now the nke-controller-config key
managementNamespace, read through config.Config.ManagementNamespaceOrDefault
and threaded to what addresses that namespace: the tenant-access publish and
Secret-reconcile paths, the nke-rbac read, the CAPI cluster and machine
activities, failure-domain discovery, the Teleport token controller, the OIDC
rollout operation and the Secret cache the manager builds.

An unset key resolves to nke-system, which is what a config.yaml written before
the key existed decodes to, so a controller upgrade alone never moves a site.
The old constant is renamed LegacyManagementNamespace to say which of the two
it is.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* feat(chart): default the management namespace to nvke-system

nvkeSystemNamespace.name is new and defaults to nvke-system. One helper,
controller.managementNamespace, feeds the Namespace object, the nke-rbac
ConfigMap, the Role and RoleBinding scoped to it and the managementNamespace
key the controller reads, so the grant and the namespace it covers cannot
drift apart.

This moves the default a new install gets. The old namespace is not also read,
so a site installed before the value existed must pin nvkeSystemNamespace.name
to nke-system before it upgrades; the chart README says so and
chart-identity-assertions.py now renders that pin and asserts every object and
the controller config land on it.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* feat(cli): read kubeconfig Secrets from a configurable namespace

nvkectl get kubeconfig reads nvke-system and then nke-system, so it finds the
Secret whether or not the site has pinned the old management namespace, and
--namespace names one outright. The error from a miss names the last namespace
searched rather than reporting only the first.

The bootstrap engine installs the chart with default values, so its own
constant moves to nvke-system with the chart default.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* chore: move the greenfield deploy, e2e and docs to nvke-system

The base-config Namespace manifests, Tilt, the e2e lanes, the CI helper scripts
and the user-facing docs all name the management namespace. They describe a new
install, so they follow the chart default. Nothing here is read by a site that
has pinned nke-system.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* fix: address review feedback

fix: address CI failures
Signed-off-by: Terry Howe <thowe@nvidia.com>

* fix: address CI failures

The CLI falls back from nvke-system to nke-system and its not-found error names the last namespace tried, so the smoke test accepts either.

Signed-off-by: Terry Howe <thowe@nvidia.com>

---------

Signed-off-by: Terry Howe <thowe@nvidia.com>
2026-10-16 20:23:38 -04:00
Aaron Patten e19274429e chore(controller): say controller, not CWE, in the settings-rename files (#1653)
Comments, help, log and error text in the files the CWE_* settings rename
owns say "the controller". Every deprecated CWE_* alias statement cites
#1399, which removes them, so `git grep '#1399'` finds every alias site.
No behaviour change.

Signed-off-by: Aaron Patten <apatten@nvidia.com>
2026-10-16 07:58:55 -04:00
Miancheng Lin 3317737e1e refactor(api): rename the OS profile surface to releases (#1612)
* refactor(api): rename the OS profile surface to releases

/osProfiles becomes /releases and nico.osProfile becomes nico.release, so
the REST API uses the release vocabulary the rest of the management plane
already does. Internal db and workflow structs keep their field names.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* refactor(controller): rename the OS profile to the release

Nico payloads gain a release key. os_profile is still written alongside
it and still read as a fallback, so a CWE predating the rename keeps
reading and writing the value through a rolling upgrade or a rollback.
No stored data changes. A later release backfills release from
os_profile, then drops the mirror and the fallback.

The os_profile Prometheus label is deliberately unchanged.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* docs: follow the OS profile rename

The request YAML in the workload-cluster guides named a field the API no
longer accepts, and two troubleshooting entries quoted error text that no
longer appears. The dashboard panel descriptions in operate/observe.md
keep the old wording: the panels and the os_profile metric label they
read are unchanged.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* fix(scripts): read cluster NICo fields from .nico and allow an absent configProfile

The cluster-level orgID, siteID and vpcID live under .nico in the API
response, as the node pool fields already corrected do, so the script
exited before generating anything. configProfile is optional in the same
schema, and requiring it skipped a valid node pool.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

---------

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-10-15 11:56:35 -07:00
Chao aaf0a6b596 fix(controller): escalate stalled soft reboots to hard reboot (#1636)
* fix(controller): escalate stalled soft reboots to hard reboot

Signed-off-by: Chao Chen <chaoch@nvidia.com>
2026-10-14 20:25:08 -07:00
Miancheng Lin 9dcdcbc45b refactor(controller): drop the filesystem OS profile path (#1590)
* refactor(controller): reduce the kubernetes_version migration to its schema change

The backfill populated existing node pools and node sets from OS profile
metadata on disk. It is no longer needed: every database with rows to populate
applied this migration long ago, and the only database that still runs it is a
new one, which has no node pools or node sets.

Dropping it removes the last production caller of internal/utils/osprofiles.go.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* refactor(controller): drop the filesystem OS profile path

OS images and releases are resolved from MachineImage, ClusterRelease and
NodePoolRelease custom resources. The filesystem tree they replaced had no
reader left, so it goes along with the tool that converted it:

- hack/osprofiles-to-crs and its make target, fixture-releases
- internal/utils/osprofiles.go
- the osProfiles trees under test/fixtures/profiles and profiles/example

PROFILES_DIR stays. It still carries config profiles and the runbooks their
hooks reference, which have no custom-resource equivalent.

test/fixtures/releases is now maintained by hand. The converter's --check test
was what held it to the profile tree; with no tree to compare against, the
remaining cover is go test ./internal/clients/nico, which renders bootstrap
user-data from the nodepoolrelease manifests.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

---------

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-10-13 16:48:08 -06:00
Abhay Krishna 8c6e47fc1e feat(controller)!: read settings only from nke-controller-config (#1527)
The controller now takes the 61 settings nke-controller-config carries
from the mounted file only. Each config.Config field that moved trades
its env tag for a controllerconfig tag naming its config.yaml key, and
controllerconfig.LoadStartupConfig fills them at startup from the file
CONTROLLER_CONFIG_PATH names, which is now required. The chart stops
setting the 61 variables, and config.Validate checks only what the
environment still supplies; the file validates the rest when it loads.

With no tracing.endpoint in the file, the controller falls back to the
OTEL_EXPORTER_OTLP_* variables the OpenTelemetry Operator injects, as
it did before. The exporter gets the endpoint as a URL whose scheme
carries the resolved transport, so an injected http:// endpoint cannot
downgrade a secure tracing.endpoint, and an https:// one stays secure.

Host-local runs and the gofail e2e worker start from
hack/local-controller-config.yaml. The e2e helpers that toggled OIDC
and permissive mode on the Deployment now edit nke-controller-config
and restart the controller.

Rolling back across this change needs the chart and the image rolled
back together: an older image under this chart runs on Go defaults for
every setting the chart no longer passes.

Signed-off-by: Abhay Krishna Arunachalam <abhaykrishna@nvidia.com>
2026-10-12 15:17:34 -07:00
Davanum SrinivasandClaude Fable 5.1 3baba6d1b4 ci: give the name check its launch allowlist, and move the stragglers to the new name (#1484)
* chore: move test doubles, examples and stale references to the new name

What the name check still reported outside the Tier 2 identifiers:
synthetic names in tests (nke-site, nke-old, nke-injected, nke-role,
nke-key-1 and friends), registry and path examples in documents and
flag help (registry.example.com/nke, ghcr.io/my-org/nke, ~/dev/nke),
development defaults (DEV_NAME, kind contexts, the promtail job, the
mutagen example), stale references to packages renamed earlier
(internal/nke, nke.NewClient, nkecli, nkeutils), the `nke#1399` issue
shorthand, the CI image tag nke/capd-reboot-controller, the prune
script's package names, and a few comments and messages. The
UpdateNKERBAC rpc's errors now start with the rpc name, which no caller
parses.

Kept: the two synthetic fixture profiles' image URLs, because
osprofiles-to-crs refuses to change a published MachineImage spec; the
salt of the bring-up VMs' default password hash; the legacy installer
path the kubeadm-distro test asserts is absent; the fleet names existing
sites carry. The postgresql chart's description changes with a patch
bump.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* ci: give the name check its launch allowlist

hack/name-check-allowlist.txt grows from two entries to 48, each with
its reason: the Tier 2 identifiers that stay until the post-launch
release (PR4 Kubernetes, PR5 node, PR6 OS image and packages), the
permanent keeps (migration names and texts, the NKEAuth magic and its
package, fleet release and profile names, the identity of existing
sites), the settings-coupled names (the old NGC token secret, the
CODEOWNERS team slugs, the S3 and apt names, the old CLI name), and the
files that keep the bare word (the agent version line the updater
parses, the OIDC upstream CA subject, the Keycloak lab, the two NVCR
workflows whose NGC organisation is named NKE).

With it, NAME_CHECK_MODE=fail make name-check passes on this tree:
5,908 hits, all allowed, every entry in use. The make target keeps
report mode until the launch flips it (W4).

Closes #1483

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

---------

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 19:24:52 -04:00
Davanum SrinivasandClaude Fable 5.1 3e8ca2590f refactor: rename the Go identifiers, packages and fixture paths that carried the old product name (#1453)
After the repository rename and the module-path change (#1449) the tree
still carried the old name where it is ours alone: Go identifiers, two
internal package names, import aliases, fixture and test-data
directories, the e2e deploy overlays and a few deploy and hack scripts.
None of these is a wire protocol, a persisted name or a user-typed
value, so they change now, before the repository goes public, without a
migration.

Identifiers change as tokens, through a go/scanner pass, and in comments
only on word boundaries, so every string value stays: NamespaceNVKESystem
is still "nke-system" and the env and json struct tags keep their keys.
Generated files are untouched and regenerate identically. The packages
controller/internal/nkerbac and controller/test/e2e/internal/nke move
with their import paths; the e2e deploy overlays, the nke-deploy.yaml
files, deploy/nke-deploy.sh, deploy/lib/nke-deploy-items.py and the two
hack scripts move with every reference; the twelve management-engine
test-data directories move with the test prefixes that select them.

Kept on purpose: the NKECluster types and their schema tests (the CRD
kind), the UpdateNKERBAC rpc names and their tests (from the proto), the
SubjectNKE release subject, agent/pkg/nkeauth and its record magic, and
every nkectl name, which moves with the binary.

Closes #1452

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 16:31:31 -04:00
Davanum SrinivasandClaude Fable 5.1 4409efc29b build: move the Go module paths and repository URLs to dsx-ai-factory/nvke (#1449)
The repository was renamed from dsx-ai-factory/nke to dsx-ai-factory/nvke
on 2026-10-10. Its id is unchanged, so guards, rulesets, environments and
the OIDC subject carried over, and GitHub redirects the old URLs. The
tree still named the old repository where the name is a contract rather
than a URL: the module lines of the 12 Go modules and about 1,700 import
lines, the proto go_package (embedded in node_agent.pb.go, regenerated
here), both THIRD_PARTY_NOTICES.md files (regenerated), the lint
local-prefix and depguard entries, ldflags, the go-licenses ignore lists,
the documented repository URLs and gh commands, and the
ghcr.io/dsx-ai-factory/nke image paths in workflows, the chart default
and the e2e defaults.

Only the organisation and repository segments change. Directories,
identifiers, binary, image, chart, package, label, namespace and
environment variable names, the CODEOWNERS team slugs and CHANGELOG.md
stay as they are.

Closes #1448

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 16:03:26 -04:00
Aaron Patten d131ec29a2 refactor(e2e): rename cwe Go identifiers in the e2e harness to controller (#1406)
Signed-off-by: Aaron Patten <apatten@nvidia.com>
2026-10-09 10:48:50 -06:00
Aaron Patten 418ed5c55c chore(e2e): say controller, not CWE, in the e2e harness, CI and Tilt (#1394)
Signed-off-by: Aaron Patten <apatten@nvidia.com>
2026-10-09 09:44:03 -06:00
Aaron Patten ef21b3d337 refactor(dev): rename the remaining CWE_* developer settings to NKE_CONTROLLER_* (#1389)
The developer settings still named CWE_* are renamed:

- CWE_BIN_NAME (root Makefile) is NKE_CONTROLLER_BIN_NAME.
- CWE_API_URL (controller integration test) is NKE_CONTROLLER_API_URL.
- get-kubeconfig.sh takes --controller-api and NKE_CONTROLLER_API_URL in
  place of --cwe-api and CWE_API.
- The four CWE_GOFAIL_E2E_* settings of e2e-gofail and e2e-tracing are
  NKE_CONTROLLER_GOFAIL_E2E_*, and the gofail lane sets the new names.
- The qualify e2e lane (qualify-e2e.yml) takes a controller-name input
  and reads the NKE_CONTROLLER_NAMESPACE and NKE_CONTROLLER_SERVICE
  repository variables, and exports those names to the suite.

Every old name, the --cwe-api flag and the cwe-name input keep working
until nke#1399 removes them, after the first controller and nkectl GA
releases that include the new names. Every alias site cites nke#1399. A
new name wins, and an empty new name counts as unset. The qualify lane's
resolved-inputs summary says when a deprecated name answered. Defaults
are unchanged.

The URL and environment fallbacks and their tests sit in files without the
integration_test or gofail build tag, so the unit test lane runs them.

Signed-off-by: Aaron Patten <apatten@nvidia.com>
2026-10-09 11:04:41 -04:00
pbikki 97c6dee071 feat(controller)!: add node labels and taints to the API schema (#1306)
Support adding nodelabels and taints in API. This change covers the OpenAPI schema, the generated API types, the database schema and migration, and the create and read handlers that store and return the values. Stored labels and taints are not applied to Kubernetes nodes, which matches current behavior. A follow-up MR will apply them. Shipping the schema now lets API consumers, including nkectl, adopt the new fields.

BREAKING CHANGE:

- nodeLabels changes from a list of key=value strings to an object of keys and values on control-plane and node-pool create and read.
- nodeLabels is removed from PATCH UpdateClusterControlPlaneConfig rejects unknown fields, so a patch that still sends controlPlaneConfig.nodeLabels returns 400. The same applies to a node-pool patch that sends nodeLabels or nodeTaints.
2026-10-08 17:00:49 -05:00
Miancheng Lin 0f709ef431 feat(controller): resolve OS profiles from the releases and provide them locally (#1165)
* feat(controller): resolve OS profiles from the releases

CWE reads OS images and first-boot templates from ClusterRelease,
NodePoolRelease and MachineImage resources instead of the files under
PROFILES_DIR. The osProfile names clusters and node pools already store are
release names, so persisted selections keep resolving.

Provisioning and the Kubernetes upgrade both resolve a release by the node's
role through the new internal/machinerelease package: a control-plane node from
a ClusterRelease, a worker from a NodePoolRelease, with no fallback between
them. The upgrade preserves the current image's architecture, variant and
Ubuntu version and never selects a deprecated target. GET /osProfiles keeps its
contract and lists the non-deprecated ClusterRelease names.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* feat(controller): apply the releases in every way CWE runs locally

CWE resolves every OS image from the release resources, so each way of running
it outside a fleet now installs the CRDs and applies the releases: Tilt, `make
run-local`, the gofail e2e framework, the nke-sbom deploy, and the nico-vms and
backend CI lanes. Each reads them from a releases directory, defaulting to the
committed fixtures under test/fixtures/releases. The two Tilt resources are
named machine-engine-crds and machine-engine-releases, after the resources they
install rather than after their consumer.

capnico-create-instance.sh takes the iPXE template from the NodePoolRelease's
MachineImage, under NODEPOOL_RELEASE rather than OS_PROFILE. The OS profile
matrix test lists NodePoolReleases, replacing the fleet-profiles mirror with
test/fixtures/fleet-releases. controller/AGENTS.md, controller/README.md and
the nke-sbom README say where OS images come from now.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

---------

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-10-08 13:06:31 -07:00
Dan BudrisandClaude Opus 5.5 be7b060aa3 feat(temporal): label tenant cluster system namespaces for PSA audit (#738)
* feat(temporal): label tenant cluster system namespaces for PSA audit

## Description

Adds `pod-security.kubernetes.io/enforce=privileged` labels to the tenant system namespaces NKE provisions: `kube-system`, and the CNI's namespace (`tigera-operator` for Calico, `ovn-kubernetes` for OVN-Kubernetes). Calico's other namespace, `calico-system`, is left alone: the tigera operator creates it already labeled `enforce=privileged` and keeps it that way, so NKE has nothing to add there.

`privileged` is the level these namespaces need, not a compromise — kube-proxy (kube-system), the CNI's own components, and node-local-dns's hostPath mount all need host access that even `baseline` forbids. It also matches how [GKE](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/podsecurityadmission) and [EKS](https://aws.github.io/aws-eks-best-practices/security/docs/pods/) treat the same namespaces — both keep `kube-system` unrestricted regardless of what a customer configures.

Closes #739.

**What this actually fixes:** the underlying problem isn't "these namespaces should be restricted" — it's that PodSecurity is enabled but silently has no opinion anywhere, so it *looks* configured while doing nothing. An unlabeled namespace and one explicitly labeled `privileged` behave identically at runtime; the label is what turns "PSA appears present but nothing shows intent" into an explicit, auditable decision. Tenant-owned namespaces are never touched — that stays the tenant's responsibility.

**Where it lives:** folded into the existing `InstallKubeLocalDNS` activity rather than a separate one. It already runs once per cluster right after CNI bring-up and already holds a tenant client for that cluster; with only one level and no configurable mode, a dedicated activity/workflow-step/version-gate wasn't earning its keep.

Also grants the tenant `nke:cwe` ClusterRole scoped `get`/`patch` on exactly the namespaces this touches (`kube-system`, `tigera-operator`, `ovn-kubernetes`) — it had no `namespaces` permission at all, which would have 403'd every call. `hack/chart-rbac-assertions.py` asserts these grants render correctly.

## Testing

Automated:
```bash
make preflight
```
Unit tests cover labeling `kube-system` + the CNI namespace for Calico, OVN-Kubernetes, and an unrecognized plugin (no-op), plus idempotency. They also check that a missing `calico-system` neither fails the activity nor gets created, and that a missing `kube-system`, `tigera-operator` or `ovn-kubernetes` is still an error: each exists before this activity runs.

Manual, against a local Tilt + CAPD tenant cluster (Calico): confirmed `kube-proxy` genuinely fails `baseline` PSA (the reason `privileged` is correct here, not a guess).

Against a real OVN-Kubernetes cluster: manually dispatched the `NICo VMs E2E` workflow (real KVM tenant nodes) against this branch — [run 34896035329](https://github.com/dsx-ai-factory/nke/actions/runs/34896035329), `16 Passed | 0 Failed | 0 Pending | 222 Skipped`, including the entry that sets `cniPlugin: ovn-kubernetes` and validates Open vSwitch.

Also fixed a real bug found in CI: the gofail e2e crash-recovery test's fake tenant API server never advertised `Namespace` as a resource type, so the production activity's real Get/Patch calls failed with a REST-mapper error once it started touching `Namespace` objects. Added `namespaces` to the fixture's discovery document and seeded a `kube-system` object; verified locally with `make e2e-gofail`.

## Checklist
- [x] I am familiar with the [Contributing Guidelines](https://github.com/dsx-ai-factory/nke/blob/main/CONTRIBUTING.md).
- [x] New or existing tests cover these changes.
- [x] The documentation is up to date with these changes.


Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: dbudris <dbudris@nvidia.com>

* refactor(temporal): move PSA namespace labeling into its own activity

InstallKubeLocalDNS goes back to DNS only. LabelSystemNamespacesForPSA
labels kube-system and the CNI namespace enforce=privileged, with the
same behavior as before: kube-system and the CNI namespace must exist,
an unrecognized plugin is a no-op, and calico-system is not waited on.

ProvisionCluster and UpgradeControlPlaneAddons run it right after
InstallKubeLocalDNS, gated by workflow.GetVersion change ID
"psa-label-system-namespaces" so histories from before this change
replay without it. It gets a 1m start-to-close timeout and 10 attempts
(10s initial interval, 1m max), since it is a DB read plus a few
namespace Get/Patch calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: dbudris <dbudris@nvidia.com>

---------

Signed-off-by: dbudris <dbudris@nvidia.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 14:49:54 -04:00
vwilson-nvidia 37cd328428 feat(controller): pin node agent security profile per node (#1093)
- Persist each node's SPIRE attestation method, external mTLS, and TLS/JWT settings at creation.
- Use the pinned profile for bootstrap, reconciliation, and agent connections.
- Support mixed TPM and DSX IMDS nodes in the local Tilt setup.

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>
2026-09-29 20:35:08 +00:00
vwilson-nvidia 68457cf8af feat(controller): add DSX IMDS SPIRE attestation (#974)
- configure node-agent SPIRE attestation at deployment time
- render DSX IMDS plugin settings in CAPI bootstrap data
- reconcile Nico SPIFFE entries using primary DPU machine IDs
- group node-agent transport and attestation configuration

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>
2026-09-28 15:29:18 -04:00
Davanum Srinivas 2ab60c7f6b refactor: move the module path to github.com/dsx-ai-factory/nke (#896)
* refactor: move the module path to github.com/dsx-ai-factory/nke

All nine modules still declared github.com/NVIDIA/nke after the org
move, so the two documented consumer go get lines resolved only through
GitHub's org-rename redirect.

1391 occurrences across 593 files, plus two lines in vendor/modules.txt.
Replaced by exact string, never by pattern: github.com/NVIDIA/nke is
never a prefix of anything else here, and the three other NVIDIA modules
this repository depends on -- ncx-infra-controller-rest,
infra-controller, and a bare github.com/NVIDIA/ in a GOPRIVATE pattern
-- are untouched.

The generated proto could not be renamed by substitution and was
regenerated. node_agent.pb.go embeds go_package in a length-prefixed
descriptor, so the length byte changes with the string: 0x2d to 0x35.
check-protos caught it. THIRD_PARTY_NOTICES.md for the root and agent
were regenerated too.

Verified: GOPROXY=off make build links all six binaries,
work-check-offline reports vendor consistent with every module, and
agent, cli, controller, controller/api, controller/nico-sim,
controller/hack/capd-reboot-controller, os-image and
cluster-api-provider-provisioned all pass through make.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* fix: catch up two things the module-path rename missed

workspace: controller/go.mod's require block and vendor/modules.txt
still had the two local requires (agent, controller/api) at their old
sort position. Ran make work-sync to re-sort both under their new
github.com/dsx-ai-factory/nke path.

lint: cli/.golangci.yml and os-image/.golangci.yml pin gci's local
group to prefix(github.com/NVIDIA/), which no longer matches the
renamed local imports -- gci moved them into the third-party group
and flagged every file that imports across modules. Repointed both at
prefix(github.com/dsx-ai-factory/nke), the same scope goimports uses
in controller/.golangci.yml. No source file needed reformatting: the
import order was already correct for a config that recognized the new
path.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

---------

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
2026-09-20 16:52:23 -04:00
Miancheng Lin b7e39a7ba7 refactor(controller): fully decouple from flat legacy provider fields (#668)
This fully decouples the controller from the legacy flat provider columns. Every read
of a cluster, node pool, node set, node or control-plane spec now goes through the
nested nico/capi payload, and nothing derives, copies from, or falls back to the
flat columns any more.

The writes stay, because the old binary still needs them. Set* mirrors the payload
onto the flat columns exactly as it does on main.

The reason is that the previous release still carries SyncProviderFields, which rebuilds
the nested payload from the flat columns on every write. So during a rolling upgrade,
where both versions run against the same database, and on any rollback, the old binary
reads a row this release wrote and reconstructs the payload out of those columns. Keep
writing them and it reconstructs a correct payload; leave them empty and it reconstructs
an empty one, destroying the row's provider data. Continuing to write them is what makes
this release backward compatible.

After this lands the columns are inert: still populated, read by nobody, and ready to
be deleted.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-09-16 17:48:33 +00:00
Ryan Bever 5af7334722 refactor: remove obsolete Forge integration remnants (#603)
Signed-off-by: Ryan Bever <rbever@nvidia.com>
2026-09-10 18:15:16 +00:00
Davanum Srinivas 8db9c225f9 test(gofail): seed the worker fixture in one transaction (#518)
The worker is running before the seed, and its node-pool controller
deletes any non-current node set with no nodes. The seeded set was
committed on its own, so the node insert could hit
fk_nodes_node_set_id. seedTeardownScenario already seeds this way.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
2026-09-05 09:09:20 -04:00
vwilson-nvidia 8f464ab049 refactor(controller): remove legacy site reconciliation sweep (#404)
* refactor(controller): remove legacy site reconciliation sweep

- Remove the legacy site-based controller manager and polling scheduler.

- Remove the Forge CAPI migration and legacy CAPI namespace migration paths.

- Drop the unused CAPI adoption metrics tied to the removed migration path.

- Remove the next_reconcile_due model/query surface from site persistence while leaving physical site table cleanup to the later site-object removal.

- Rename the remaining retry interval config to the node scheduler-owned NODE_SCHEDULING_RETRY_INTERVAL.

- Harden make capd-up so the local CAPD node image must include bundle server/index args required by node-agent bootstrap.

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>

* refactor(controller): make CAPI provisioning always on

- Remove CAPI and Forge-CAPI feature flag config/env wiring
- Always register CAPI and CAPNICo controller-runtime controllers
- Route NICo node provisioning through CAPI and remove the direct Forge scheduler fallback
- Install CAPI and CAPNICo CRDs in e2e harnesses that start the worker

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>

---------

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>
2026-09-03 13:08:24 -06:00
vwilson-nvidia ff8b919b46 refactor(api)!: remove legacy site APIs (#439)
Remove the legacy CWE site and VIP allocation API surface, along with the server and database query layers that backed it.

Update tests, e2e fixtures, Tilt resources, and local helper scripts so cluster creation no longer tries to register default or mock sites before submitting cluster requests.

BREAKING CHANGE: The /sites and /vipAllocations API endpoints are removed.

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>
2026-09-03 10:08:46 -06:00
Terry Howe 6cf2150d3c test: seed the gofail teardown fixture in one transaction (#372)
SeedTeardownScenario inserted the site, cluster, node pool, node set and
nodes as five separate statements against a database the CWE worker is
already reconciling. Between CreateNodeSet and CreateNode the node set has
no nodes, and nodepool.Controller deletes non-current node sets that have
none -- so a reconcile landing in that window drops the node set and the
following CreateNode fails with fk_nodes_node_set_id.

Wrap the whole fixture in a single transaction so the childless node set is
never visible outside it.

Signed-off-by: Terry Howe <thowe@nvidia.com>
2026-08-28 13:42:03 -04:00
Terry Howe 43614bec44 chore: remove internal ticket references from comments (#324)
Signed-off-by: Terry Howe <thowe@nvidia.com>
2026-08-26 17:35:56 -04:00
Alexander Greene 0cf73e93b6 feat: adapt node-local-dns for OVN prefer-local cluster DNS (#211)
* feat: adapt node-local-dns for OVN prefer-local cluster DNS

Run node-local-dns on the pod network and share kube-dns endpoints
with CoreDNS via dns-role so OVN can prefer the local cache with
fallback. Re-apply after kubeadm addon upgrades.

* fix(controller): wait for Ready cluster-dns pods before rewriting kube-dns

The kube-dns selector must not flip to dns-role=cluster-dns until a Ready
pod already has that label, otherwise kube-dns can have zero endpoints
while CoreDNS still rolls and node-local-dns is not Ready.

* fix: resolve unparam issue

* test(controller): stub tenant kube API for gofail addon-upgrade recovery

UpgradeControlPlaneAddons now re-applies kube-local DNS after the
kubeadm runbook, so the crash-recovery e2e needs GetKubeconfig and a
narrow apiserver fixture instead of the dummy 127.0.0.1:1 kubeconfig.

* chore: run make work-sync
2026-08-25 16:11:42 -04:00
Davanum Srinivas 19619fdd97 test(gofail): run the fault-injection suite (#248)
* test(gofail): give the suite a real API server

The gofail suite has not run in CI, and it does not pass locally either. The
worker exits at startup:

  Failed to create Kubernetes controller manager: failed to determine if
  *v1.Secret is namespaced: Get "http://127.0.0.1:1/api": connection refused

The framework supplies that unreachable address on purpose, because the tested
workflows never call the Kubernetes API. That was enough once. It is not now:
NewRuntimeManager configures a per-namespace cache for corev1.Secret, and a
Cache.ByObject entry makes controller-runtime resolve the REST mapping eagerly
instead of lazily.

WriteKubeconfig now starts envtest and points the worker at it. That is a real
kube-apiserver and etcd running as two local binaries, not a cluster: no kubelet,
no scheduler, no controller manager.

The suite skips with a clear message when KUBEBUILDER_ASSETS is unset, so running
the tests directly still explains itself. make e2e-gofail resolves it with
setup-envtest.

Vendor grows by 86 files across 5 package trees, all from modules already in the
graph, so no go.mod changes.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* ci(gofail): run the fault-injection suite

Nothing ran this suite. It is the largest body of test code here that never
executed, and the only thing that exercises cmd/worker as a built binary.

PostgreSQL comes from the runner image rather than a service container, which is
what NVIDIA/infra-controller does. Starting the packaged cluster also avoids
initdb, which the framework runs only when no DSN is set and which refuses to run
as root. Durability is off because the database dies with the runner.

A separate workflow rather than another job in an existing lane. Nothing else
needs PostgreSQL, the envtest binaries or a Temporal dev server, so folding it in
would slow every job there for setup none of them use.

Not wired into merge-gate.yml yet. It takes about six minutes against a gate
whose wall clock is about nine, so it would not extend the critical path, but a
fault-injection suite deserves a record before anything is blocked on it.

Measured on Linux in a plain checkout: both scenarios pass, 158s and 188s, 346s
for the package.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* ci(gofail): add the suite to the merge gate

Runs on every pull request and blocks a merge when it fails.

About six minutes, against a gate whose wall clock is about nine, set by
golangci-lint (controller), so it does not extend the critical path.

It is the only gate member that needs a database and the only one that runs a
built binary rather than a package, so it is the most likely to fail for
environmental reasons rather than a real regression.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* test(gofail): set the controller-runtime logger before envtest

envtest starting printed "log.SetLogger(...) was never called" with a stack
trace pointing at StartAPIServer. controller-runtime holds one global logger,
and nothing had set it. NewRuntimeManager sets one, but that runs in the worker
process rather than the test process.

The setter is named for what it does. The logger is process-wide and covers
everything logging through controller-runtime, not only envtest.

Routed to slog rather than discarded, so the diagnostics survive. make
e2e-gofail runs go test -v, so they show up on a failure.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* ci(gofail): time each phase, and cache what is slow

The lane takes 631s. 258s of that is before the first test runs, and it is
silent, so there is nothing to optimise against. Two changes: make the time
visible, then cache the two things that plausibly explain it.

Instrumentation. `make e2e-gofail` now prints elapsed and cumulative seconds
after install-tools, envtest-assets, gofail-enable, build-worker and run-tests.
The next run says where the 258s goes instead of leaving it to inference.

Caching. setup-go's cache is off here on purpose: it only SAVES on a key miss,
so once go.sum settles it restores a stale entry and never refreshes. This lane's
expensive artefact is a `-tags gofail` build, which shares no cache entries with
the untagged builds every other lane does, so it would never be written back.
Both caches below use a unique key with restore-keys, so they always save.

The envtest store is pinned to controller/.go/envtest with --bin-dir rather than
left at setup-envtest's platform-dependent default, so the cache path is exact.
Measured locally: 160 MB, 8.8s to fetch cold, 0.011s once the store is warm.

Measurement first, conclusions after. The golangci-lint caching attempt in #241
looked obviously right and measured slower, so this lands with the timing output
that will confirm or kill it.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

---------

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
2026-08-22 13:15:46 -04:00
Davanum Srinivas a3c868615c fix(license): normalise SPDX headers to Apache-2.0, and assert it (#197)
* chore(license): normalise SPDX headers to Apache-2.0 [machine generated]

MACHINE GENERATED. Every added line in this commit is
`SPDX-License-Identifier: Apache-2.0` and nothing else; every removed line is
the identifier it replaces, or the notice paragraph that followed it. Verified:
0 added lines are anything other than that SPDX line.

829 files. The repository ships Apache-2.0 -- LICENSE says so and GitHub
reports it -- while 676 Go files and 153 others declared a different
identifier, followed by a notice that contradicted it.

The copyright line, the comment style and the indentation are left alone. Files
carrying the short form, two SPDX lines with no notice paragraph, have the
identifier swapped and nothing else.

Markdown is excluded: there the identifier appears in prose describing the
mismatch rather than in a header, so rewriting it would turn the sentence into
a tautology. That file is handled in the next commit.

Three shapes needed care, and each is worth knowing about if this is ever
repeated. controller/api/prepend-license.go carries the block inside a Go raw
string, so the paragraph's last line ends with a backtick; the closing
delimiter is carried back onto the SPDX line rather than dropped, or the string
would be left unterminated. Two shell scripts under controller/hack/ word the
final sentence differently, so matching on the common ending alone misses them.
And controller/.golangci.yml prefixes each line with "# //", which has to be
stripped before the paragraph text can be recognised.

The templates that produce these headers are rewritten here too, so this commit
is self-consistent: the five addlicense boilerplates, the five goheader
templates in .golangci.yml, and the block in prepend-license.go. Every header
in the tree now names the same identifier.

Review the next commit. This one is a substitution.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

* fix(license): one header template, and a check that reads it

The previous commit fixed the headers. This one stops them drifting again, and
is the part worth reviewing.

Nothing here could catch a header that named the wrong licence. addlicense only
ADDS a header to a file that has none; it never rewrites one already present.
So `make file-license-check` runs addlicense, finds every file already stamped,
produces no diff, and passes -- whatever the header says. agent/ is the proof:
its template and its check have both been correct all along, and six of its
files disagreed with them.

Three mechanisms defined the header and could disagree with each other: an
addlicense boilerplate per module, a goheader template in five .golangci.yml
files, and a hardcoded block in controller/api/prepend-license.go that stamps
generated API code. They are now one file, hack/license-header.tmpl, and every
module reads it.

make license-header-check replaces the per-module matrix and asserts two things
rather than one: that a header exists, and that it names Apache-2.0. The second
assertion is what this repository never had. Verified by planting a different
identifier in a file and confirming the check fails and names it.

Modules resolve the template through `git rev-parse --show-toplevel`, not a
relative path. A relative ../hack path silently changes meaning when a module
moves, which is how cli/ broke when it moved out of controller/.

The file set is the union of what the per-module targets already ignored, so
this covers exactly the files stamped today. 120 files carry no header at all
-- generated output, testdata, fixtures, build tooling, three .github files --
and widening the set to reach them is a separate change. Mixing headers that
are WRONG with headers that are MISSING would hide both.

Dockerfiles stay out: addlicense keys off the file extension and gives
Dockerfile.proto C-style // comments, which Docker cannot parse.

AGENTS.md's licence-header rule now describes the current state: one identifier,
added by `make license` rather than copied from a neighbouring file. The ban on
relicensing as a side effect of unrelated work stays.

The header-check job is renamed from "License headers (<module>)" to "License
headers". The merge gate calls this workflow whole rather than naming its jobs,
and the branch ruleset requires only `gate` and `DCO`, so no required check
changes name.

Verified: GOPROXY=off make build links all five binaries with no credentials;
golangci-lint goheader reports 0 issues on cli and controller; `make license`
is a no-op in all five modules; make license-header-check passes over 828 files
and fails on a planted mismatched header.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

stderr is not captured when reading addlicense's output. addlicense prints the
offending paths to stdout, while `go run` writes "go: downloading ..." on a
cold module cache and "exit status 1" on failure -- both to stderr. Folding the
two together reports a module download as a file with no header, which is how
the first CI run of this check failed while passing on a machine whose cache
was already warm. Reproduced locally against an empty GOMODCACHE.

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>

---------

Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
2026-08-18 20:42:45 -04:00
nhammernik fd95309ade chore: re-sync cwe from gitlab (#136) 2026-08-15 19:32:05 -04:00
jgriffith 2dbf7bfdd1 Point controller at the in-tree agent module.
Replace the VPN-gated gitlab node-agent dependency with a local
replace to github.com/NVIDIA/nke/agent, and drop call sites for
removed RPCs (InstallCNIPlugin, GetNodeInfo) in favor of in-init CNI
and the dedicated rewrite / idempotent kube-vip restore status paths.
2026-08-10 08:42:48 -06:00
jgriffith 18e42b26e6 Rename node-agent to agent.
Drop the redundant "node-" prefix so the module path is
github.com/NVIDIA/nke/agent rather than stuttering as nke/nke-agent.
Controller still consumes the published gitlab node-agent module until a
follow-up cutover.
2026-08-10 08:33:04 -06:00
nhammernik 7ce92b69ce feat: import cloud-workflow-engine (#7) 2026-08-05 16:25:10 -06:00