Skip to content

feat(helm): make device plugin security context configurable via values#1887

Merged
hami-robot[bot] merged 4 commits into
Project-HAMi:masterfrom
ilia-medvedev:feat/configurable-security-context
Jul 2, 2026
Merged

feat(helm): make device plugin security context configurable via values#1887
hami-robot[bot] merged 4 commits into
Project-HAMi:masterfrom
ilia-medvedev:feat/configurable-security-context

Conversation

@ilia-medvedev

@ilia-medvedev ilia-medvedev commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • hostPID and hostNetwork on the device plugin DaemonSet pod spec are now values-configurable (defaults: true / false — unchanged from current behaviour)
  • securityContext for the main device-plugin container is now values-configurable (default: privileged: true, allowPrivilegeEscalation: true, SYS_ADMIN)
  • securityContext for the vgpu-monitor container is now values-configurable (default: allowPrivilegeEscalation: false, SYS_ADMIN)
  • gpuOperatorToolkitReady.securityContext for the toolkit-validation init container is now values-configurable (default: privileged: true, runAsUser: 0)

All defaults preserve the existing hardcoded values — this is a non-breaking change.

Motivation

Users deploying HAMi in environments with custom Pod Security Admission policies or restricted node configurations need to be able to tune these settings without patching the chart templates.

Through testing we found that not all security defaults — such as privileged: true and hostPID: true — are required for every use case. Making these configurable allows users to apply a least-privilege posture where their environment permits.

Closes #1888
Related: #1143

AI assistance used in drafting this PR.

Summary by CodeRabbit

  • New Features

    • Added new configuration options to control whether the device plugin uses host PID and host networking.
    • Introduced configurable security settings for the device plugin, its monitoring component, and the toolkit validation step.
  • Bug Fixes

    • Replaced previously hardcoded privilege and container security settings with deployment-driven controls, improving compatibility and flexibility across environments.

@hami-robot hami-robot Bot requested review from FouoF and archlitchi May 19, 2026 10:50
@github-actions github-actions Bot added the kind/feature new function label May 19, 2026
@hami-robot hami-robot Bot added the size/M label May 19, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request parameterizes the hostPID, hostNetwork, and securityContext settings for the NVIDIA device plugin DaemonSet, moving previously hardcoded values into values.yaml. The review feedback recommends wrapping the securityContext blocks in Helm with statements to better handle cases where values might be null or omitted. There is also a suggestion to adjust the placement of the new securityContext field in values.yaml to preserve the association between the resources field and its descriptive comments.

