@@ -43,36 +43,47 @@ Create chart name and version as used by the chart label.
4343{ {- end } }
4444
4545{ {/*
46- Common labels
46+ Standard labels: documented at
47+ https://helm.sh/docs/chart_best_practices/labels/
48+ Apply this to all high-level objects (Deployment, DaemonSet, ...).
49+ Pod template labels are included here to deliver name+instance.
4750*/} }
4851{ {- define " nvidia-dra-driver-gpu.labels" -} }
4952helm.sh/chart: { { include " nvidia-dra-driver-gpu.chart" . } }
50- { { include " nvidia-dra-driver-gpu.templateLabels" . } }
51- { {- if .Chart.AppVersion } }
5253app.kubernetes.io/version: { { .Chart.AppVersion | quote } }
53- { {- end } }
5454app.kubernetes.io/managed-by: { { .Release.Service } }
55+ { { include " nvidia-dra-driver-gpu.templateLabels" . } }
5556{ {- end } }
5657
5758{ {/*
58- Template labels
59+ Apply this to all pod templates (a smaller set of labels compared to
60+ the set of standard labels above, to not clutter individual pods too
61+ much). Note that these labels cannot be used to distinguish
62+ components within this Helm chart.
5963*/} }
6064{ {- define " nvidia-dra-driver-gpu.templateLabels" -} }
6165app.kubernetes.io/name: { { include " nvidia-dra-driver-gpu.name" . } }
6266app.kubernetes.io/instance: { { .Release.Name } }
63- { {- if .Values.selectorLabelsOverride } }
64- { { toYaml .Values.selectorLabelsOverride } }
65- { {- end } }
6667{ {- end } }
6768
6869{ {/*
69- Selector labels
70+ Selector label: precisely filter for just the pods of the corresponding
71+ Deployment, DaemonSet, .... That is, this label key/value pair must be
72+ different per-component (a component name is a required argument). This
73+ could be many labels, but we want to use just one (with a sufficiently
74+ unique key).
75+
76+ TOOD: remove the override feature, or make the override work per-component.
7077*/} }
7178{ {- define " nvidia-dra-driver-gpu.selectorLabels" -} }
72- { {- if .Values.selectorLabelsOverride -} }
73- { { toYaml .Values.selectorLabelsOverride } }
79+ { {- if and (hasKey . " componentName" ) (hasKey . " context" ) -} }
80+ { {- if .context.Values.selectorLabelsOverride -} }
81+ { { toYaml .context.Values.selectorLabelsOverride } }
7482{ {- else -} }
75- { { include " nvidia-dra-driver-gpu.templateLabels" . } }
83+ { { .context.Chart.Name } }-component: { { .componentName } }
84+ { {- end } }
85+ { {- else -} }
86+ fail "selectorLabels: both arguments are required: context, componentName"
7687{ {- end } }
7788{ {- end } }
7889
0 commit comments