Skip to content

feat(nvidia): exposing nvidia container runtime config in nodeadm config - #2875

Merged
kummatty merged 1 commit into
awslabs:mainfrom
kummatty:main
Nov 3, 2026
Merged

kummatty merged 1 commit into
awslabs:mainfrom
kummatty:main

Conversation

@kummatty

@kummatty kummatty commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available:
#2861

Description of changes:

Adds spec.nvidiaContainerRuntime.config, an inline TOML document that nodeadm merges into /etc/nvidia-container-runtime/config.toml. Customers can set any NVIDIA Container Toolkit option, such as :

apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
  cluster: ...
  nvidiaContainerRuntime:
    config: |
      accept-nvidia-visible-devices-as-volume-mounts = true
      accept-nvidia-visible-devices-envvar-when-unprivileged = false

The setting is opt-in with no defaults, so nodes that don't use it keep the toolkit's shipped file untouched. On AMIs without the NVIDIA container runtime the setting is ignored with a warning.

Since user data can be modified on a stopped instance, nodeadm needs a baseline to merge back from in case the customer later unsets properties in their nodeadm spec. So the first time nodeadm changes the file, it saves the shipped version as .config.toml.orig and merges the user config over that copy on every boot. Properties removed from the spec then revert, and removing the field entirely restores the original file. The baseline is the node's own file rather than the toolkit's defaults, so settings a custom AMI ships are kept.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Testing Done

  • Built AL2023 NVIDIA and standard AMIs from this branch.
  • Verified the spec is merged into the shipped config.toml.
  • Verified unsetting a property reverts it to the original value, and removing the spec restores the original file.
  • Verified non-NVIDIA AMIs skip it with a warning.
  • Added unit tests and an e2e case.
  • unprivileged pods can't get GPUs through NVIDIA_VISIBLE_DEVICES, while nvidia.com/gpu pods still can.

@kummatty
kummatty requested a review from a team as a code owner November 2, 2026 21:43
@kummatty
kummatty force-pushed the main branch 2 times, most recently from e7b4da9 to ab906a6 Compare November 2, 2026 22:27

@mselim00 mselim00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks 🙌

just some minor notes, up to you if you think they're worth addressing or not

Comment on lines +33 to +34
if _, err := os.Stat(runtimeBinaryPath); err != nil {
if len(userConfig) > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not a fan of duplicating this check (duplicate)

but I can see the motivation with keeping this separate from the containerd config "mixin." ok with leaving it as is since it's small enough, or maybe extracting it into a util under internal/pkg?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well 👍

// ship their own config that we don't want to lose. The original is restored
// once the user config is removed.
func updateConfig(configPath string, userConfig api.NvidiaContainerRuntimeConfig) error {
originalConfigPath := configPath + ".orig"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this seems like it should be a dotfile

Suggested change
originalConfigPath := configPath + ".orig"
originalConfigPath := path.Join(path.Dir(configPath), "."+path.Base(configPath)+".orig")

or just hardcode /etc/nvidia-container-runtime/.config.toml.orig in the const block since it's a fixed path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in a dotfile, since this is primarily an implementation detail and not a config. I can do a hardcoded const though

@mselim00 mselim00 Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dotfile approach is the same one vi uses for backup, it creates a temp file named .<filename>.swp

@kummatty
kummatty merged commit 1e63249 into awslabs:main Nov 3, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AL2023 NVIDIA AMI: ignore NVIDIA_VISIBLE_DEVICES from unprivileged containers, as Bottlerocket does

2 participants