Comment thread charts/hami/templates/device-plugin/daemonsetnvidia.yaml Outdated
Comment thread charts/hami/templates/device-plugin/daemonsetnvidia.yaml Outdated
Comment thread charts/hami/templates/device-plugin/daemonsetnvidia.yaml Outdated
Comment thread charts/hami/values.yaml Outdated
@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 59.05% <ø> (+0.45%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Expose hardcoded hostPID, hostNetwork, and all container securityContext
fields as overridable values in values.yaml. Current settings are
preserved as defaults so this is a non-breaking change.

Wrap securityContext blocks in {{- with }} so they are safely omitted
when overridden to null. Move monitor.securityContext before resources
in values.yaml to keep resource comments associated with the right field.

Signed-off-by: ilia-medvedev <ilia.medvedev@gong.io>
@ilia-medvedev ilia-medvedev force-pushed the feat/configurable-security-context branch from b8910e3 to 994b102 Compare May 19, 2026 11:00
…ToolkitReady

Co-locates the init container security settings with the other
gpuOperatorToolkitReady options for clarity, since that block
is the only place the init container is used.

Signed-off-by: ilia-medvedev <ilia.medvedev@gong.io>

@mesutoezdil mesutoezdil 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.

defaults are preserved correctly, all ci passes, and the {{- with }} pattern for securityContext is the right call. one issue with hostPID and hostNetwork.

Comment thread charts/hami/templates/device-plugin/daemonsetnvidia.yaml
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

hostPID, hostNetwork, and securityContext for the device-plugin, vgpu-monitor, and toolkit-validation containers in the DaemonSet template are now rendered from values.yaml instead of being hardcoded. Default values preserving existing behavior are added to values.yaml.

Changes

Configurable Device Plugin Security

Layer / File(s) Summary
Default values for securityContext and host settings
charts/hami/values.yaml
Adds securityContext under gpuOperatorToolkitReady (privileged: true, runAsUser: 0), under monitor (allowPrivilegeEscalation: false, capabilities drop ALL/add SYS_ADMIN), and under devicePlugin (privileged: true, allowPrivilegeEscalation: true, capabilities); also adds hostPID: true and hostNetwork: false.
DaemonSet template parameterization
charts/hami/templates/device-plugin/daemonsetnvidia.yaml
Replaces hardcoded hostPID, hostNetwork, and per-container securityContext blocks with value-driven rendering from the new Helm values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

🐇 I hop through values, neat and new,
With flags and contexts set so true.
The daemonset now bends to you—
hostPID and friends can ebb and flow.
Carrots for least-privilege, too!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making device plugin security context configurable via Helm values.
Linked Issues check ✅ Passed The chart exposes the requested host and security context values for the device plugin, monitor, and toolkit-validation init container with preserved defaults.
Out of Scope Changes check ✅ Passed The changes stay within the Helm chart device-plugin configuration and do not introduce unrelated functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/hami/templates/device-plugin/daemonsetnvidia.yaml`:
- Line 43: The hostPID templating in the device plugin DaemonSet is overriding
an explicit false value because default true treats false as empty. Update the
hostPID rendering logic in the daemonset template so devicePlugin.hostPID=false
is preserved as false instead of falling back to true, using the existing
hostPID value handling in the chart template.

In `@charts/hami/values.yaml`:
- Around line 272-274: The init container security context is currently defined
under gpuOperatorToolkitReady.securityContext, but the contract expects it at
devicePlugin.initContainerSecurityContext, so the configured value path is being
ignored. Move the default in values.yaml to the documented
devicePlugin.initContainerSecurityContext key and update the DaemonSet/template
lookup to read from that same path, using the relevant securityContext fields in
the init container rendering logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 088bf6e1-58bb-4841-8601-0d548997648c

📥 Commits

Reviewing files that changed from the base of the PR and between 98b8830 and 19f8a7d.

📒 Files selected for processing (2)
  • charts/hami/templates/device-plugin/daemonsetnvidia.yaml
  • charts/hami/values.yaml

Comment thread charts/hami/templates/device-plugin/daemonsetnvidia.yaml Outdated
Comment thread charts/hami/values.yaml
@ilia-medvedev ilia-medvedev force-pushed the feat/configurable-security-context branch from 19f8a7d to c370332 Compare June 29, 2026 08:24
Signed-off-by: ilia-medvedev <ilia.medvedev@gong.io>
Comment thread charts/hami/templates/device-plugin/daemonsetnvidia.yaml Outdated
@mesutoezdil

mesutoezdil commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The PR says Closes #1888 but 2 things from that issue are not working:

  • Issue specifies devicePlugin.initContainerSecurityContext but the PR puts it under devicePlugin.gpuOperatorToolkitReady.securityContext.
    The path does not match.
  • hostPID: false override does not work due to the boolean default bug mentioned above.

Both need to be fixed before this can actually close #1888.

Signed-off-by: ilia-medvedev <ilia.medvedev@gong.io>
@ilia-medvedev

Copy link
Copy Markdown
Contributor Author

@mesutoezdil I've fixed the hostPID . as for the initContainer- it's cleaner to use the already existing parent value for it so using gpuOperatorToolkitReady.securityContext is the correct choice. I've adjusted the issue and the PR comment accordingly.

@mesutoezdil

Copy link
Copy Markdown
Contributor

/lgtm

@archlitchi archlitchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@hami-robot

hami-robot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: archlitchi, ilia-medvedev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the approved label Jul 2, 2026
@hami-robot hami-robot Bot merged commit 0517f24 into Project-HAMi:master Jul 2, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Make device plugin security context configurable via Helm values

3 participants