diff --git a/deployments/helm/nvidia-device-plugin/templates/_helpers.tpl b/deployments/helm/nvidia-device-plugin/templates/_helpers.tpl index a2dfca250..277c51fa8 100644 --- a/deployments/helm/nvidia-device-plugin/templates/_helpers.tpl +++ b/deployments/helm/nvidia-device-plugin/templates/_helpers.tpl @@ -77,6 +77,16 @@ Selector labels {{- end }} {{- end }} +{{/* +Optional component label for DaemonSet selector and template labels. +*/}} +{{- define "nvidia-device-plugin.componentLabel" -}} +{{- $root := .root -}} +{{- if and $root.Values.componentSelectorLabels.enabled (not $root.Values.selectorLabelsOverride) -}} +app.kubernetes.io/component: {{ .component }} +{{- end -}} +{{- end }} + {{/* Full image name with tag */}} 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 65492c327..fb5739520 100644 --- a/deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml +++ b/deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml @@ -29,6 +29,9 @@ spec: selector: matchLabels: {{- include "nvidia-device-plugin.selectorLabels" . | nindent 6 }} + {{- with (include "nvidia-device-plugin.componentLabel" (dict "root" . "component" "device-plugin") | trim) }} + {{- . | nindent 6 }} + {{- end }} {{- with .Values.updateStrategy }} updateStrategy: {{- toYaml . | nindent 4 }} @@ -37,6 +40,9 @@ spec: metadata: labels: {{- include "nvidia-device-plugin.templateLabels" . | nindent 8 }} + {{- with (include "nvidia-device-plugin.componentLabel" (dict "root" . "component" "device-plugin") | trim) }} + {{- . | nindent 8 }} + {{- end }} annotations: {{- include "nvidia-device-plugin.podAnnotations" (dict "local" . "root" .) | nindent 8 }} spec: diff --git a/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml b/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml index fd3ff7b2b..162957537 100644 --- a/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml +++ b/deployments/helm/nvidia-device-plugin/templates/daemonset-gfd.yml @@ -29,6 +29,9 @@ spec: selector: matchLabels: {{- include "nvidia-device-plugin.selectorLabels" . | nindent 6 }} + {{- with (include "nvidia-device-plugin.componentLabel" (dict "root" . "component" "gpu-feature-discovery") | trim) }} + {{- . | nindent 6 }} + {{- end }} {{- with .Values.updateStrategy }} updateStrategy: {{- toYaml . | nindent 4 }} @@ -37,6 +40,9 @@ spec: metadata: labels: {{- include "nvidia-device-plugin.templateLabels" . | nindent 8 }} + {{- with (include "nvidia-device-plugin.componentLabel" (dict "root" . "component" "gpu-feature-discovery") | trim) }} + {{- . | nindent 8 }} + {{- end }} annotations: {{- include "nvidia-device-plugin.podAnnotations" (dict "local" . "root" .) | nindent 8 }} spec: 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 1b7dd3a89..140332c69 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 @@ -27,6 +27,9 @@ spec: selector: matchLabels: {{- include "nvidia-device-plugin.selectorLabels" . | nindent 6 }} + {{- with (include "nvidia-device-plugin.componentLabel" (dict "root" . "component" "mps-control-daemon") | trim) }} + {{- . | nindent 6 }} + {{- end }} {{- with .Values.updateStrategy }} updateStrategy: {{- toYaml . | nindent 4 }} @@ -35,6 +38,9 @@ spec: metadata: labels: {{- include "nvidia-device-plugin.templateLabels" . | nindent 8 }} + {{- with (include "nvidia-device-plugin.componentLabel" (dict "root" . "component" "mps-control-daemon") | trim) }} + {{- . | nindent 8 }} + {{- end }} annotations: {{- include "nvidia-device-plugin.podAnnotations" (dict "local" . "root" .) | nindent 8 }} spec: diff --git a/deployments/helm/nvidia-device-plugin/values.yaml b/deployments/helm/nvidia-device-plugin/values.yaml index 12d30964a..953f4c3fb 100644 --- a/deployments/helm/nvidia-device-plugin/values.yaml +++ b/deployments/helm/nvidia-device-plugin/values.yaml @@ -42,6 +42,13 @@ nameOverride: "" fullnameOverride: "" namespaceOverride: "" selectorLabelsOverride: {} +componentSelectorLabels: + # enabled controls whether DaemonSet selectors include app.kubernetes.io/component + # to avoid overlap between device-plugin, gpu-feature-discovery, and mps-control-daemon. + # NOTE: This is disabled by default for upgrade compatibility because DaemonSet + # selectors are immutable and enabling this on an existing release requires + # DaemonSet recreation. + enabled: false allowDefaultNamespace: false