apiAuth in nvke-controller-config becomes the only place the controller reads its API authentication configuration from. This is the breaking second step of phase 2. - The controller refuses to start when AUTH_CONFIG_PATH is set, naming apiAuth as the replacement, and passes authn.Setup only the apiAuth section. authn.Load and Options.ConfigPath stay for management-engine's --auth-config. - The chart no longer renders or mounts nvke-auth-config. It refuses apiAuth.configMap and an AUTH_CONFIG_PATH env entry by name, and a caBundlePath into the old mount, pointing at jwks.caBundle. - apiAuth.permissive requires apiAuth.enabled, in the chart and at startup. Tilt passes it only with authentication on. - controllerconfig, which decodes the apiAuth section, gets the decoder-strictness tests. - nvkectl and the token scripts keep their fallback to the authentication ConfigMap for controllers from before this change. - The e2e suite reads the enforcement mode from apiAuth alone. - The pod template carries a checksum of nvke-controller-config, so an upgrade that changes apiAuth rolls the controller without Reloader, which the NVKE stack does not install. - API authorization (#2125) counts authentication as on exactly when apiAuth.enabled is. BREAKING CHANGE: AUTH_CONFIG_PATH and apiAuth.configMap are removed. A site that managed its own authentication ConfigMap moves audiences and issuers into apiAuth.config, CA bundles into jwks.caBundle, and sets apiAuth.enabled. apiAuth.permissive without apiAuth.enabled is refused. nvkectl older than the previous step gets 401. Signed-off-by: Abhay Krishna Arunachalam <abhaykrishna@nvidia.com>
21 KiB
API authentication in nvke-controller-config: design
Status: phase 1 is implemented. A chart install and released
nvkectlneed no changes, but theapiAuthsection is required, so a hand-writtennvke-controller-configmust now carry one (see Startup behaviour). Phase 2, which retires the old path, ships in two steps; both are implemented. Step 2 is breaking:apiAuthinnvke-controller-configis now the controller's only source, and a site that managed its own authentication ConfigMap moves it intoapiAuth.config(see Step 2).Names: the chart names the settings ConfigMap
nvke-controller-configby default, and until step 2 named the authentication ConfigMapnvke-auth-config; an install that predates the chart's move to nvke names pinsnke-controller-config, and pinnednke-auth-configuntil step 2 removed the value. Below,nvke-controller-configmeans the settings ConfigMap whatever its name. Where this document describes behaviour from before that move,nke-auth-configis the authentication ConfigMap, and the Tilt scaffolding it names is nowcontroller/deploy/k8s/nvke-auth-dev.yaml.
Problem
The controller reads every setting from nvke-controller-config at startup except one: the NVKE API authentication configuration. That is still its own file, auth.yaml in the nke-auth-config ConfigMap, found through the AUTH_CONFIG_PATH environment variable and loaded by auth/authn. So the controller has two configuration files, two loaders and two ways to be misconfigured.
The authentication configuration was left out of the move to nvke-controller-config deliberately, because folding it in raises two questions a rename does not answer:
- How authentication is turned off. Today an unset
AUTH_CONFIG_PATHmeans off, a valid file means on, and a broken file stops the controller rather than letting it start unprotected.nvke-controller-configis always mounted, so it can never be absent. The off switch has to become explicit. - Who owns the schema.
auth.yamlis a separately designed feature with its own types, strict loader andapiVersion/kindheader. Folding it in must not leave a second copy of its rules.
How it is used today
The chart has two modes, both selected by apiAuth.configMap.create:
| Mode | Who uses it | What happens |
|---|---|---|
create: true |
Every fleet site and the operator guide | The chart renders apiAuth.config into nke-auth-config, mounts it at /etc/nke/auth and sets AUTH_CONFIG_PATH=/etc/nke/auth/auth.yaml. |
create: false |
Tilt (controller/deploy/k8s/nvke-auth-dev.yaml) and the CAPD and CAPNICo e2e deploy paths (nvke-auth-dev items) |
The chart mounts a ConfigMap it does not own and sets AUTH_CONFIG_PATH. |
Every fleet site has the same shape: one issuer, local-kubernetes, the management cluster's own ServiceAccount issuer, with the projected ServiceAccount CA and token as its caBundlePath and bearerTokenPath, serviceAccounts admission and one audience. No site uses apiAuth.configMap.extraFiles.
Outside the controller, these read the configuration:
nvkectl(cli/internal/auth/source.go) treats a missingnke-auth-configas "authentication off" and mints a ServiceAccount token foraudiences[0]of itsauth.yamlotherwise.- The e2e suite's token helper (
controller/test/e2e/internal/authtoken) reads the audiences fromnke-auth-configthe same way. - The e2e suite's
detectAuthnEnforcement(controller/test/e2e/authn_test.go) treats a missingAUTH_CONFIG_PATHon the controller Deployment as "authentication off", and readspermissiveModefromnvke-controller-configotherwise. hack/nvke-token.shandhack/nvke-auth-demo.shreadAUTH_CONFIG_PATHfrom the Deployment the same way.
Goals
- The controller reads the authentication configuration from
nvke-controller-configwhen the chart renders it, through the same startup load as every other setting. auth/authnkeeps the only definition of the schema and its rules.- Turning authentication off is an explicit setting, and a configuration that is filled in but turned off is an error, not a silent "off".
- A configuration that is set but invalid still stops the controller at startup.
- No operator changes their chart values, and released
nvkectlkeeps working.
Non-goals (phase 1)
- Retiring
AUTH_CONFIG_PATHor the external-ConfigMap mode (create: false). - Moving
nvkectloffnke-auth-config. - Moving
permissiveModeunderapiAuth. It governs the legacy file too, which is read whileapiAuth.enabledisfalse, so it cannot live in a section that is turned off. - An inline CA bundle.
caBundlePathkeeps working, andextraFileskeep landing in/etc/nke/auth.
Design
Schema
nvke-controller-config gains an apiAuth section. Its audiences and issuers are auth/authn's existing Config fields, unchanged; enabled is new.
permissiveMode: false # unchanged, top level
apiAuth:
enabled: true
audiences: [nke-site-example]
issuers:
- name: local-kubernetes
issuer: https://kubernetes.default.svc.cluster.local
jwks:
uri: https://kubernetes.default.svc/openid/v1/jwks
caBundlePath: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearerTokenPath: /var/run/secrets/kubernetes.io/serviceaccount/token
algorithms: [RS256]
admit:
serviceAccounts:
- namespace: nke-clients
The embedded section has no apiVersion or kind, like every other section of the file. The standalone auth.yaml keeps requiring both.
Startup behaviour
apiAuth.enabled |
AUTH_CONFIG_PATH |
The controller |
|---|---|---|
false, audiences and issuers empty |
unset | Runs with authentication off, as today. |
false, audiences and issuers empty |
set | Loads the file at AUTH_CONFIG_PATH, as today. This is the external-ConfigMap mode. |
false, audiences or issuers present |
either | Refuses to start: the configuration is filled in but turned off. |
true |
unset | Validates apiAuth with auth/authn's rules and enables authentication. A validation failure stops the controller. |
true |
set | Refuses to start and names both sources, rather than choosing one. |
Permissive mode comes from permissiveMode in every case, as today. The startup log line that reports the mode also names its source: nvke-controller-config or the AUTH_CONFIG_PATH file.
The apiAuth section itself is required: a config.yaml without it, or with apiAuth: null, refuses to start, so a missing section never reads as "off" and turning authentication off takes an explicit enabled: false, which the chart always renders.
auth/authn
- One exported validation entry point runs everything
Loadchecks today apart from the file header:Config.Validateplus the "every issuer needsadmit" check, which today lives only inLoad.Loadcalls it too, so both paths enforce identical rules. Setuptakes either a path (the legacy file) or an already-validated*Config. Everything after loading, from key fetching to the middleware, is unchanged.
controllerconfig
ConfiggainsAPIAuth, holdingEnabled,AudiencesandIssuers.Issuersis a list ofauthn.Issuer, so the issuer schema stays defined once. The strict loader parses the section with the rest of the file.validateapplies the table above: withenabled: false,audiencesandissuersmust be empty; withenabled: true, it callsauth/authn's validation and prefixes errors withapiAuth:.LoadStartupConfig, which sees both the file and the environment, refusesapiAuth.enabledtogether withAUTH_CONFIG_PATH.cmd/workerpasses the section toauthn.Setupwhen it is enabled, and the path otherwise.hack/local-controller-config.yamlgainsapiAuth: {enabled: false, audiences: [], issuers: []}.
Chart
The values are unchanged. What the chart renders depends on the mode:
| Values | Rendered | The controller reads |
|---|---|---|
apiAuth.enabled: false |
apiAuth: {enabled: false, audiences: [], issuers: []}; no AUTH_CONFIG_PATH |
nothing: authentication off |
enabled: true, configMap.create: true |
apiAuth with enabled: true and apiAuth.config's audiences and issuers; no AUTH_CONFIG_PATH. nke-auth-config is still rendered from the same values and mounted at /etc/nke/auth. |
apiAuth |
enabled: true, configMap.create: false |
apiAuth: {enabled: false, …}; the external ConfigMap mounted and AUTH_CONFIG_PATH set, as today |
the file at AUTH_CONFIG_PATH |
nke-auth-config keeps being rendered in create: true mode for two reasons. nvkectl and the e2e token helper still find it there, and extraFiles still land in /etc/nke/auth for caBundlePath. Both copies come from the same apiAuth.config value, so they cannot disagree. The Reloader annotation already lists both ConfigMaps, and the render-time checks on apiAuth.config and configMap.create are unchanged. AUTH_CONFIG_PATH stays off the chart's list of retired variables, because the external-ConfigMap mode still sets it.
Clients and tooling
detectAuthnEnforcement and both scripts treat authentication as on when either AUTH_CONFIG_PATH is set on the Deployment or apiAuth.enabled is true in nvke-controller-config. Reading both keeps the e2e suite correct against controllers older than this change. nvkectl needs no change in phase 1.
Compatibility and rollout
- Fleet sites keep their values. After the upgrade their controller reads
apiAuthinstead ofAUTH_CONFIG_PATH, with the same issuers, audiences and mode. - Tilt and the CAPNICo e2e path keep the external ConfigMap and the legacy path.
- Rollback is chart and image together, as for #1527. A controller older than this change rejects the unknown
apiAuthkey and does not start, so a mismatched pair fails closed rather than running unauthenticated. - A partial rollback that reverts
nvke-controller-configwhile the new controller keeps running also fails closed, because the olderconfig.yamlhas noapiAuthsection and the controller refuses to start without one.
Testing
auth/authn: the shared validation entry point, including theadmitcheck, andSetupfrom an in-memoryConfig.controllerconfig: a table overenabledand the presence ofaudiencesandissuers, including an absent or null section, which is refused; theAUTH_CONFIG_PATHconflict inLoadStartupConfig; the drift tests extended to the new key.- Chart:
chart-auth-assertions.shchecks thatcreate: truerendersapiAuthand noAUTH_CONFIG_PATH, and thatcreate: falseis unchanged.chart-controller-config-assertions.shchecks thatapiAuthrenders in every mode. - E2E: the CAPD e2e deploy path moves to
create: true, so CI exercises the new path. The authentication document moves into its overlay values. Itsnvke-auth-devitem keeps the ServiceAccounts and RBAC but drops itsnke-auth-configConfigMap, because the chart now renders that ConfigMap. Tilt and the CAPNICo e2e path exercise the legacy one. The pull request's CAPD check does not select the authentication specs, so a full CAPD run is dispatched on the branch before it is marked ready; the local entry point runs Tilt, which stays on the external ConfigMap. - Docs: the operator guide (Secure the NVKE API),
controller/docs/configuring-api-authentication.mdand theAUTH_CONFIG_PATHrow incontroller/AGENTS.md.
Phase 2
Phase 1 left the controller with two sources: apiAuth for a chart-rendered configuration and AUTH_CONFIG_PATH for a ConfigMap managed elsewhere. Phase 2 retires the second, so apiAuth in nvke-controller-config is the only place the controller, nvkectl and the tooling read authentication from.
Constraints
- Released
nvkectlreads only the authentication ConfigMap. Every release up tocli/v0.3.0-rc.2looks upnvke-auth-configornke-auth-configand treats their absence as "authentication off". If the chart stopped rendering that ConfigMap first, those clients would send no token and get 401. So the chart can drop it only after annvkectlthat readsnvke-controller-confighas been released. - No released controller has
apiAuth. Phase 1 is unreleased, so the shape of the section can still change without a deprecation window: anyconfig.yamlthat loads on a released controller has noapiAuthand is refused by this one regardless.
Phase 2 therefore ships as two pull requests.
Step 1: everything reads apiAuth (not breaking)
nvkectl and the tooling read nvke-controller-config first. nvkectl (cli/internal/auth/source.go), the e2e token helper (authtoken.RawConfig) and hack/nvke-token.sh look for the controller's settings ConfigMap, nvke-controller-config then nke-controller-config, in the same namespaces as before. When its apiAuth.enabled is true they mint for apiAuth.audiences[0]. When the section is off or absent they fall back to the authentication ConfigMap, because in the external-ConfigMap mode apiAuth.enabled is false while the controller authenticates through AUTH_CONFIG_PATH. A denied read is handled as before: remembered, and returned only when nothing readable turns authentication on, so a missing grant never reads as "off". nvkectl users need get on the settings ConfigMap as well as the authentication one; a role scoped by resourceNames must add it.
Tilt and the CAPNICo e2e path move onto values, as CAPD did in phase 1. Tilt passes hack/tilt-controller-api-auth-values.yaml, with configMap.create: true and the configuration, whenever NKE_AUTH_ENABLED is true. deploy/k8s/nvke-auth-dev.yaml and the CAPNICo nvke-auth-dev copy keep the namespaces, ServiceAccounts and token-minter RBAC and drop their nvke-auth-config ConfigMap, which the chart now renders. After this nothing in the repository uses configMap.create: false. An existing Tilt cluster has a nvke-auth-config that Tilt applied, which Helm will not adopt: delete it once before the next tilt up.
permissiveMode moves to apiAuth.permissive. The Helm value has always been apiAuth.permissive; only the rendered config.yaml put it at the top level, as a leftover of the move from the PERMISSIVE_MODE variable. It now sits beside the rest of the section. It applies to whichever source configures authentication, so it may be true while apiAuth.enabled is false and AUTH_CONFIG_PATH is set; the rule that an off section must be empty covers audiences and issuers only. A config.yaml that still sets top-level permissiveMode is refused with an error naming apiAuth.permissive, rather than strict decoding's bare "unknown field". The move carries no compatibility window, for the reason under Constraints. The chart refuses permissive inside apiAuth.config, as it refuses enabled, and the retired PERMISSIVE_MODE variable now points at apiAuth.permissive.
Issuers take an inline CA bundle. jwks.caBundle is a PEM bundle carried in the configuration itself, an alternative to caBundlePath. At most one of the two may be set, and a bundle with no PEM certificates is refused at validation, so it fails at startup like every other configuration error. A CA certificate is public, so it needs no Secret, which matches oidc.providers[].caBundle. It is what lets step 2 drop extraFiles: today a private CA has to be a file in /etc/nke/auth, which exists only because nvke-auth-config is mounted there.
Step 2: retire the old path (breaking)
Merged only after a release that includes step 1, and deployed as chart and image together, as for #1527.
AUTH_CONFIG_PATHis retired. The chart refuses it inenv. The controller refuses to start when it is set, so a hand-written Deployment fails closed instead of starting without the authentication it asked for.authn.Load, the file header check andOptions.ConfigPathgo, since the file was their only caller;auth.yaml'sapiVersionandkindgo with them.- The external-ConfigMap mode is removed.
apiAuth.configMap, and with itcreate,nameandextraFiles, is refused by name, as the chart refuses other removed values.apiAuthrenders wheneverapiAuth.enabledis true. nvke-auth-configis no longer rendered, and its volume, mount and Reloader entry go.caBundlePathstays: it is how an issuer names a file the pod already has, such as the projected ServiceAccount CA.apiAuth.permissiverequiresapiAuth.enabled. With one source, permissive with authentication off is a configuration that does nothing, so it is refused.nvkectland the tooling keep their fallback to the authentication ConfigMap, for sites still running a controller from before step 2.
nvkectl older than step 1 sends no token to a controller from step 2 and gets 401. The release notes for step 2 say so; the fix is to upgrade nvkectl.
The implementation adds these details to the outline:
- The chart refuses
apiAuth.configMapas a whole, so a site that pinned onlynameis told to drop it rather than having it ignored. - A
jwks.caBundlePathunder/etc/nke/auth/fails the render and names the inlinejwks.caBundle, because nothing is mounted there any more. A path elsewhere, such as the projected ServiceAccount CA or a file mounted through.Values.volumes, is accepted as before. apiAuth.configwithoutapiAuth.enabled, andapiAuth.enabledwithoutapiAuth.config, each fail the render, rather than one being silently ignored.- The controller refuses only a non-empty
AUTH_CONFIG_PATH. An empty value has always meant unset, so it still starts. - The e2e suite's
detectAuthnEnforcementreads onlyapiAuth.enabledandapiAuth.permissivefromnvke-controller-config; it no longer looks at the Deployment's environment.hack/nvke-auth-demo.shno longer requiresnvke-auth-configto exist.
A site upgrading to step 2 that set apiAuth.configMap.create: false moves its configuration into apiAuth.config (audiences and issuers only, without apiVersion and kind), moves any CA bundle from extraFiles or its own ConfigMap into jwks.caBundle, sets apiAuth.enabled: true and removes apiAuth.configMap. A site with apiAuth.permissive: true and enabled: false drops permissive. Helm deletes the chart-owned nvke-auth-config on the upgrade.
Testing
auth/authn:caBundlevalidation (both set, not PEM) and a JWKS fetch trusting an inline bundle.controllerconfig:apiAuth.permissivewhile off and on, and the refusal of top-levelpermissiveMode; the drift tests mapPERMISSIVE_MODEto the new key.- Chart:
chart-auth-assertions.shchecksapiAuth.permissivein both modes, the absence of the top-level key, the refusal ofpermissiveinapiAuth.config, and an inline bundle rendered withoutextraFiles. nvkectlandauthtoken: the lookup order, the fallback when the section is off or absent, a pinned settings name, and denied reads.- E2E: CAPD and CAPNICo both run on the chart-rendered configuration; the authentication specs read
apiAuth.permissive. - Step 2:
controllerconfigrefuses a setAUTH_CONFIG_PATHand starts with an empty one, and refusespermissivewhile off;chart-auth-assertions.shchecks the refusals ofapiAuth.configMap, ofAUTH_CONFIG_PATHinenv, ofconfigandenabledwithout each other, ofpermissivewithoutenabledand of acaBundlePathunder/etc/nke/auth/, and that nothing butnvke-controller-configis rendered or mounted for authentication.
Alternatives considered
authn.Loadreads the section out ofconfig.yaml. One loader, butauth/authnwould have to know the controller configuration's layout, and the file would be parsed twice.- The chart renders
auth.yamlfromnvke-controller-config's values and the controller is left alone. The controller would still read two files, which is the problem this solves. - Presence of issuers as the on switch. Fewer keys, but an accidentally emptied list would turn authentication off instead of failing, against the fail-closed contract.
- Move
permissiveModeunderapiAuthnow. Tidier, but the legacy file, read whileapiAuth.enabledisfalse, would then take its mode from a section that is turned off. Moving it would also break the e2e suite'sSetPermissiveMode, which writes the top-level key, on controllers older than this change. Phase 2 moves it anyway: allowingpermissivein a section that is off answers the first point, and the e2e suite runs against the controller it ships with. - Keep
permissiveModeat the top level in phase 2. No migration, butconfig.yamlwould keep a shape that differs from the values, and the move only gets more expensive onceapiAuthis released.