Skip to content

Commit 114926c

Browse files
committed
Use _helpers.tpl for global labels
1 parent 6ffcdbb commit 114926c

5 files changed

Lines changed: 22 additions & 14 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{/* Labels common to all resources */}}
2+
{{- define "flannel.labels" -}}
3+
app: {{ .Chart.Name | quote }}
4+
tier: node
5+
{{- with .Values.global.commonLabels }}
6+
{{ toYaml . }}
7+
{{- end }}
8+
{{- end -}}

chart/kube-flannel/templates/config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ metadata:
44
name: kube-flannel-cfg
55
namespace: {{ .Release.Namespace }}
66
labels:
7-
tier: node
8-
app: flannel
9-
{{- with merge .Values.flannel.configMap.labels .Values.global.commonLabels }}
7+
{{- include "flannel.labels" . | nindent 4 }}
8+
{{- with .Values.flannel.configMap.labels }}
109
{{- toYaml . | nindent 4 }}
1110
{{- end }}
1211
{{- with merge .Values.flannel.configMap.annotations .Values.global.commonAnnotations }}

chart/kube-flannel/templates/daemonset.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ metadata:
44
name: kube-flannel-ds
55
namespace: {{ .Release.Namespace }}
66
labels:
7-
tier: node
8-
app: flannel
9-
{{- with merge .Values.flannel.daemonSet.labels .Values.global.commonLabels }}
7+
{{- include "flannel.labels" . | nindent 4 }}
8+
{{- with .Values.flannel.daemonSet.labels }}
109
{{- toYaml . | nindent 4 }}
1110
{{- end }}
1211
{{- with merge .Values.flannel.daemonSet.annotations .Values.global.commonAnnotations }}
@@ -16,13 +15,12 @@ metadata:
1615
spec:
1716
selector:
1817
matchLabels:
19-
app: flannel
18+
{{- include "flannel.labels" . | nindent 6 }}
2019
template:
2120
metadata:
2221
labels:
23-
tier: node
24-
app: flannel
25-
{{- with merge .Values.flannel.podLabels .Values.global.commonLabels }}
22+
{{- include "flannel.labels" . | nindent 8 }}
23+
{{- with .Values.flannel.podLabels }}
2624
{{- toYaml . | nindent 8 }}
2725
{{- end }}
2826
{{- with merge .Values.flannel.podAnnotations .Values.global.commonAnnotations }}

chart/kube-flannel/templates/rbac.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ apiVersion: rbac.authorization.k8s.io/v1
33
metadata:
44
name: flannel
55
labels:
6-
{{- with (merge .Values.flannel.rbac.clusterRole.labels .Values.flannel.rbac.labels .Values.global.commonLabels) }}
6+
{{- include "flannel.labels" . | nindent 4 }}
7+
{{- with (merge .Values.flannel.rbac.clusterRole.labels .Values.flannel.rbac.labels) }}
78
{{- toYaml . | nindent 4 }}
89
{{- end }}
910
{{- with (merge .Values.flannel.rbac.clusterRole.annotations .Values.flannel.rbac.annotations .Values.global.commonAnnotations) }}
@@ -50,7 +51,8 @@ apiVersion: rbac.authorization.k8s.io/v1
5051
metadata:
5152
name: flannel
5253
labels:
53-
{{- with (merge .Values.flannel.rbac.clusterRoleBinding.labels .Values.flannel.rbac.labels .Values.global.commonLabels) }}
54+
{{- include "flannel.labels" . | nindent 4 }}
55+
{{- with (merge .Values.flannel.rbac.clusterRoleBinding.labels .Values.flannel.rbac.labels) }}
5456
{{- toYaml . | nindent 4 }}
5557
{{- end }}
5658
{{- with (merge .Values.flannel.rbac.clusterRoleBinding.annotations .Values.flannel.rbac.annotations .Values.global.commonAnnotations) }}

chart/kube-flannel/templates/serviceaccount.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ kind: ServiceAccount
33
metadata:
44
name: flannel
55
namespace: {{ .Release.Namespace }}
6-
{{- with merge .Values.flannel.serviceAccount.labels .Values.global.commonLabels }}
76
labels:
7+
{{- include "flannel.labels" . | nindent 4 }}
8+
{{- with .Values.flannel.serviceAccount.labels }}
89
{{- toYaml . | nindent 4 }}
9-
{{- end }}
10+
{{- end }}
1011
{{- with merge .Values.flannel.serviceAccount.annotations .Values.global.commonAnnotations }}
1112
annotations:
1213
{{- toYaml . | nindent 4 }}

0 commit comments

Comments
 (0)