Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if $useServiceAccount }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about this, it could introduce a breaking change , we need to find a way that won't break existing users scripts that may rely on this existing HELM setup

Copy link
Author

Choose a reason for hiding this comment

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

It's not a breaking change because the existing logic is respected. It replaces this if with another one but still considering $useServiceAccount.

Copy link
Author

Choose a reason for hiding this comment

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

@ArangoGutierrez did you check what I mentioned?

{{- if or .Values.serviceAccount.create $useServiceAccount }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- else }}
serviceAccountName: {{ include "nvidia-device-plugin.fullname" . }}-service-account
{{- end }}
{{- end }}
{{- if $options.hasConfigMap }}
shareProcessNamespace: true
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if $useServiceAccount }}
{{- if or .Values.serviceAccount.create $useServiceAccount }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- else }}
serviceAccountName: {{ include "nvidia-device-plugin.fullname" . }}-service-account
{{- end }}
{{- end }}
{{- if $options.hasConfigMap }}
shareProcessNamespace: true
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{{- if .Values.devicePlugin.enabled }}
---
{{- $options := (include "nvidia-device-plugin.options" . | fromJson) }}
{{- $useServiceAccount := $options.hasConfigMap }}
Copy link

Copilot AI Mar 3, 2025

Choose a reason for hiding this comment

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

The variable $useServiceAccount is assigned solely from $options.hasConfigMap, which may lead to inconsistent service account creation behavior compared to other templates that consider .Values.serviceAccount.create. Consider updating this assignment to include .Values.serviceAccount.create for consistency.

Suggested change
{{- $useServiceAccount := $options.hasConfigMap }}
{{- $useServiceAccount := or $options.hasConfigMap .Values.serviceAccount.create }}

Copilot uses AI. Check for mistakes.
{{- $configMapName := (include "nvidia-device-plugin.configMapName" .) | trim }}
{{- $daemonsetName := printf "%s-mps-control-daemon" (include "nvidia-device-plugin.fullname" .) | trunc 63 | trimSuffix "-" }}
apiVersion: apps/v1
Expand Down Expand Up @@ -50,12 +51,16 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if $options.hasConfigMap }}
{{- if or .Values.serviceAccount.create $useServiceAccount }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- else }}
serviceAccountName: {{ include "nvidia-device-plugin.fullname" . }}-service-account
{{- end }}
{{- end }}
{{- if not .Values.mps.enableHostPID }}
shareProcessNamespace: true
{{- end }}
{{- end }}
{{- if .Values.mps.enableHostPID }}
hostPID: true
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
---
{{- $options := (include "nvidia-device-plugin.options" . | fromJson) }}
{{- if or $options.hasConfigMap ( and .Values.gfd.enabled .Values.nfd.enableNodeFeatureApi ) }}
{{- if or .Values.serviceAccount.create $options.hasConfigMap ( and .Values.gfd.enabled .Values.nfd.enableNodeFeatureApi ) }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- if .Values.serviceAccount.name }}
name: {{ .Values.serviceAccount.name }}
{{- else }}
name: {{ include "nvidia-device-plugin.fullname" . }}-service-account
{{- end }}
namespace: {{ include "nvidia-device-plugin.namespace" . }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "nvidia-device-plugin.labels" . | nindent 4 }}
{{- end }}
11 changes: 11 additions & 0 deletions deployments/helm/nvidia-device-plugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ podAnnotations: {}
podSecurityContext: {}
securityContext: {}

serviceAccount:
# Specifies whether a service account should be created.
create: false

# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template.
# name: ""

# Optional additional annotations to add to the controller's Service Account. Templates are allowed for both keys and values.
# annotations: {}

resources: {}
nodeSelector: {}
affinity:
Expand Down