Skip to content

K8s: Helm config customLabels to add more tracing resource attributes #2858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
Merged
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
2 changes: 1 addition & 1 deletion charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| videoRecorder.extraVolumeMounts | list | `[]` | Custom video recorder back-end scripts (video.sh, video_ready.py, etc.) further by ConfigMap. NOTE: For the mount point with the name "video", or "video-scripts", it will override the default. For other names, it will be appended. |
| videoRecorder.extraVolumes | list | `[]` | Extra volumes for video recorder pod |
| videoRecorder.s3 | object | `{"args":[],"command":[],"extraEnvironmentVariables":[],"imageName":"aws-cli","imagePullPolicy":"IfNotPresent","imageRegistry":"bitnami","imageTag":"latest","securityContext":{"runAsUser":0}}` | Container spec for the uploader if above it is defined as "uploader.name: s3" |
| customLabels | object | `{}` | Custom labels for k8s resources |
| customLabels | object | `{}` | Add more labels to all resources created by this chart or override existing label keys |
| videoManager.enabled | bool | `false` | Enable video manager |
| videoManager.nameOverride | string | `""` | Override deployment name of video manager |
| videoManager.ingress.enabled | bool | `true` | Enable ingress resource to access the file browser |
Expand Down
7 changes: 3 additions & 4 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,10 @@ template:
labels:
app: {{ .name }}
app.kubernetes.io/name: {{ .name }}
{{- include "seleniumGrid.commonLabels" . | nindent 6 }}
{{- include "seleniumGrid.commonLabels" $ | nindent 6 }}
{{- with .node.labels }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 6 }}
{{- end }}
annotations:
checksum/event-bus-configmap: {{ include (print $.Template.BasePath "/event-bus-configmap.yaml") . | sha256sum }}
checksum/node-configmap: {{ include (print $.Template.BasePath "/node-configmap.yaml") . | sha256sum }}
Expand Down Expand Up @@ -398,6 +395,8 @@ template:
{{- end }}
- name: SE_OTEL_SERVICE_NAME
value: {{ .name | quote }}
- name: SE_OTEL_RESOURCE_ATTRIBUTES
value: {{ include "seleniumGrid.tracing.attributes" $ | quote }}
- name: SE_NODE_HOST
valueFrom:
fieldRef:
Expand Down
27 changes: 22 additions & 5 deletions charts/selenium-grid/templates/_nameHelpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,28 @@ Create chart name and version as used by the chart label.
Common labels
*/}}
{{- define "seleniumGrid.commonLabels" -}}
app.kubernetes.io/managed-by: {{ .Release.Service | lower }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/component: {{ printf "selenium-grid-%s" .Chart.AppVersion }}
helm.sh/chart: {{ include "seleniumGrid.chart" . }}
{{- $defaultLabels := dict
"app.kubernetes.io/managed-by" (.Release.Service | lower)
"app.kubernetes.io/instance" .Release.Name
"app.kubernetes.io/version" .Chart.AppVersion
"app.kubernetes.io/component" (printf "selenium-grid-%s" .Chart.AppVersion)
"helm.sh/chart" (include "seleniumGrid.chart" .)
}}
{{- $customLabels := tpl (toYaml (.Values.customLabels | default dict)) $ | fromYaml }}
{{- $mergedLabels := merge $defaultLabels $customLabels }}
{{- toYaml $mergedLabels | nindent 0 }}
{{- end -}}

{{/*
Bring common labels to tracing resource attributes
*/}}
{{- define "seleniumGrid.tracing.attributes" -}}
{{- $labels := include "seleniumGrid.commonLabels" $ | fromYaml }}
{{- $attrs := list }}
{{- range $k, $v := $labels }}
{{- $attrs = append $attrs (printf "%s=%s" $k $v) }}
{{- end }}
{{- join "," $attrs }}
{{- end -}}

{{/*
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/basic-auth-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ metadata:
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- if eq .Values.basicAuth.enabled true }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/chrome-node-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $nodeConfig $.Values.global.seleniumGrid) }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/chrome-node-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy $ -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.chromeNode.fullname" (list $nodeConfig $)) -}}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/chrome-node-scaledjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy $ -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.chromeNode.fullname" (list $nodeConfig $)) -}}
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/distributor-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
data:
{{- $fileProceeded := list -}}
{{- range $path, $_ := .Files.Glob $.Values.distributorConfigMap.extraScriptsImportFrom }}
Expand Down
7 changes: 3 additions & 4 deletions charts/selenium-grid/templates/distributor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
labels: &distributor_labels
app: {{ template "seleniumGrid.distributor.fullname" . }}
app.kubernetes.io/name: {{ template "seleniumGrid.distributor.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.distributor $.Values.global.seleniumGrid) }}
Expand Down Expand Up @@ -49,6 +46,8 @@ spec:
fieldPath: status.hostIP
- name: SE_OTEL_SERVICE_NAME
value: '{{ template "seleniumGrid.distributor.fullname" . }}'
- name: SE_OTEL_RESOURCE_ATTRIBUTES
value: {{ include "seleniumGrid.tracing.attributes" $ | quote }}
- name: SE_DISTRIBUTOR_HOST
valueFrom:
fieldRef:
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/distributor-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "seleniumGrid.distributor.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.components.distributor.serviceAnnotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/edge-node-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $nodeConfig $.Values.global.seleniumGrid) }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/edge-node-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy $ -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.edgeNode.fullname" (list $nodeConfig $)) -}}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/edge-node-scaledjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy $ -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.edgeNode.fullname" (list $nodeConfig $)) -}}
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/event-bus-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
data:
SE_EVENT_BUS_HOST: {{ $eventBusHost | quote }}
SE_EVENT_BUS_PUBLISH_PORT: {{ $eventBusPublishPort | quote }}
Expand Down
7 changes: 3 additions & 4 deletions charts/selenium-grid/templates/event-bus-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
labels: &event_bus_labels
app: {{ template "seleniumGrid.eventBus.fullname" . }}
app.kubernetes.io/name: {{ template "seleniumGrid.eventBus.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.eventBus $.Values.global.seleniumGrid) }}
Expand Down Expand Up @@ -53,6 +50,8 @@ spec:
fieldPath: status.hostIP
- name: SE_OTEL_SERVICE_NAME
value: '{{ template "seleniumGrid.eventBus.fullname" . }}'
- name: SE_OTEL_RESOURCE_ATTRIBUTES
value: {{ include "seleniumGrid.tracing.attributes" $ | quote }}
- name: SE_EVENT_BUS_HOST
valueFrom:
fieldRef:
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/event-bus-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "seleniumGrid.eventBus.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.components.eventBus.serviceAnnotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/firefox-node-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $nodeConfig $.Values.global.seleniumGrid) }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/firefox-node-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy $ -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.firefoxNode.fullname" (list $nodeConfig $)) -}}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/firefox-node-scaledjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ metadata:
{{- with $nodeConfig.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy $ -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.firefoxNode.fullname" (list $nodeConfig $)) -}}
Expand Down
7 changes: 3 additions & 4 deletions charts/selenium-grid/templates/hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ metadata:
labels: &hub_labels
app: {{ template "seleniumGrid.hub.fullname" . }}
app.kubernetes.io/name: {{ template "seleniumGrid.hub.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.hub.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $.Values.hub $.Values.global.seleniumGrid) }}
Expand Down Expand Up @@ -110,6 +107,8 @@ spec:
fieldPath: status.hostIP
- name: SE_OTEL_SERVICE_NAME
value: '{{ template "seleniumGrid.hub.fullname" . }}'
- name: SE_OTEL_RESOURCE_ATTRIBUTES
value: {{ include "seleniumGrid.tracing.attributes" $ | quote }}
- name: SE_HUB_HOST
valueFrom:
fieldRef:
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/hub-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "seleniumGrid.hub.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.hub.serviceAnnotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ metadata:
name: {{ template "seleniumGrid.ingress.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- $ingressAnnotations := (include "seleniumGrid.ingress.nginx.annotations.default" . | toString | fromYaml ) }}
{{- with .Values.ingress.annotations -}}
{{- $ingressAnnotations = mergeOverwrite $ingressAnnotations . }}
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/jaeger-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ metadata:
name: {{ .Release.Name }}-jaeger-ingress
namespace: {{ .Release.Namespace }}
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.tracing.ingress.annotations }}
annotations:
{{- . | toYaml | nindent 4 }}
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/logging-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
data:
SE_LOG_LEVEL: {{ default "INFO" .Values.global.seleniumGrid.logLevel | quote }}
SE_STRUCTURED_LOGS: {{ default false .Values.global.seleniumGrid.structuredLogs | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels: &exporter_labels
app: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
app.kubernetes.io/name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
spec:
replicas: {{ .Values.monitoring.exporter.replicas }}
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
app.kubernetes.io/name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
spec:
selector:
app: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
Expand Down
3 changes: 0 additions & 3 deletions charts/selenium-grid/templates/monitoring-scape-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ metadata:
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- $key := include "seleniumGrid.monitoring.scrape.key" $ -}}
Expand Down
5 changes: 1 addition & 4 deletions charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
data:
{{- if .Values.isolateComponents }}
SE_DISTRIBUTOR_HOST: {{ $distributorHost | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ metadata:
app: {{ template "seleniumGrid.keda.deleteObjectsJob.fullname" $ }}
app.kubernetes.io/name: {{ template "seleniumGrid.keda.deleteObjectsJob.fullname" $ }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
template:
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ metadata:
app: {{ template "seleniumGrid.keda.patchObjectsJob.fullname" $ }}
app.kubernetes.io/name: {{ template "seleniumGrid.keda.patchObjectsJob.fullname" $ }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{- if $.Values.autoscaling.patchObjectFinalizers.deleteObjectsScript }}
deleteObjectsScript.sh: {{- toYaml $.Values.autoscaling.patchObjectFinalizers.deleteObjectsScript | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ metadata:
app: {{ template "seleniumGrid.keda.patchObjectsJob.fullname" $ }}
app.kubernetes.io/name: {{ template "seleniumGrid.keda.patchObjectsJob.fullname" $ }}
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
template:
metadata:
Expand Down
Loading
Loading