Skip to content

Commit 40473e8

Browse files
authoredNov 26, 2024··
fix(Traefik Hub): compatibility with Traefik Proxy v3.2
1 parent 6bfdd50 commit 40473e8

File tree

3 files changed

+135
-16
lines changed

3 files changed

+135
-16
lines changed
 

‎traefik/templates/_helpers.tpl

+9-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ Traefik hub is based on v3.1 (v3.0 before v3.3.1) of traefik proxy, so this is a
134134
based on semverCompare
135135
*/}}
136136
{{- if $.Values.hub.token -}}
137-
{{ if and (regexMatch "v[0-9]+.[0-9]+.[0-9]+" (default "" $.Values.image.tag)) (semverCompare "<v3.3.2-0" $.Values.image.tag) -}}
138-
v3.0
139-
{{- else -}}
140-
v3.1
141-
{{- end -}}
137+
{{ $hubVersion := "v3.2" }}
138+
{{- if regexMatch "v[0-9]+.[0-9]+.[0-9]+" (default "" $.Values.image.tag) -}}
139+
{{- if semverCompare "<v3.3.2-0" $.Values.image.tag -}}
140+
{{ $hubVersion = "v3.0" }}
141+
{{- else if semverCompare "<3.7.0-0" $.Values.image.tag -}}
142+
{{ $hubVersion = "v3.1" }}
143+
{{- end -}}
144+
{{- end -}}
145+
{{ $hubVersion }}
142146
{{- else -}}
143147
{{ (split "@" (default $.Chart.AppVersion $.Values.image.tag))._0 | replace "latest-" "" | replace "experimental-" "" }}
144148
{{- end -}}

‎traefik/templates/rbac/clusterrole.yaml

-9
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,6 @@ rules:
151151
- get
152152
- list
153153
- watch
154-
{{- if (semverCompare ">=v3.1.0-0" $version) }}
155-
- apiGroups:
156-
- discovery.k8s.io
157-
resources:
158-
- endpointslices
159-
verbs:
160-
- list
161-
- watch
162-
{{- end }}
163154
- apiGroups:
164155
- gateway.networking.k8s.io
165156
resources:

‎traefik/tests/rbac-config_test.yaml

+126-2
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ tests:
736736
- list
737737
- watch
738738

739-
- it: should provide expected role rbac when k8s gw api is enabled >=v3.2.0
739+
- it: should provide expected role rbac when k8s gw api is enabled for Proxy >=v3.2.0
740740
set:
741741
image:
742742
tag: v3.2.0-rc1
@@ -794,6 +794,67 @@ tests:
794794
- get
795795
- list
796796
- watch
797+
- it: should provide expected role rbac when k8s gw api is enabled for Hub >=v3.7.0
798+
set:
799+
image:
800+
tag: v3.7.0
801+
hub:
802+
token: "xxx"
803+
providers:
804+
kubernetesGateway:
805+
enabled: true
806+
asserts:
807+
- template: rbac/clusterrole.yaml
808+
contains:
809+
path: rules
810+
content:
811+
apiGroups:
812+
- gateway.networking.k8s.io
813+
resources:
814+
- backendtlspolicies/status
815+
- gatewayclasses/status
816+
- gateways/status
817+
- grpcroutes/status
818+
- httproutes/status
819+
- tcproutes/status
820+
- tlsroutes/status
821+
verbs:
822+
- update
823+
- template: rbac/clusterrole.yaml
824+
contains:
825+
path: rules
826+
content:
827+
apiGroups:
828+
- gateway.networking.k8s.io
829+
resources:
830+
- backendtlspolicies
831+
- gatewayclasses
832+
- gateways
833+
- grpcroutes
834+
- httproutes
835+
- referencegrants
836+
- tcproutes
837+
- tlsroutes
838+
verbs:
839+
- get
840+
- list
841+
- watch
842+
- template: rbac/clusterrole.yaml
843+
contains:
844+
path: rules
845+
content:
846+
apiGroups:
847+
- ""
848+
resources:
849+
- namespaces
850+
- secrets
851+
- services
852+
- configmaps
853+
verbs:
854+
- get
855+
- list
856+
- watch
857+
797858
- it: should contain additional RBACS for hub API gateway
798859
set:
799860
image:
@@ -1080,7 +1141,7 @@ tests:
10801141
- list
10811142
- get
10821143
- watch
1083-
- it: should provide expected RBACS for version < v3.1
1144+
- it: should provide expected RBACS for Proxy version < v3.1
10841145
set:
10851146
image:
10861147
tag: v3.0.1
@@ -1110,3 +1171,66 @@ tests:
11101171
- list
11111172
- get
11121173
- watch
1174+
- it: should provide expected RBACS for Hub version <3.3.2
1175+
set:
1176+
image:
1177+
tag: v3.3.0
1178+
hub:
1179+
token: "xxx"
1180+
asserts:
1181+
- template: rbac/clusterrole.yaml
1182+
contains:
1183+
path: rules
1184+
content:
1185+
apiGroups:
1186+
- ""
1187+
resources:
1188+
- endpoints
1189+
- services
1190+
verbs:
1191+
- get
1192+
- list
1193+
- watch
1194+
- template: rbac/clusterrole.yaml
1195+
notContains:
1196+
path: rules
1197+
content:
1198+
apiGroups:
1199+
- discovery.k8s.io
1200+
resources:
1201+
- endpointslices
1202+
verbs:
1203+
- list
1204+
- get
1205+
- watch
1206+
- it: should provide expected RBACS for Hub version >3.3.2 and <3.7.0
1207+
set:
1208+
image:
1209+
tag: v3.6.0
1210+
hub:
1211+
token: "xxx"
1212+
asserts:
1213+
- template: rbac/clusterrole.yaml
1214+
notContains:
1215+
path: rules
1216+
content:
1217+
apiGroups:
1218+
- ""
1219+
resources:
1220+
- endpoints
1221+
- services
1222+
verbs:
1223+
- get
1224+
- list
1225+
- watch
1226+
- template: rbac/clusterrole.yaml
1227+
contains:
1228+
path: rules
1229+
content:
1230+
apiGroups:
1231+
- discovery.k8s.io
1232+
resources:
1233+
- endpointslices
1234+
verbs:
1235+
- list
1236+
- watch

0 commit comments

Comments
 (0)
Please sign in to comment.