feature(chart): Allow configuring labels and annotations#2443
feature(chart): Allow configuring labels and annotations#2443brookelew wants to merge 4 commits into
Conversation
73fe8c7 to
75056b8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
chart/kube-flannel/templates/rbac.yaml:55
- Same issue as above for the ClusterRoleBinding:
labels:is always emitted, but the merged label map may be empty (defaults are{}), resulting inlabels:with a null value. Make thelabels:key conditional or render an explicit empty map.
labels:
{{- with (merge .Values.flannel.rbac.clusterRoleBinding.labels .Values.flannel.rbac.labels .Values.global.commonLabels) }}
{{- toYaml . | nindent 4 }}
{{- end }}
mgfritch
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
Would you mind adding a named template (helpers file) for generating the default flannel labels?
6cdccab to
922aad2
Compare
lets users configure the labels and annotations in the Helm chart Resolves flannel-io#2442
922aad2 to
114926c
Compare
|
@mgfritch Sorry for the delay! I used some |
| set: | ||
| flannel.rbac.labels: | ||
| rbac-non-overridden-label: "rbac label should not be overridden" | ||
| rbac-overrridden-label: "rbac label should be overridden" |
| rbac-overridden-label: "rbac label has been overridden" | ||
| flannel.rbac.annotations: | ||
| rbac-non-overridden-annotation: "rbac annotation should not be overridden" | ||
| rbac-overrridden-annotation: "rbac annotation should be overridden" |
| app: "flannel" | ||
| tier: "node" | ||
| app.kubernetes.io/name: {{ include "flannel.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} |
|
|
||
| {{- define "flannel.selectorLabels" -}} | ||
| app: "flannel" | ||
| tier: "node" | ||
| app.kubernetes.io/name: {{ include "flannel.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| {{- end -}} |
There was a problem hiding this comment.
| {{- define "flannel.selectorLabels" -}} | |
| app: "flannel" | |
| tier: "node" | |
| app.kubernetes.io/name: {{ include "flannel.name" . }} | |
| app.kubernetes.io/instance: {{ .Release.Name }} | |
| {{- end -}} | |
| +{{/* Immutable selector labels */}} | |
| {{- define "flannel.selectorLabels" -}} | |
| app: "flannel" | |
| {{- end -}} |
sorry, this one is my fault, but adding labels here will cause the DaemonSet to fail during helm upgrade.
Can we move them into the common labels below?
| helm.sh/chart: {{ include "flannel.chart" . }} | ||
| app.kubernetes.io/version: {{ .Chart.AppVersion }} | ||
| app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
| {{ include "flannel.selectorLabels" . }} |
There was a problem hiding this comment.
| helm.sh/chart: {{ include "flannel.chart" . }} | |
| app.kubernetes.io/version: {{ .Chart.AppVersion }} | |
| app.kubernetes.io/managed-by: {{ .Release.Service }} | |
| {{ include "flannel.selectorLabels" . }} | |
| tier: "node" | |
| helm.sh/chart: {{ include "flannel.chart" . }} | |
| app.kubernetes.io/name: {{ include "flannel.name" . }} | |
| app.kubernetes.io/instance: {{ .Release.Name }} | |
| {{ include "flannel.selectorLabels" . }} |
Add common labels here instead of in the (immutable) selector labels
| {{- include "flannel.selectorLabels" . | nindent 6 }} | ||
| template: | ||
| metadata: | ||
| {{- with (merge .Values.flannel.podLabels (include "flannel.labels" . | fromYaml)) }} |
There was a problem hiding this comment.
| {{- with (merge .Values.flannel.podLabels (include "flannel.labels" . | fromYaml)) }} | |
| {{- with (merge (include "flannel.labels" . | fromYaml) .Values.flannel.podLabels) }} |
reversing the order should ensure the the match labels cannot be overwritten by the pod labels
| @@ -0,0 +1,95 @@ | |||
| suite: test labels annotations overrides | |||
There was a problem hiding this comment.
Thanks for adding these!
Can we also add a test to ensure the selector labels are immutable? Feel free to reuse (or modify) this if it helps: mgfritch@61396f7
@brookelew No worries! The I think this should be ready to finally merge after resolving the last few small revisions above. This PR will be a really nice addition to modernize the charts! 😀 |
lets users configure the labels and annotations in the Helm chart
Resolves #2442
Description
Feature for the Helm chart that lets users modify the labels and annotations of deployed resources.
Todos
Release Note