Skip to content

Commit

Permalink
fix(Traefik Hub): missing RBACs for Traefik Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 committed Jul 29, 2024
1 parent ab2db23 commit ed80c4c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion traefik/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Traefik hub is based on v3.1 (v3.0 before v3.3.1) of traefik proxy, so this is a
based on semverCompare
*/}}
{{- if $.Values.hub.token -}}
{{ if and (regexMatch "v[0-9]+.[0-9]+.[0-9]+" (default "" $.Values.image.tag)) (semverCompare "<=v3.3.1-0" $.Values.image.tag) -}}
{{ if and (regexMatch "v[0-9]+.[0-9]+.[0-9]+" (default "" $.Values.image.tag)) (semverCompare "<v3.3.2-0" $.Values.image.tag) -}}
v3.0
{{- else -}}
v3.1
Expand Down
9 changes: 9 additions & 0 deletions traefik/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ rules:
{{- /* not .Values.rbac.namespace */}}
{{- end }}
{{- if .Values.hub.token }}
{{- if or (semverCompare ">=v3.1.0-0" $version) .Values.hub.apimanagement.enabled }}
- apiGroups:
- ""
resources:
- endpoints
verbs:
- list
- watch
{{- end }}
- apiGroups:
- ""
resources:
Expand Down
41 changes: 41 additions & 0 deletions traefik/tests/rbac-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,17 @@ tests:
verbs:
- list
- watch
- template: rbac/clusterrole.yaml
contains:
path: rules
content:
apiGroups:
- ""
resources:
- endpoints
verbs:
- list
- watch

- it: should not contain additional RBACS for hub > 3.3.1 API management
set:
Expand All @@ -1351,6 +1362,36 @@ tests:
verbs:
- list
- watch
- template: rbac/clusterrole.yaml
contains:
path: rules
content:
apiGroups:
- ""
resources:
- endpoints
verbs:
- list
- watch

- it: should not contain additional RBACS for hub <= 3.3.1 API gateway
set:
image:
tag: v3.3.1
hub:
token: xxx
asserts:
- template: rbac/clusterrole.yaml
notContains:
path: rules
content:
apiGroups:
- ""
resources:
- endpoints
verbs:
- list
- watch

- it: should provide expected namespace'd RBACS for version < v3.1
set:
Expand Down

0 comments on commit ed80c4c

Please sign in to comment.