-
Notifications
You must be signed in to change notification settings - Fork 44
feat(nvsnap): shared-token authentication for the agent API #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
balajinvda
wants to merge
13
commits into
main
Choose a base branch
from
nvsnap-agent-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
744b617
fix(nvsnap): confine agent path construction to its own directories
balaji-g 7a59a4d
test(nvsnap): fold path-safety tests into pathsafe_test.go
balaji-g c49d23c
feat(nvsnap): shared-token authentication for the agent API (#486)
balaji-g 2dfd2d7
feat(nvsnap): send and require the agent token end to end (#486)
balaji-g 28ea9be
fix(nvsnap): address review on agent authentication (#486)
balaji-g 0f368ff
feat(nvsnap): make pod networking a supported mode for the agent (#561)
balajinvda 8185411
Merge origin/main into nvsnap-agent-auth
balaji-g 6c34a38
build(nvsnap): drop the k8s.io/utils/ptr import from the webhook
balaji-g 8827b43
Merge origin/main into nvsnap-agent-auth (#472 landed)
balaji-g d2b1ad4
fix(nvsnap): send the agent token from checkpoint.sh
balaji-g 1a087a9
fix(nvsnap): send the agent token from every API caller (#734)
balaji-g 3344047
fix(nvsnap): send the agent token from nvsnap-server (#736)
balaji-g cbc318c
fix(nvsnap): close token-leak and token-reach gaps in agent auth (#736)
balaji-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/compute-plane-services/nvsnap/deploy/helm/nvsnap/templates/agent-token-secret.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| {{- if .Values.agent.auth.enabled }} | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Shared bearer token for the agent HTTP API (GH #486). | ||
| # | ||
| # The agent API is the control surface of a privileged process and the | ||
| # DaemonSet binds it to every node's IP, so it needs authentication in the | ||
| # request path. This Secret holds the token both the agent (to verify) and its | ||
| # callers (to present) read. | ||
| # | ||
| # Generated once and preserved across upgrades: `helm upgrade` re-renders every | ||
| # template, so a freshly random token on each upgrade would rotate the | ||
| # credential out from under running callers and cause a self-inflicted outage | ||
| # mid-rollout. The lookup below reuses the existing value when the Secret is | ||
| # already present. Set agent.auth.token explicitly to manage it yourself (or to | ||
| # rotate deliberately). | ||
| {{- $ns := .Release.Namespace }} | ||
| {{- $name := "nvsnap-agent-token" }} | ||
| {{- $existing := lookup "v1" "Secret" $ns $name }} | ||
| {{- $token := "" }} | ||
| {{- if .Values.agent.auth.token }} | ||
| {{- $token = .Values.agent.auth.token | b64enc }} | ||
| {{- else if and $existing $existing.data $existing.data.token }} | ||
| {{- $token = $existing.data.token }} | ||
| {{- else }} | ||
| # Reached on a first install, and on any client-side render -- `lookup` returns | ||
| # empty without cluster access, so an existing Secret is invisible here and | ||
| # indistinguishable from a missing one. | ||
| # | ||
| # That makes `helm template` non-deterministic: every run mints a different | ||
| # token, and `helm template | kubectl apply` would rotate the credential out | ||
| # from under running agents, which keep the old value in their environment | ||
| # while fresh mount-prep pods get the new one and 401 until the DaemonSet | ||
| # rolls. Set agent.auth.token to render offline safely. | ||
| # | ||
| # Not guarded with `fail`, because `lookup` is equally empty under | ||
| # `helm install --dry-run` -- which scripts/install-nvsnap.sh --dry-run | ||
| # relies on, and which applies nothing. helm install/upgrade is the supported | ||
| # path and does see the existing Secret, so the token survives upgrades. | ||
| {{- $token = randAlphaNum 48 | b64enc }} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| {{- end }} | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: {{ $name }} | ||
| namespace: {{ $ns }} | ||
| labels: | ||
| app.kubernetes.io/name: nvsnap | ||
| app.kubernetes.io/part-of: nvsnap | ||
| annotations: | ||
| # helm.sh/resource-policy keeps the Secret if the release is removed with | ||
| # --keep-history style workflows; without it a delete/reinstall cycle | ||
| # silently rotates the token. | ||
| helm.sh/resource-policy: keep | ||
| type: Opaque | ||
| data: | ||
| token: {{ $token }} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| {{- /* | ||
| Replicate into every restore namespace. A SecretKeyRef resolves only in | ||
| the pod's own namespace, and the mount-prep init container the webhook | ||
| injects runs in the restore pod's namespace, not the release namespace. | ||
| Without a copy there its reference (marked optional, so the pod still | ||
| starts) silently resolves to nothing -- mount-prep then sends no header | ||
| and the agent 401s every restore once auth.mode=required. | ||
|
|
||
| Same list the restore-pod NetworkPolicy uses, so a namespace already | ||
| declared for egress is covered here too with no new configuration. | ||
| */}} | ||
| {{- range $rns := .Values.agent.l2.restoreNamespaces }} | ||
| {{- if ne $rns $ns }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: {{ $name }} | ||
| namespace: {{ $rns }} | ||
| labels: | ||
| app.kubernetes.io/name: nvsnap | ||
| app.kubernetes.io/part-of: nvsnap | ||
| annotations: | ||
| helm.sh/resource-policy: keep | ||
| type: Opaque | ||
| data: | ||
| token: {{ $token }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.