diff --git a/deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml b/deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml index 1fdd0b6f4..7ef22f5a8 100644 --- a/deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml +++ b/deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml @@ -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 initContainers: diff --git a/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml b/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml index 197f12b7a..811879920 100644 --- a/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml +++ b/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml @@ -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 }} diff --git a/deployments/helm/nvidia-device-plugin/templates/daemonset-mps-control-daemon.yml b/deployments/helm/nvidia-device-plugin/templates/daemonset-mps-control-daemon.yml index da37aba6d..2dffdf84a 100644 --- a/deployments/helm/nvidia-device-plugin/templates/daemonset-mps-control-daemon.yml +++ b/deployments/helm/nvidia-device-plugin/templates/daemonset-mps-control-daemon.yml @@ -14,6 +14,7 @@ {{- if .Values.devicePlugin.enabled }} --- {{- $options := (include "nvidia-device-plugin.options" . | fromJson) }} +{{- $useServiceAccount := $options.hasConfigMap }} {{- $configMapName := (include "nvidia-device-plugin.configMapName" .) | trim }} {{- $daemonsetName := printf "%s-mps-control-daemon" (include "nvidia-device-plugin.fullname" .) | trunc 63 | trimSuffix "-" }} apiVersion: apps/v1 @@ -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 }} diff --git a/deployments/helm/nvidia-device-plugin/templates/service-account.yml b/deployments/helm/nvidia-device-plugin/templates/service-account.yml index 7ab9ba336..b4aa71f34 100644 --- a/deployments/helm/nvidia-device-plugin/templates/service-account.yml +++ b/deployments/helm/nvidia-device-plugin/templates/service-account.yml @@ -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 }} diff --git a/deployments/helm/nvidia-device-plugin/values.yaml b/deployments/helm/nvidia-device-plugin/values.yaml index 147b9eac9..c1de43092 100644 --- a/deployments/helm/nvidia-device-plugin/values.yaml +++ b/deployments/helm/nvidia-device-plugin/values.yaml @@ -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: