Skip to content

Commit b3177e3

Browse files
author
Filip Chlebowski
committed
feat(chart): Add support for gateway API
1 parent 052e30f commit b3177e3

5 files changed

Lines changed: 220 additions & 1 deletion

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{- if or .Values.cas.httpRoute.enabled .Values.httpRoute.enabled }}
2+
{{- /*
3+
Copyright Chainloop, Inc. All Rights Reserved.
4+
SPDX-License-Identifier: APACHE-2.0
5+
*/}}
6+
{{- $fullName := include "chainloop.cas.fullname" . -}}
7+
apiVersion: gateway.networking.k8s.io/v1
8+
kind: HTTPRoute
9+
metadata:
10+
name: {{ $fullName }}
11+
namespace: {{ include "common.names.namespace" . | quote }}
12+
labels: {{- include "chainloop.cas.labels" . | nindent 4 }}
13+
{{- if or .Values.cas.httpRoute.annotations .Values.httpRoute.annotations }}
14+
annotations:
15+
{{- if .Values.cas.httpRoute.annotations }}
16+
{{- include "common.tplvalues.render" ( dict "value" .Values.cas.httpRoute.annotations "context" $) | nindent 4 }}
17+
{{- end }}
18+
{{- if .Values.httpRoute.annotations }}
19+
{{- include "common.tplvalues.render" ( dict "value" .Values.httpRoute.annotations "context" $) | nindent 4 }}
20+
{{- end }}
21+
{{- end }}
22+
spec:
23+
parentRefs:
24+
{{- if .Values.cas.httpRoute.parentRefs }}
25+
{{- include "common.tplvalues.render" (dict "value" .Values.httpRoute.parentRefs "context" .) | nindent 4 }}
26+
{{- else }}
27+
- name: gateway
28+
namespace: {{ include "common.names.namespace" . | quote }}
29+
{{- end }}
30+
hostnames: {{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.hostnames "context" .) | nindent 4 }}
31+
rules:
32+
{{- $port := coalesce .Values.cas.service.port .Values.cas.service.ports.http }}
33+
- backendRefs:
34+
- name: {{ include "chainloop.cas.fullname" . }}
35+
port: {{ $port }}
36+
{{- if .Values.cas.httpRoute.matches }}
37+
matches: {{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.matches "context" .) | nindent 8 }}
38+
{{- end }}
39+
{{- if .Values.cas.httpRoute.filters }}
40+
filters: {{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.filters "context" .) | nindent 8 }}
41+
{{- end }}
42+
- matches:
43+
- headers:
44+
- name: content-type
45+
value: application/grpc
46+
{{- $portAPI := coalesce .Values.cas.serviceAPI.port .Values.cas.serviceAPI.ports.http }}
47+
backendRefs:
48+
- name: {{ include "chainloop.cas.fullname" . }}-api
49+
kind: Service
50+
namespace: {{ include "common.names.namespace" . | quote }}
51+
port: {{ $portAPI }}
52+
{{- if .Values.cas.httpRoute.extraRules }}
53+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.extraRules "context" .) | nindent 4 }}
54+
{{- end }}
55+
{{- end }}

