Skip to content

Commit 3042b5a

Browse files
committed
Use per-component matchLabels selector in pod specs (fix #355)
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
1 parent bf444c4 commit 3042b5a

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

deployments/helm/nvidia-dra-driver-gpu/templates/_helpers.tpl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,19 @@ app.kubernetes.io/instance: {{ .Release.Name }}
6666
{{- end }}
6767

6868
{{/*
69-
Selector labels
69+
Selector labels: meant to select just the pods of the corresponding
70+
deployment/daemonset/... That is, this is different per-component.
7071
*/}}
7172
{{- define "nvidia-dra-driver-gpu.selectorLabels" -}}
72-
{{- if .Values.selectorLabelsOverride -}}
73-
{{ toYaml .Values.selectorLabelsOverride }}
74-
{{- else -}}
75-
{{ include "nvidia-dra-driver-gpu.templateLabels" . }}
76-
{{- end }}
73+
{{- if and (hasKey . "componentName") (hasKey . "context") -}}
74+
{{- if .context.Values.selectorLabelsOverride -}}
75+
{{ toYaml .context.Values.selectorLabelsOverride }}
76+
{{- else -}}
77+
nvidia-dra-driver-gpu-component: {{ .componentName }}
78+
{{- end }}
79+
{{- else -}}
80+
fail "selectorLabels: both arguments are required: context, componentName"
81+
{{- end }}
7782
{{- end }}
7883

7984
{{/*

deployments/helm/nvidia-dra-driver-gpu/templates/controller.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
replicas: 1
2626
selector:
2727
matchLabels:
28-
{{- include "nvidia-dra-driver-gpu.selectorLabels" . | nindent 6 }}
28+
{{- include "nvidia-dra-driver-gpu.selectorLabels" (dict "context" . "componentName" "controller") | nindent 6 }}
2929
template:
3030
metadata:
3131
{{- with .Values.controller.podAnnotations }}
@@ -34,6 +34,7 @@ spec:
3434
{{- end }}
3535
labels:
3636
{{- include "nvidia-dra-driver-gpu.templateLabels" . | nindent 8 }}
37+
{{- include "nvidia-dra-driver-gpu.selectorLabels" (dict "context" . "componentName" "controller") | nindent 8 }}
3738
spec:
3839
{{- if .Values.controller.priorityClassName }}
3940
priorityClassName: {{ .Values.controller.priorityClassName }}

deployments/helm/nvidia-dra-driver-gpu/templates/kubeletplugin.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ metadata:
2424
spec:
2525
selector:
2626
matchLabels:
27-
{{- include "nvidia-dra-driver-gpu.selectorLabels" . | nindent 6 }}
27+
{{- include "nvidia-dra-driver-gpu.selectorLabels" (dict "context" . "componentName" "kubelet-plugin") | nindent 6 }}
2828
{{- with .Values.kubeletPlugin.updateStrategy }}
2929
updateStrategy:
3030
{{- toYaml . | nindent 4 }}
@@ -37,6 +37,7 @@ spec:
3737
{{- end }}
3838
labels:
3939
{{- include "nvidia-dra-driver-gpu.templateLabels" . | nindent 8 }}
40+
{{- include "nvidia-dra-driver-gpu.selectorLabels" (dict "context" . "componentName" "kubelet-plugin") | nindent 8 }}
4041
spec:
4142
{{- if .Values.kubeletPlugin.priorityClassName }}
4243
priorityClassName: {{ .Values.kubeletPlugin.priorityClassName }}

0 commit comments

Comments
 (0)