feat: add global.commonLabels support to camunda-load-tests chart#58
feat: add global.commonLabels support to camunda-load-tests chart#58ChrisKujawa wants to merge 8 commits into
Conversation
Templates now include a commonLabels block; when no labels are set the helper renders an empty line. Update all pre-existing golden files to match the new template output so the full suite stays green.
{{- if ... }} (no trailing dash) left the newline between the if tag and
{{ tpl }} in the output, so the helper returned \n<yaml>. nindent then
prepended another \n, producing a blank line before each injected label.
Changing to {{- if ... -}} trims that newline, keeping output clean.
nindent always emits a leading newline even for empty input, producing a
blank line in the rendered YAML when global.commonLabels is not set.
Wrap each call site with {{- if .Values.global.commonLabels }} so the
nindent call is skipped entirely when no labels are configured.
There was a problem hiding this comment.
Pull request overview
This PR adds support for propagating user-defined labels (global.commonLabels) into the camunda-load-tests Helm chart so that every rendered Kubernetes resource can receive consistent metadata labels.
Changes:
- Introduces
global.commonLabelsinvalues.yamland acamunda-load-tests.commonLabelshelper in_helpers.tpl. - Injects the helper into multiple templates’
metadata.labels(and pod template labels for Deployments). - Adds Terratest golden tests and golden files to validate common-label rendering.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| charts/camunda-load-tests/values.yaml | Adds the new global.commonLabels value and documentation. |
| charts/camunda-load-tests/templates/_helpers.tpl | Adds camunda-load-tests.commonLabels helper to render global.commonLabels. |
| charts/camunda-load-tests/templates/workers.yaml | Injects common labels into Deployment metadata and pod template labels. |
| charts/camunda-load-tests/templates/starter.yaml | Injects common labels into Deployment metadata and pod template labels. |
| charts/camunda-load-tests/templates/clients-service.yaml | Injects common labels into Service and ServiceMonitor metadata labels. |
| charts/camunda-load-tests/templates/load-test-config.yaml | Injects common labels into ConfigMap metadata labels. |
| charts/camunda-load-tests/templates/credentials.yaml | Adds Secret metadata labels section for common labels. |
| charts/camunda-load-tests/test/common_labels_test.go | Adds golden tests to assert common labels are rendered. |
| charts/camunda-load-tests/test/golden/golden-saas-with-extra-config-workers.golden.yaml | Updates expected checksum output due to template changes. |
| charts/camunda-load-tests/test/golden/golden-saas-with-extra-config-starter.golden.yaml | Updates expected checksum output due to template changes. |
| charts/camunda-load-tests/test/golden/golden-credentials-workers.golden.yaml | Updates expected checksum output due to template changes. |
| charts/camunda-load-tests/test/golden/golden-credentials-starter.golden.yaml | Updates expected checksum output due to template changes. |
| charts/camunda-load-tests/test/golden/golden-credentials-credentials.golden.yaml | Updates expected Secret rendering (now includes labels:). |
| charts/camunda-load-tests/test/golden/golden-common-labels-workers.golden.yaml | New golden file validating common labels on workers Deployment. |
| charts/camunda-load-tests/test/golden/golden-common-labels-starter.golden.yaml | New golden file validating common labels on starter Deployment. |
| charts/camunda-load-tests/test/golden/golden-common-labels-clients-service.golden.yaml | New golden file validating common labels on clients Service/ServiceMonitor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| labels: | ||
| app: starter | ||
| {{- if .Values.global.commonLabels }}{{ include "camunda-load-tests.commonLabels" . | nindent 4 }}{{- end }} | ||
| spec: |
| labels: | ||
| app: {{ $workerName }} | ||
| {{- if $.Values.global.commonLabels }}{{ include "camunda-load-tests.commonLabels" $ | nindent 4 }}{{- end }} | ||
| spec: |
| labels: | ||
| app: starter | ||
| app.kubernetes.io/component: zeebe-client | ||
| {{- if .Values.global.commonLabels }}{{ include "camunda-load-tests.commonLabels" . | nindent 8 }}{{- end }} | ||
| annotations: |
| app: {{ $workerName }} | ||
| app.kubernetes.io/component: zeebe-client | ||
| {{- if $.Values.global.commonLabels }}{{ include "camunda-load-tests.commonLabels" $ | nindent 8 }}{{- end }} |
multani
left a comment
There was a problem hiding this comment.
@ChrisKujawa should we merge the camunda-load-tests.labels template and camunda-load-tests.commonLabels templates together and set by default everywhere labels: {{- include "camunda-load-tests.labels" . | nindent 4 }} (+ more labels, if needed?)
This would move the if to check if Values.global.commonLabels is set into the camunda-load-tests.labels template:
- you won't need to add it in all the target resources
- this would also remove the current double
ifyou have (once in the template, once in the resources using the template)
|
@multani do you mean this one https://github.com/camunda/camunda-load-tests-helm/blob/main/charts/camunda-load-tests/templates/_helpers.tpl#L58-L68 ? i think makes sense. Currently wondering why Starter and worker are actually not using it 🤔 |
Yes, this one. I think it could be used everywhere (also not sure why it's not the case 🤔 ) and you can integrate your new global labels into it 👍 |
|
Good point I will look into this 👍🏼 |
Summary
global.commonLabelsvalue and acamunda-load-tests.commonLabelshelper in_helpers.tplselector.matchLabelsstarter.yaml,workers.yaml, andclients-service.yamlwithcamunda.io/created-byandcamunda.io/purposelabelsMotivation
Enables the
camunda/camundaload-test setup scripts to propagate author and purpose labels toevery Kubernetes resource via
global.commonLabels:These labels are already present in
load-test-values.yaml(camunda/camunda#51880) but had noeffect until this chart added support. With both changes in place, cost attribution and logging
alerts can be driven from per-resource labels without resolving the namespace first.
Test Plan
go test ./charts/camunda-load-tests/test/...— all golden tests passglobal.commonLabelsset and verify labels appear on Pods/Deployments/Servicesselector.matchLabelson any Deployment🤖 Generated with Claude Code