-
Notifications
You must be signed in to change notification settings - Fork 87
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
[CN-993] Common label and annotation parameters for all deployed objects #388
Conversation
@@ -8,6 +8,15 @@ metadata: | |||
helm.sh/chart: {{ template "hazelcast.chart" . }} | |||
app.kubernetes.io/instance: "{{ .Release.Name }}" | |||
app.kubernetes.io/managed-by: "{{ .Release.Service }}" | |||
{{- range $key, $value := .Values.commonLabels }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use template to avoid repeating loop in every template?
We do something similar in our operator helm chart:
labels:
{{- include "hazelcast-platform-operator.labels" . | nindent 4 }}
and define it in https://github.com/hazelcast/charts/blob/master/stable/hazelcast-platform-operator/templates/_helpers.tpl#L33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to refactor it in a separate PR. We are duplicating default labels in all templates as well.
…mon-label-annotation
provides a way to add common labels and annotations to all objects deployed by the chart
Implementation Notes
To merge two maps, we are using
merge
function. eg:The reason why we are passing
nil
to the first parameter ofmerge
function is to keep the maps immutable.The first parameter of the
merge
function is destination. The new merging entries are put into the destination map.https://helm.sh/docs/chart_template_guide/function_list/#merge-mustmerge
We are passing
nil
as a destination map in order to not modify any of our existing map. In this way, the maps generated from the values.yaml and user args are not modified during the render process of templates.