Skip to content

Commit 25c25c6

Browse files
ivanmatmatioktalz
authored andcommitted
MINOR: install or accommodate yaml files for TLSRoute
1 parent f064b32 commit 25c25c6

File tree

9 files changed

+91
-88
lines changed

9 files changed

+91
-88
lines changed

example/deploy/hug/rbac.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ metadata:
1111
name: haproxy-unified-gateway
1212
rules:
1313
- apiGroups:
14-
- "apiextensions.k8s.io"
14+
- "apiextensions.k8s.io"
1515
resources:
16-
- customresourcedefinitions
16+
- customresourcedefinitions
1717
verbs:
18-
- get
19-
- list
20-
- watch
21-
- update
18+
- get
19+
- list
20+
- watch
21+
- update
2222
- apiGroups:
2323
- ""
2424
resources:
@@ -102,7 +102,7 @@ rules:
102102
- list
103103
- watch
104104
- apiGroups:
105-
- "apps"
105+
- "apps"
106106
resources:
107107
- replicasets
108108
- deployments
@@ -111,38 +111,40 @@ rules:
111111
- get
112112
- list
113113
- apiGroups:
114-
- gateway.networking.k8s.io
114+
- gateway.networking.k8s.io
115115
resources:
116116
- gatewayclasses
117117
- gateways
118118
- httproutes
119119
- referencegrants
120120
- grpcroutes
121+
- tlsroutes
121122
verbs:
122123
- list
123124
- watch
124125
- apiGroups:
125-
- gateway.networking.k8s.io
126+
- gateway.networking.k8s.io
126127
resources:
127128
- gatewayclasses/status
128129
- gateways/status
129130
- httproutes/status
130131
- referencegrants/status
131132
- grpcroutes/status
133+
- tlsroutes/status
132134
verbs:
133135
- get
134136
- update
135137
- patch
136138
- apiGroups:
137-
- coordination.k8s.io
139+
- coordination.k8s.io
138140
resources:
139141
- leases
140142
verbs:
141143
- create
142144
- get
143145
- update
144146
- apiGroups:
145-
- gate.v3.haproxy.org
147+
- gate.v3.haproxy.org
146148
resources:
147149
- huggates
148150
- hugconfs
@@ -151,7 +153,6 @@ rules:
151153
- get
152154
- list
153155
- watch
154-
155156
---
156157
kind: ClusterRoleBinding
157158
apiVersion: rbac.authorization.k8s.io/v1

k8s/gate/haproxy/backends.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,10 @@ func (b *HaproxyConfMgrImpl) cleanupUnreferencedBackendsForHTTPRoutes(ownerType
483483
return nil
484484
}
485485

