diff --git a/traefik/Chart.yaml b/traefik/Chart.yaml index d9a46e649..b70280cd5 100644 --- a/traefik/Chart.yaml +++ b/traefik/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: traefik description: A Traefik based Kubernetes ingress controller type: application -version: 20.4.0 +version: 20.4.1 appVersion: v2.9.4 keywords: - traefik diff --git a/traefik/templates/NOTES.txt b/traefik/templates/NOTES.txt index 389b4ce45..98c67a7fe 100644 --- a/traefik/templates/NOTES.txt +++ b/traefik/templates/NOTES.txt @@ -1,17 +1,17 @@ -Traefik Proxy {{ .Chart.AppVersion }} has been deployed successfully -on {{ .Release.Namespace }} namespace ! +Traefik Proxy {{ .Chart.AppVersion }} has been deployed successfully +on {{ template "traefik.namespace" . }} namespace ! {{- if .Values.hub.enabled }} -{{- if coalesce (ne .Release.Namespace "hub-agent") .Values.hub.tunnelPort (ne (.Values.ports.metrics.port | int) 9100) }} +{{- if coalesce (ne (include "traefik.namespace" .) "hub-agent") .Values.hub.tunnelPort (ne (.Values.ports.metrics.port | int) 9100) }} -Traefik Hub integration is enabled ! With your specific parameters, +Traefik Hub integration is enabled ! With your specific parameters, `metricsURL`, `tunnelHost` and `tunnelPort` needs to be set accordingly on hub-agent Helm Chart. Based on this Chart, it should be: - --set controllerDeployment.traefik.metricsURL=traefik-hub.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.ports.metrics.port }}/metrics - --set tunnelDeployment.traefik.tunnelHost=traefik-hub.{{ .Release.Namespace }}.svc.cluster.local + --set controllerDeployment.traefik.metricsURL=traefik-hub.{{ template "traefik.namespace" . }}.svc.cluster.local:{{ .Values.ports.metrics.port }}/metrics + --set tunnelDeployment.traefik.tunnelHost=traefik-hub.{{ template "traefik.namespace" . }}.svc.cluster.local --set tunnelDeployment.traefik.tunnelPort={{ default 9901 .Values.hub.tunnelPort }} See https://doc.traefik.io/traefik-hub/install/#traefik-hub-agent-install-with-helmchart diff --git a/traefik/templates/dashboard-hook-ingressroute.yaml b/traefik/templates/dashboard-hook-ingressroute.yaml index bc09dc9cc..a95786407 100644 --- a/traefik/templates/dashboard-hook-ingressroute.yaml +++ b/traefik/templates/dashboard-hook-ingressroute.yaml @@ -7,7 +7,7 @@ metadata: annotations: helm.sh/hook: "post-install,post-upgrade" meta.helm.sh/release-name: {{ .Release.Name }} - meta.helm.sh/release-namespace: {{ .Release.Namespace }} + meta.helm.sh/release-namespace: {{ template "traefik.namespace" . }} {{- with .Values.ingressRoute.dashboard.annotations }} {{- toYaml . | nindent 4 }} {{- end }} diff --git a/traefik/templates/rbac/clusterrolebinding.yaml b/traefik/templates/rbac/clusterrolebinding.yaml index a4d196e05..b1aa3d651 100644 --- a/traefik/templates/rbac/clusterrolebinding.yaml +++ b/traefik/templates/rbac/clusterrolebinding.yaml @@ -13,5 +13,5 @@ roleRef: subjects: - kind: ServiceAccount name: {{ include "traefik.serviceAccountName" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ template "traefik.namespace" . }} {{- end -}} diff --git a/traefik/templates/rbac/rolebinding.yaml b/traefik/templates/rbac/rolebinding.yaml index 8429c8b64..91334b4b2 100644 --- a/traefik/templates/rbac/rolebinding.yaml +++ b/traefik/templates/rbac/rolebinding.yaml @@ -13,5 +13,5 @@ roleRef: subjects: - kind: ServiceAccount name: {{ include "traefik.serviceAccountName" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ template "traefik.namespace" . }} {{- end -}} diff --git a/traefik/templates/servicemonitor.yaml b/traefik/templates/servicemonitor.yaml index 015dcf88d..d5fea4861 100644 --- a/traefik/templates/servicemonitor.yaml +++ b/traefik/templates/servicemonitor.yaml @@ -56,7 +56,7 @@ spec: {{ else }} namespaceSelector: matchNames: - - {{ .Release.Namespace }} + - {{ template "traefik.namespace" . }} {{- end }} selector: matchLabels: diff --git a/traefik/tests/notes_test.yaml b/traefik/tests/notes_test.yaml new file mode 100644 index 000000000..af088fe8a --- /dev/null +++ b/traefik/tests/notes_test.yaml @@ -0,0 +1,50 @@ +suite: NOTES.txt output +templates: + - NOTES.txt +tests: + - it: should use helm managed namespace in release notes output + set: + rbac: + namespaced: true + asserts: + - equal: + path: raw + value: | + + + Traefik Proxy v2.9.4 has been deployed successfully + on NAMESPACE namespace ! + - it: should use helm managed namespace in release notes output + set: + namespaceOverride: "traefik-ns-override" + asserts: + - equal: + path: raw + value: | + + + Traefik Proxy v2.9.4 has been deployed successfully + on traefik-ns-override namespace ! + + - it: should output hub related notes + set: + hub: + enabled: true + asserts: + - equal: + path: raw + value: | + + + Traefik Proxy v2.9.4 has been deployed successfully + on NAMESPACE namespace ! + + Traefik Hub integration is enabled ! With your specific parameters, + `metricsURL`, `tunnelHost` and `tunnelPort` needs to be set accordingly + on hub-agent Helm Chart. Based on this Chart, it should be: + + --set controllerDeployment.traefik.metricsURL=traefik-hub.NAMESPACE.svc.cluster.local:9100/metrics + --set tunnelDeployment.traefik.tunnelHost=traefik-hub.NAMESPACE.svc.cluster.local + --set tunnelDeployment.traefik.tunnelPort=9901 + + See https://doc.traefik.io/traefik-hub/install/#traefik-hub-agent-install-with-helmchart diff --git a/traefik/tests/rbac-config_test.yaml b/traefik/tests/rbac-config_test.yaml index 9be937141..cf2e5d380 100644 --- a/traefik/tests/rbac-config_test.yaml +++ b/traefik/tests/rbac-config_test.yaml @@ -191,3 +191,41 @@ tests: path: metadata.namespace value: "traefik-ns-override" template: rbac/serviceaccount.yaml + - it: should use helm managed namespace for clusterrolebinding sa + set: + rbac: + namespaced: true + asserts: + - equal: + path: subjects[0].namespace + value: NAMESPACE + template: rbac/clusterrolebinding.yaml + - it: should accept overridden namespace for clusterrolebinding sa + set: + namespaceOverride: "traefik-ns-override" + rbac: + namespaced: true + asserts: + - equal: + path: subjects[0].namespace + value: "traefik-ns-override" + template: rbac/clusterrolebinding.yaml + - it: should use helm managed namespace for rolebinding sa + set: + rbac: + namespaced: true + asserts: + - equal: + path: subjects[0].namespace + value: NAMESPACE + template: rbac/rolebinding.yaml + - it: should accept overridden namespace for rolebinding sa + set: + namespaceOverride: "traefik-ns-override" + rbac: + namespaced: true + asserts: + - equal: + path: subjects[0].namespace + value: "traefik-ns-override" + template: rbac/rolebinding.yaml