deployment/chainloop/templates/cas/service-grpc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ spec:
4040
{{- if not (eq $port .Values.cas.containerPorts.grpc) }}
4141
targetPort: {{ .Values.cas.containerPorts.grpc }}
4242
{{- end }}
43+
appProtocol: kubernetes.io/h2c
4344
protocol: TCP
4445
{{- if and (or (eq .Values.cas.serviceAPI.type "NodePort") (eq .Values.cas.serviceAPI.type "LoadBalancer")) (not (empty .Values.cas.serviceAPI.nodePorts.http)) }}
4546
nodePort: {{ .Values.cas.serviceAPI.nodePorts.http }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{- if or .Values.controlplane.httpRoute.enabled .Values.httpRoute.enabled }}
2+
{{- /*
3+
Copyright Chainloop, Inc. All Rights Reserved.
4+
SPDX-License-Identifier: APACHE-2.0
5+
*/}}
6+
{{- $fullName := include "chainloop.controlplane.fullname" . -}}
7+
apiVersion: gateway.networking.k8s.io/v1
8+
kind: HTTPRoute
9+
metadata:
10+
name: {{ $fullName }}
11+
namespace: {{ include "common.names.namespace" . | quote }}
12+
labels: {{- include "chainloop.controlplane.labels" . | nindent 4 }}
13+
{{- if or .Values.controlplane.httpRoute.annotations .Values.httpRoute.annotations }}
14+
annotations:
15+
{{- if .Values.controlplane.httpRoute.annotations }}
16+
{{- include "common.tplvalues.render" ( dict "value" .Values.controlplane.httpRoute.annotations "context" $) | nindent 4 }}
17+
{{- end }}
18+
{{- if .Values.httpRoute.annotations }}
19+
{{- include "common.tplvalues.render" ( dict "value" .Values.httpRoute.annotations "context" $) | nindent 4 }}
20+
{{- end }}
21+
{{- end }}
22+
spec:
23+
parentRefs:
24+
{{- if .Values.controlplane.httpRoute.parentRefs }}
25+
{{- include "common.tplvalues.render" (dict "value" .Values.httpRoute.parentRefs "context" .) | nindent 4 }}
26+
{{- else }}
27+
- name: gateway
28+
namespace: {{ include "common.names.namespace" . | quote }}
29+
{{- end }}
30+
hostnames: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.hostnames "context" .) | nindent 4 }}
31+
rules:
32+
{{- $port := coalesce .Values.controlplane.service.port .Values.controlplane.service.ports.http }}
33+
- backendRefs:
34+
- name: {{ include "chainloop.controlplane.fullname" . }}
35+
port: {{ $port }}
36+
{{- if .Values.controlplane.httpRoute.matches }}
37+
matches: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.matches "context" .) | nindent 8 }}
38+
{{- end }}
39+
{{- if .Values.controlplane.httpRoute.filters }}
40+
filters: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.filters "context" .) | nindent 8 }}
41+
{{- end }}
42+
- matches:
43+
- headers:
44+
- name: content-type
45+
value: application/grpc
46+
{{- $portAPI := coalesce .Values.controlplane.serviceAPI.port .Values.controlplane.serviceAPI.ports.http }}
47+
backendRefs:
48+
- name: {{ include "chainloop.controlplane.fullname" . }}-api
49+
kind: Service
50+
namespace: {{ include "common.names.namespace" . | quote }}
51+
port: {{ $portAPI }}
52+
{{- if .Values.controlplane.httpRoute.extraRules }}
53+
{{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.extraRules "context" .) | nindent 4 }}
54+
{{- end }}
55+
{{- end }}

deployment/chainloop/templates/controlplane/service-grpc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ spec:
4141
targetPort: {{ .Values.controlplane.containerPorts.grpc }}
4242
{{- end }}
4343
protocol: TCP
44+
appProtocol: kubernetes.io/h2c
4445
{{- if and (or (eq .Values.controlplane.serviceAPI.type "NodePort") (eq .Values.controlplane.serviceAPI.type "LoadBalancer")) (not (empty .Values.controlplane.serviceAPI.nodePorts.http)) }}
4546
nodePort: {{ .Values.controlplane.serviceAPI.nodePorts.http }}
4647
{{- else if eq .Values.controlplane.serviceAPI.type "ClusterIP" }}

