Skip to content

Commit

Permalink
fix: disable ClusterRole and ClusterRoleBinding when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
BabisK authored Oct 19, 2023
1 parent 1cc6271 commit 14d4895
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion traefik/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rbac.enabled -}}
{{- if and .Values.rbac.enabled (or .Values.providers.kubernetesIngress.enabled (not .Values.rbac.namespaced)) -}}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
2 changes: 1 addition & 1 deletion traefik/templates/rbac/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rbac.enabled -}}
{{- if and .Values.rbac.enabled (or .Values.providers.kubernetesIngress.enabled (not .Values.rbac.namespaced)) -}}
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
14 changes: 14 additions & 0 deletions traefik/tests/rbac-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ tests:
path: metadata.name
pattern: ^.*-NAMESPACE$
template: rbac/clusterrolebinding.yaml
- it: should not create cluster scoped RBAC related objects when namespaced and not using ingressclass
set:
rbac:
namespaced: true
providers:
kubernetesIngress:
enabled: false
asserts:
- hasDocuments:
count: 0
template: rbac/clusterrole.yaml
- hasDocuments:
count: 0
template: rbac/clusterrolebinding.yaml

- it: should use existing ServiceAccount
set:
Expand Down

0 comments on commit 14d4895

Please sign in to comment.