486+
//revive:disable:flag-parameter
486487
func (b *HaproxyConfMgrImpl) newBackend(backendName string, md metadata.MetaData,
487-
backendRef gatewayv1.HTTPBackendRef, namespace string, isHTTPBackend bool) (*models.Backend, error) {
488+
backendRef gatewayv1.HTTPBackendRef, namespace string, isHTTPBackend bool,
489+
) (*models.Backend, error) {
488490
// First, we merge the Backend CRDs from filters, if there are some
489491
// Backend CRDs are defined in the Filters of type: ExtensionRef
490492
// We gather all those filters, merge them and apply them

k8s/gate/haproxy/routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ func (b *RouteMgrImpl) onUpsertedTLSRoute(routeKey k8stypes.NamespacedName, rout
7171
}
7272

7373
func (b *RouteMgrImpl) onValidTLSRouteUpserted(_ k8stypes.NamespacedName,
74-
tlsRoute *tree.TLSRoute, mapSNI *maps.MapData, acceptedHostnamesForRoute []string) error {
75-
74+
tlsRoute *tree.TLSRoute, mapSNI *maps.MapData, acceptedHostnamesForRoute []string,
75+
) error {
7676
for _, tlsRouteRule := range tlsRoute.Rules {
7777
// if !rule.Valid {
7878
// find the old rule in route.TreeStatus.OldTreeResource.Rules, name is optional

k8s/gate/tree/HTTPRoute.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (r *HTTPRoute) checkParentRef(parentRef gatewayv1.ParentReference, controll
222222
}
223223
}
224224

225-
// Récupère le Gateway correspondant
225+
// Get the Gateway
226226
gwKey := GetParentRefNamespacedName(parentRef, r.K8sResource)
227227
treeGw, ok := controllerStore.GateTree.Gateways[gwKey]
228228
if ok && treeGw.TreeStatus.Status == store.StatusDeleted {
@@ -240,7 +240,7 @@ func (r *HTTPRoute) checkParentRef(parentRef gatewayv1.ParentReference, controll
240240
}
241241
}
242242

243-
// Collecte les listeners attachables
243+
// Compute the list of attachable Listeners
244244
attachableListeners := make([]*Listener, 0)
245245
if parentRef.SectionName != nil {
246246
listener, ok := treeGw.Listeners[string(*parentRef.SectionName)]
@@ -262,35 +262,35 @@ func (r *HTTPRoute) checkParentRef(parentRef gatewayv1.ParentReference, controll
262262
conds := generic.Conditions{}
263263

264264
for _, listener := range attachableListeners {
265-
// Vérifie la validité du listener
265+
// Check if the listener is valid
266266
if !listener.Valid {
267267
conds.MergeOverrideConditions(rc.ConditionNotAcceptedNoMatchingParent())
268268
continue
269269
}
270270

271-
// Vérifie le hostname
271+
// Check hostname
272272
if !matchHostname(r.K8sResource.Spec.Hostnames, listener.K8sResource.Hostname) {
273273
conds.MergeOverrideConditions(rc.ConditionNotAcceptedNoMatchingHostname())
274274
continue
275275
}
276276

277-
// Vérifie le type de route autorisé
277+
// Check if the route kind is allowed
278278
if !r.isAllowedRouteKind(listener, controllerStore.ExtractGVK) {
279279
conds.MergeOverrideConditions(rc.ConditionNotAcceptedRouteReasonNotAllowedByListeners())
280280
continue
281281
}
282282

283-
// Listener valide, attache la route
283+
// Add the route to the listener
284284
listener.addAttachedRoute(client.ObjectKeyFromObject(r.K8sResource), controllerStore)
285285
validListeners = append(validListeners, listener)
286286

287-
// Met à jour la KeyMap r.Listeners
287+
// Add the listener to the parentRef
288288
existing, _ := r.Listeners.Get(parentRef)
289289
existing = append(existing, listener)
290290
r.Listeners.Set(parentRef, existing)
291291
}
292292

293-
// Si aucun listener valide, retourne les conditions cumulées
293+
// If no listener is valid
294294
if len(validListeners) == 0 {
295295
return checkParentRefResult{
296296
Managed: true,
@@ -299,7 +299,7 @@ func (r *HTTPRoute) checkParentRef(parentRef gatewayv1.ParentReference, controll
299299
}
300300
}
301301

302-
// Au moins un listener valide
302+
// At least one listener is valid
303303
return checkParentRefResult{
304304
Managed: true,
305305
Valid: true,

k8s/gate/utils/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ func GetNamespacedName(name, namespace, defaultNamespace string) types.Namespace
212212
func MatchTLSHostnames(listenerHostname *string, routeHostnames []string) []string {
213213
// If the listener hostname is not set, it matches any route hostname.
214214
if listenerHostname == nil {
215-
216215
return routeHostnames
217216
}
218217

taskfile/.vars.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#https://taskfile.dev/
2-
version: '3'
2+
version: "3"
33

44
env:
55
KUBECTL_VERSION: v1.34.1
66
K8S_VERSION: v1.34.0
77
ENVTEST_VERSION: v1.34.0 # https://raw.githubusercontent.com/kubernetes-sigs/controller-tools/master/envtest-releases.yaml
8-
CLUSTER_NAME: "{{ default \"dev-controller\" .CLUSTER_NAME}}"
9-
DOCKER_FILE: "{{ default \"-build/Dockerfile\" .DOCKER_FILE}}"
8+
CLUSTER_NAME: '{{ default "dev-controller" .CLUSTER_NAME}}'
9+
DOCKER_FILE: '{{ default "-build/Dockerfile" .DOCKER_FILE}}'
1010
TMP: tmp
11-
GATEWAYAPI_CRDS_DOWNLOAD_URL: https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.3.0/standard-install.yaml
11+
GATEWAYAPI_STANDARD_CRDS_DOWNLOAD_URL: https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.3.0/standard-install.yaml
12+
GATEWAYAPI_EXPERIMENTAL_CRDS_DOWNLOAD_URL: https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.3.0/experimental-install.yaml
1213

1314
vars:
1415
CONFIG_DIR: "example/deploy"

taskfile/envtest.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#https://taskfile.dev/
2-
version: '3'
2+
version: "3"
33

44
tasks:
55
download-gateway-crds:
6-
silent: true
7-
desc: Download Gateway API CRDs and split into individual files
8-
vars:
9-
OUTDIR: test/integration/api
10-
cmds:
11-
- mkdir -p /{{.TMP}}
12-
- curl -L -o /{{.TMP}}/standard-install.yaml {{.GATEWAYAPI_CRDS_DOWNLOAD_URL}}
13-
- cd /{{.TMP}} && csplit --elide-empty-files -f gatewayapicrd- -z --suffix-format='%02d.yaml' standard-install.yaml "/^---$/" "{*}"
14-
- mkdir -p crds
15-
- mv /{{.TMP}}/gatewayapicrd-* {{.OUTDIR}}
6+
silent: true
7+
desc: Download Gateway API CRDs and split into individual files
8+
vars:
9+
OUTDIR: test/integration/api
10+
cmds:
11+
- mkdir -p /{{.TMP}}
12+
- curl -L -o /{{.TMP}}/standard-install.yaml {{.GATEWAYAPI_STANDARD_CRDS_DOWNLOAD_URL}}
13+
- cd /{{.TMP}} && csplit --elide-empty-files -f gatewayapicrd- -z --suffix-format='%02d.yaml' standard-install.yaml "/^---$/" "{*}"
14+
- mkdir -p crds
15+
- mv /{{.TMP}}/gatewayapicrd-* {{.OUTDIR}}

taskfile/k0s.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
#https://taskfile.dev/
2-
version: '3'
2+
version: "3"
33

44
tasks:
5-
65
k0s-create-cluster:
76
#internal: true
87
# deps:
98
# - task: check-go-tool
109
# vars:
1110
# TOOL: KIND
1211
silent: true
13-
desc: 'create a k0s cluster with controller'
12+
desc: "create a k0s cluster with controller"
1413
status:
1514
- task check-if-ci-env # check if we are in CI_ENV, if we are, skip this task
1615
vars:
17-
kind: '{{.TMP}}/kind/{{.KIND_VERSION}}/kind'
18-
dir: 'ci/k0s' # this file is imported so its fine
16+
kind: "{{.TMP}}/kind/{{.KIND_VERSION}}/kind"
17+
dir: "ci/k0s" # this file is imported so its fine
1918
cmds:
2019
# - docker-compose down --volumes --remove-orphans || true
2120
# - docker compose up -d
@@ -29,12 +28,12 @@ tasks:
2928
# vars:
3029
# TOOL: KIND
3130
silent: true
32-
desc: 'create a k0s cluster with controller'
31+
desc: "create a k0s cluster with controller"
3332
status:
3433
- task check-if-ci-env # check if we are in CI_ENV, if we are, skip this task
3534
vars:
36-
kind: '{{.TMP}}/kind/{{.KIND_VERSION}}/kind'
37-
dir: 'ci/k0s' # this file is imported so its fine
35+
kind: "{{.TMP}}/kind/{{.KIND_VERSION}}/kind"
36+
dir: "ci/k0s" # this file is imported so its fine
3837
cmds:
3938
- echo -n "Waiting for k0s to be ready "
4039
- |
@@ -63,15 +62,15 @@ tasks:
6362
- kubectl get pods -A
6463

6564
k0s-controller-build:
66-
desc: ''
65+
desc: ""
6766
internal: true
6867
dir: cmd/controller
6968
cmds:
7069
- CGO_ENABLED=0 go build -buildvcs=true -o ../../build/kubernetes-controller .
7170

7271
k0s-build-controller-image-dev:
7372
#internal: true
74-
desc: 'build docker image of controller'
73+
desc: "build docker image of controller"
7574
deps:
7675
- task: k0s-controller-build
7776
status:
@@ -82,7 +81,7 @@ tasks:
8281

8382
k0s-build-controller-image-build-in-docker:
8483
#internal: true
85-
desc: 'build docker image of controller'
84+
desc: "build docker image of controller"
8685
deps:
8786
- task: k0s-controller-build
8887
status:
@@ -93,17 +92,17 @@ tasks:
9392

9493
k0s-build-echo-image:
9594
internal: true
96-
desc: 'build docker image of echo service'
95+
desc: "build docker image of echo service"
9796
dir: ci/http-echo
9897
status:
99-
- '[ -f ../../.local/tar/echo.tar ]'
98+
- "[ -f ../../.local/tar/echo.tar ]"
10099
cmds:
101100
- pwd
102101
- docker build --build-arg TARGETPLATFORM={{.TARGETPLATFORM}} -t haproxytech/http-echo .
103102

104103
k0s-delete:
105-
desc: 'delete a k0s cluster'
106-
dir: 'ci/k0s' # this file is imported so its fine
104+
desc: "delete a k0s cluster"
105+
dir: "ci/k0s" # this file is imported so its fine
107106
silent: true
108107
cmds:
109108
- sh stop-k0s.sh
@@ -113,29 +112,29 @@ tasks:
113112
internal: true
114113
deps:
115114
- task: k0s-build-echo-image
116-
desc: 'create tar of echo image'
115+
desc: "create tar of echo image"
117116
status:
118-
- '[ -f .local/tar/echo.tar ]'
117+
- "[ -f .local/tar/echo.tar ]"
119118
cmds:
120119
- mkdir -p .local/tar
121120
- docker save haproxytech/http-echo:latest -o .local/tar/echo.tar
122121

123122
k0s-echo-upload:
124-
desc: 'upload echo image to k0s cluster'
123+
desc: "upload echo image to k0s cluster"
125124
silent: true
126125
internal: true
127126
cmds:
128127
- docker cp .local/tar/echo.tar k0s-hug-controller:/tmp/
129128
- docker exec k0s-hug-controller k0s ctr images import /tmp/echo.tar
130129

131130
k0s-create:
132-
desc: 'create a k0s cluster with HUG and one example app'
131+
desc: "create a k0s cluster with HUG and one example app"
133132
silent: true
134133
vars:
135134
# can be set to 'k0s-build-controller-image-build-in-docker' if you want to build in the docker image
136-
CONTROLLER_BUILD_TASK: 'k0s-build-controller-image-dev'
137-
kubectl: '{{.TMP}}/kubectl/{{.KUBECTL_VERSION}}/kubectl'
138-
kind: '{{.TMP}}/kind/{{.KIND_VERSION}}/kind'
135+
CONTROLLER_BUILD_TASK: "k0s-build-controller-image-dev"
136+
kubectl: "{{.TMP}}/kubectl/{{.KUBECTL_VERSION}}/kubectl"
137+
kind: "{{.TMP}}/kind/{{.KIND_VERSION}}/kind"
139138
deps:
140139
- task: check-go-tool
141140
vars:
@@ -145,7 +144,7 @@ tasks:
145144
- task: delimiter
146145
- task: k0s-create-cluster
147146
- task: delimiter
148-
- task: '{{ .CONTROLLER_BUILD_TASK }}'
147+
- task: "{{ .CONTROLLER_BUILD_TASK }}"
149148
- docker save haproxytech/haproxy-unified-gateway:latest -o hug.tar
150149
- task: k0s-echo-create-tar
151150
# - task: delimiter
@@ -164,7 +163,8 @@ tasks:
164163
- task: delimiter
165164
- echo "Install custom resource definitions ..."
166165
- echo "Install Gateway API CRDs"
167-
- /{{.kubectl}} apply -f {{.GATEWAYAPI_CRDS_DOWNLOAD_URL}}
166+
- /{{.kubectl}} apply -f {{.GATEWAYAPI_STANDARD_CRDS_DOWNLOAD_URL}}
167+
- /{{.kubectl}} apply -f {{.GATEWAYAPI_EXPERIMENTAL_CRDS_DOWNLOAD_URL}}
168168
- echo "Install Gateway API Controller CRDs"
169169
- /{{.kubectl}} apply -f {{.CONFIG_DIR}}/crd-update/rbac.yaml
170170
- /{{.kubectl}} apply -f {{.CONFIG_DIR}}/crd-update/job-crd.yaml
@@ -187,11 +187,11 @@ tasks:
187187
vars:
188188
TOOL: KIND
189189
- task: check-kubectl
190-
desc: 'redeploy a KinD cluster with IC'
190+
desc: "redeploy a KinD cluster with IC"
191191
silent: true
192192
vars:
193-
kubectl: '{{.TMP}}/kubectl/{{.KUBECTL_VERSION}}/kubectl'
194-
kind: '{{.TMP}}/kind/{{.KIND_VERSION}}/kind'
193+
kubectl: "{{.TMP}}/kubectl/{{.KUBECTL_VERSION}}/kubectl"
194+
kind: "{{.TMP}}/kind/{{.KIND_VERSION}}/kind"
195195
cmds:
196196
- task: k0s-build-controller-image-dev
197197
- task: delimiter

0 commit comments

Comments
 (0)