deployment/chainloop/values.yaml

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,60 @@ controlplane:
601601
## name: http
602602
##
603603
extraRules: []
604+
## Gateway API HTTP routing parameters
605+
## ref: https://gateway-api.sigs.k8s.io/guides/http-routing/
606+
##
607+
httpRoute:
608+
## @param httpRoute.enabled Enable HTTPRoute generation for WordPress
609+
##
610+
enabled: false
611+
## @param httpRoute.annotations Additional annotations for the HTTPRoute resource
612+
##
613+
annotations: {}
614+
## @param httpRoute.labels Additional labels for the HTTPRoute resource
615+
##
616+
labels: {}
617+
## @param httpRoute.parentRefs Gateways the HTTPRoute is attached to. If unspecified, it'll be attached to Gateway named 'gateway' in the same namespace.
618+
## e.g:
619+
## parentRefs:
620+
## - name: my-gateway
621+
## sectionName: http
622+
## namespace: default
623+
##
624+
parentRefs: []
625+
## @param httpRoute.hostnames [array] List of hostnames matching HTTP header
626+
##
627+
hostnames:
628+
- cp.dev.local
629+
## @param httpRoute.matches [array] List of match rules applied to the HTTPRoute for the default svc backend reference
630+
##
631+
matches:
632+
- path:
633+
type: PathPrefix
634+
value: /
635+
## @param httpRoute.filters List of filter rules applied to the HTTPRoute for the default svc backend reference
636+
##
637+
filters: []
638+
## @param httpRoute.extraRules List of extra rules applied to the HTTPRoute
639+
## e.g:
640+
## extraRules:
641+
## - matches:
642+
## - path:
643+
## type: PathPrefix
644+
## value: /login
645+
## filters:
646+
## - type: RequestHeaderModifier
647+
## requestHeaderModifier:
648+
## set:
649+
## - name: My-Overwrite-Header
650+
## value: this-is-the-only-value
651+
## remove:
652+
## - User-Agent
653+
## backendRefs:
654+
## - name: wordpress
655+
## port: 80
656+
##
657+
extraRules: []
604658

605659
## @section Controlplane Misc
606660

@@ -1349,7 +1403,60 @@ cas:
13491403
## name: http
13501404
##
13511405
extraRules: []
1352-
1406+
## Gateway API HTTP routing parameters
1407+
## ref: https://gateway-api.sigs.k8s.io/guides/http-routing/
1408+
##
1409+
httpRoute:
1410+
## @param httpRoute.enabled Enable HTTPRoute generation for WordPress
1411+
##
1412+
enabled: false
1413+
## @param httpRoute.annotations Additional annotations for the HTTPRoute resource
1414+
##
1415+
annotations: {}
1416+
## @param httpRoute.labels Additional labels for the HTTPRoute resource
1417+
##
1418+
labels: {}
1419+
## @param httpRoute.parentRefs Gateways the HTTPRoute is attached to. If unspecified, it'll be attached to Gateway named 'gateway' in the same namespace.
1420+
## e.g:
1421+
## parentRefs:
1422+
## - name: my-gateway
1423+
## sectionName: http
1424+
## namespace: default
1425+
##
1426+
parentRefs: []
1427+
## @param httpRoute.hostnames [array] List of hostnames matching HTTP header
1428+
##
1429+
hostnames:
1430+
- cas.dev.local
1431+
## @param httpRoute.matches [array] List of match rules applied to the HTTPRoute for the default svc backend reference
1432+
##
1433+
matches:
1434+
- path:
1435+
type: PathPrefix
1436+
value: /
1437+
## @param httpRoute.filters List of filter rules applied to the HTTPRoute for the default svc backend reference
1438+
##
1439+
filters: []
1440+
## @param httpRoute.extraRules List of extra rules applied to the HTTPRoute
1441+
## e.g:
1442+
## extraRules:
1443+
## - matches:
1444+
## - path:
1445+
## type: PathPrefix
1446+
## value: /login
1447+
## filters:
1448+
## - type: RequestHeaderModifier
1449+
## requestHeaderModifier:
1450+
## set:
1451+
## - name: My-Overwrite-Header
1452+
## value: this-is-the-only-value
1453+
## remove:
1454+
## - User-Agent
1455+
## backendRefs:
1456+
## - name: wordpress
1457+
## port: 80
1458+
##
1459+
extraRules: []
13531460
## @section CAS Misc
13541461
## @param cas.sentry.enabled Enable sentry.io alerting
13551462
## @param cas.sentry.dsn DSN endpoint

0 commit comments

Comments
 (0)