Skip to content

Commit

Permalink
fix: namespaced RBACs hub api gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatur committed Jul 24, 2024
1 parent 9240475 commit 50c24e5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion traefik/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ rules:
- update
{{- end -}}
{{- end -}}
{{- if .Values.hub.token }}
{{- if and .Values.hub.token .Values.hub.apimanagement.enabled }}
- apiGroups:
- hub.traefik.io
resources:
Expand Down
33 changes: 33 additions & 0 deletions traefik/templates/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,38 @@ rules:
verbs:
- update
{{- end -}}
{{- if $.Values.hub.token }}
- apiGroups:
- ""
resources:
- services
- endpoints
- namespaces
- pods
verbs:
- get
- list
- watch
- apiGroups:
- discovery.k8s.io
resources:
- endpointslices
verbs:
- get
- list
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
{{- end }}
{{- end -}}
{{- end -}}
6 changes: 4 additions & 2 deletions traefik/templates/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
{{- fail "ERROR: Before traefik v3.1.0-rc3, kubernetesGateway is experimental. Enable it by setting experimental.kubernetesGateway.enabled to true" -}}
{{- end }}

{{- if and .Values.hub.token (and .Values.rbac.enabled .Values.rbac.namespaced) }}
{{- fail "ERROR: Currently traefik-hub doesn't support namespaced RBACs" -}}
{{- if .Values.hub.token }}
{{- if and .Values.hub.apimanagement.enabled (and .Values.rbac.enabled .Values.rbac.namespaced) }}
{{- fail "ERROR: Currently Traefik Hub doesn't support namespaced RBACs" -}}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions traefik/tests/rbac-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,8 @@ tests:
set:
hub:
token: xxx
apimanagement:
enabled: true
asserts:
- template: rbac/clusterrole.yaml
contains:
Expand Down
6 changes: 4 additions & 2 deletions traefik/tests/requirements-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ tests:
enabled: true
asserts:
- notFailedTemplate: {}
- it: should not fail when using traefik-hub with namespaced RBACs
- it: should fail when using traefik-hub API management with namespaced RBACs
set:
hub:
token: xxx
apimanagement:
enabled: true
rbac:
namespaced: true
asserts:
- failedTemplate:
errorMessage: "ERROR: Currently traefik-hub doesn't support namespaced RBACs"
errorMessage: "ERROR: Currently Traefik Hub doesn't support namespaced RBACs"

0 comments on commit 50c24e5

Please sign in to comment.