Skip to content

Commit

Permalink
🐛 fix namespace references to support namespaceOverride
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-haley authored Nov 21, 2022
1 parent 4a4df55 commit c7f6c3f
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 11 deletions.
2 changes: 1 addition & 1 deletion traefik/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions traefik/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion traefik/templates/dashboard-hook-ingressroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion traefik/templates/rbac/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "traefik.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ template "traefik.namespace" . }}
{{- end -}}
2 changes: 1 addition & 1 deletion traefik/templates/rbac/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "traefik.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ template "traefik.namespace" . }}
{{- end -}}
2 changes: 1 addition & 1 deletion traefik/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
{{ else }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
- {{ template "traefik.namespace" . }}
{{- end }}
selector:
matchLabels:
Expand Down
50 changes: 50 additions & 0 deletions traefik/tests/notes_test.yaml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions traefik/tests/rbac-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c7f6c3f

Please sign in to comment.