Skip to content

Commit edb683e

Browse files
committed
feat(chart): Add gateway api support
1 parent 052e30f commit edb683e

File tree

11 files changed

+645
-41
lines changed

11 files changed

+645
-41
lines changed

deployment/chainloop/README.md

Lines changed: 210 additions & 17 deletions
Large diffs are not rendered by default.

deployment/chainloop/charts/dex/templates/_helpers.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ Figure out the external URL for Dex service
4343
{{- define "chainloop.dex.external_url" -}}
4444
{{- $service := .Values.dex.service }}
4545
{{- $ingress := .Values.dex.ingress }}
46+
{{- $httpRoute := .Values.dex.httpRoute }}
4647

4748
{{- if (and $ingress $ingress.enabled $ingress.hostname) }}
4849
{{- printf "%s://%s/dex" (ternary "https" "http" $ingress.tls ) $ingress.hostname }}
50+
{{- else if (and $httpRoute $httpRoute.enabled $httpRoute.hostnames ) }}
51+
{{- printf "%s://%s/dex" (ternary "https" "http" $httpRoute.tls ) (index $httpRoute.hostnames 0) }}
4952
{{- else if (and (eq $service.type "NodePort") $service.nodePorts (not (empty $service.nodePorts.http))) }}
5053
{{- printf "http://localhost:%s" $service.nodePorts.http }}
5154
{{- else -}}
52-
{{- printf "http://%s-dex:%d/dex" ( include "chainloop.dex.fullname" . ) ( int $service.ports.http ) }}
55+
{{- printf "http://%s:%d/dex" ( include "chainloop.dex.fullname" . ) ( int $service.ports.http ) }}
5356
{{- end -}}
5457
{{- end -}}
5558

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- if or .Values.dex.httpRoute.enabled}}
2+
{{- /*
3+
Copyright Chainloop, Inc. All Rights Reserved.
4+
SPDX-License-Identifier: APACHE-2.0
5+
*/}}
6+
{{- $fullName := include "chainloop.dex.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.dex.labels" . | nindent 4 }}
13+
{{- if or .Values.dex.httpRoute.annotations }}
14+
annotations:
15+
{{- include "common.tplvalues.render" ( dict "value" .Values.dex.httpRoute.annotations "context" $) | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
parentRefs:
19+
{{- if .Values.dex.httpRoute.parentRefs }}
20+
{{- include "common.tplvalues.render" (dict "value" .Values.dex.httpRoute.parentRefs "context" .) | nindent 4 }}
21+
{{- else }}
22+
- name: gateway
23+
namespace: {{ include "common.names.namespace" . | quote }}
24+
{{- end }}
25+
hostnames: {{- include "common.tplvalues.render" (dict "value" .Values.dex.httpRoute.hostnames "context" .) | nindent 4 }}
26+
rules:
27+
{{- $port := coalesce .Values.dex.service.port .Values.dex.service.ports.http }}
28+
- backendRefs:
29+
- name: {{ include "chainloop.dex.fullname" . }}
30+
port: {{ $port }}
31+
{{- if .Values.dex.httpRoute.matches }}
32+
matches: {{- include "common.tplvalues.render" (dict "value" .Values.dex.httpRoute.matches "context" .) | nindent 8 }}
33+
{{- end }}
34+
{{- if .Values.dex.httpRoute.filters }}
35+
filters: {{- include "common.tplvalues.render" (dict "value" .Values.dex.httpRoute.filters "context" .) | nindent 8 }}
36+
{{- end }}
37+
{{- if .Values.dex.httpRoute.extraRules }}
38+
{{- include "common.tplvalues.render" (dict "value" .Values.dex.httpRoute.extraRules "context" .) | nindent 4 }}
39+
{{- end }}
40+
{{- end }}

deployment/chainloop/charts/dex/values.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,61 @@ dex:
674674
## port:
675675
## name: http
676676
##
677+
extraRules: []
678+
## Gateway API HTTP routing parameters
679+
## ref: https://gateway-api.sigs.k8s.io/guides/http-routing/
680+
##
681+
httpRoute:
682+
## @param dex.httpRoute.enabled Enable HTTPRoute generation for dex
683+
##
684+
enabled: false
685+
## @param controlplane.httpRoute.tls Indicate if tls is active for this route
686+
##
687+
tls: false
688+
## @param dex.httpRoute.annotations Additional annotations for the HTTPRoute resource
689+
##
690+
annotations: {}
691+
## @param dex.httpRoute.labels Additional labels for the HTTPRoute resource
692+
##
693+
labels: {}
694+
## @param dex.httpRoute.parentRefs Gateways the HTTPRoute is attached to. If unspecified, it'll be attached to Gateway named 'gateway' in the same namespace.
695+
## e.g:
696+
## parentRefs:
697+
## - name: my-gateway
698+
## sectionName: http
699+
## namespace: default
700+
##
701+
parentRefs: []
702+
## @param dex.httpRoute.hostnames [array] List of hostnames matching HTTP header
703+
##
704+
hostnames:
705+
- dex.dev.local
706+
## @param dex.httpRoute.matches [array] List of match rules applied to the HTTPRoute for the default svc backend reference
707+
##
708+
matches:
709+
- path:
710+
type: PathPrefix
711+
value: /
712+
## @param dex.httpRoute.filters List of filter rules applied to the HTTPRoute for the default svc backend reference
713+
##
714+
filters: []
715+
## @param dex.httpRoute.extraRules List of extra rules applied to the HTTPRoute
716+
## e.g:
717+
## extraRules:
718+
## - matches:
719+
## - path:
720+
## type: PathPrefix
721+
## value: /login
722+
## filters:
723+
## - type: RequestHeaderModifier
724+
## requestHeaderModifier:
725+
## set:
726+
## - name: My-Overwrite-Header
727+
## value: this-is-the-only-value
728+
## remove:
729+
## - User-Agent
730+
## backendRefs:
731+
## - name: chainloop-dex
732+
## port: 80
733+
##
677734
extraRules: []

deployment/chainloop/templates/NOTES.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@ APP VERSION: {{ .Chart.AppVersion }}
44

55
** Please be patient while the chart is being deployed **
66

7-
###########################################################################
8-
CONFIGURE CLI
9-
###########################################################################
10-
11-
Configure the CLI to point to this instance, for example
12-
13-
chainloop --insecure config save \
14-
--control-plane my-controlplane.acme.com:80 \
15-
--artifact-cas cas.acme.com:80
16-
17-
Refer to this link for more information
18-
https://docs.chainloop.dev/get-started/setup
19-
207
###########################################################################
218
USEFUL LINKS
229
###########################################################################
@@ -30,3 +17,19 @@ https://docs.chainloop.dev/get-started/setup
3017
{{- include "common.warnings.rollingTag" .Values.controlplane.migration.image }}
3118
{{- include "chainloop.validateValues" . }}
3219
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.controlplane.image .Values.cas.image .Values.controlplane.migration.image) "context" $) }}
20+
21+
###########################################################################
22+
CONFIGURE CLI
23+
###########################################################################
24+
25+
Configure the CLI to point to this instance, for example:
26+
27+
chainloop{{ ternary "" " --insecure" ( or .Values.controlplane.ingressAPI.tls .Values.controlplane.httpRoute.tls ) }} config save \
28+
--control-plane {{ include "chainloop.controlplane.external_hostname" . }}:{{ ternary "443" "80" ( or .Values.controlplane.ingressAPI.tls .Values.controlplane.httpRoute.tls ) }} \
29+
--artifact-cas {{ include "chainloop.cas.external_hostname" . }}:{{ ternary "443" "80" ( or .Values.cas.ingressAPI.tls .Values.cas.httpRoute.tls ) }} \
30+
31+
Refer to this link for more information
32+
https://docs.chainloop.dev/getting-started/installation#configure-cli-optional
33+
34+
Refer to this link for more information
35+
https://docs.chainloop.dev/get-started/setup

deployment/chainloop/templates/_helpers.tpl

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,39 @@ NOTE: Load balancer service type is not supported
316316
{{- define "chainloop.controlplane.external_url" -}}
317317
{{- $service := .Values.controlplane.service }}
318318
{{- $ingress := .Values.controlplane.ingress }}
319+
{{- $httpRoute := .Values.controlplane.httpRoute }}
319320

320321
{{- if .Values.controlplane.auth.oidc.externalURL }}
321322
{{- .Values.controlplane.auth.oidc.externalURL }}
322323
{{- else if (and $ingress $ingress.enabled $ingress.hostname) }}
323-
{{- printf "%s://%s" (ternary "https" "http" $ingress.tls ) $ingress.hostname }}
324+
{{- printf "%s://%s" (ternary "https" "http" $ingress.tls ) $ingress.hostnames }}
325+
{{- else if (and $httpRoute $httpRoute.enabled $httpRoute.hostnames ) }}
326+
{{- printf "%s://%s" (ternary "https" "http" $httpRoute.tls ) ( index $httpRoute.hostnames 0) }}
324327
{{- else if (and (eq $service.type "NodePort") $service.nodePorts (not (empty $service.nodePorts.http))) }}
325328
{{- printf "http://localhost:%s" $service.nodePorts.http }}
326329
{{- else -}}
327330
null
328331
{{- end -}}
329332
{{- end -}}
330333

334+
{{- define "chainloop.controlplane.external_hostname" -}}
335+
{{- $service := .Values.controlplane.service }}
336+
{{- $ingress := .Values.controlplane.ingress }}
337+
{{- $httpRoute := .Values.controlplane.httpRoute }}
338+
339+
{{- if .Values.controlplane.auth.oidc.externalURL }}
340+
{{- .Values.controlplane.auth.oidc.externalURL }}
341+
{{- else if (and $ingress $ingress.enabled $ingress.hostname) }}
342+
{{- printf "%s" $ingress.hostnames }}
343+
{{- else if (and $httpRoute $httpRoute.enabled $httpRoute.hostnames ) }}
344+
{{- printf "%s" ( index $httpRoute.hostnames 0) }}
345+
{{- else if (and (eq $service.type "NodePort") $service.nodePorts (not (empty $service.nodePorts.http))) }}
346+
{{- printf "localhost:%s" $service.nodePorts.http }}
347+
{{- else -}}
348+
null
349+
{{- end -}}
350+
{{- end -}}
351+
331352
{{- define "chainloop.sentry" -}}
332353
observability:
333354
sentry:
@@ -407,16 +428,35 @@ NOTE: Load balancer service type is not supported
407428
{{- define "chainloop.cas.external_url" -}}
408429
{{- $service := .Values.cas.service }}
409430
{{- $ingress := .Values.cas.ingress }}
431+
{{- $httpRoute := .Values.cas.httpRoute }}
410432

411433
{{- if .Values.cas.externalURL }}
412434
{{- .Values.cas.externalURL }}
413435
{{- else if (and $ingress $ingress.enabled $ingress.hostname) }}
414436
{{- printf "%s://%s" (ternary "https" "http" $ingress.tls ) $ingress.hostname }}
437+
{{- else if (and $httpRoute $httpRoute.enabled $httpRoute.hostnames) }}
438+
{{- printf "%s://%s" (ternary "https" "http" $httpRoute.tls ) (index $httpRoute.hostnames 0) }}
415439
{{- else if (and (eq $service.type "NodePort") $service.nodePorts (not (empty $service.nodePorts.http))) }}
416440
{{- printf "http://localhost:%s" $service.nodePorts.http }}
417441
{{- end -}}
418442
{{- end -}}
419443

444+
{{- define "chainloop.cas.external_hostname" -}}
445+
{{- $service := .Values.cas.service }}
446+
{{- $ingress := .Values.cas.ingress }}
447+
{{- $httpRoute := .Values.cas.httpRoute }}
448+
449+
{{- if .Values.cas.externalURL }}
450+
{{- .Values.cas.externalURL }}
451+
{{- else if (and $ingress $ingress.enabled $ingress.hostname) }}
452+
{{- printf "%s" $ingress.hostname }}
453+
{{- else if (and $httpRoute $httpRoute.enabled $httpRoute.hostnames) }}
454+
{{- printf "%s" (index $httpRoute.hostnames 0) }}
455+
{{- else if (and (eq $service.type "NodePort") $service.nodePorts (not (empty $service.nodePorts.http))) }}
456+
{{- printf "localhost:%s" $service.nodePorts.http }}
457+
{{- end -}}
458+
{{- end -}}
459+
420460
{{/*
421461
Check for Development mode
422462
*/}}
@@ -435,6 +475,23 @@ Compile all warning messages into a single one
435475
{{- $messages := without $messages "" -}}
436476
{{- $message := join "\n" $messages -}}
437477

478+
{{- if and (or (.Values.controlplane.ingress.enabled | default false) (.Values.controlplane.ingressAPI.enabled | default false)) (.Values.controlplane.httpRoute.enabled | default false) -}}
479+
{{- fail "Invalid values: controlplane.ingress.enabled or controlplane.ingressAPI.enabled and controlplane.httpRoute.enabled cannot both be true." -}}
480+
{{- end -}}
481+
482+
{{- if and (or (.Values.cas.ingress.enabled | default false) (.Values.cas.ingressAPI.enabled | default false)) (.Values.cas.httpRoute.enabled | default false) -}}
483+
{{- fail "Invalid values: cas.ingress.enabled or cas.ingressAPI.enabled and cas.httpRoute.enabled cannot both be true." -}}
484+
{{- end -}}
485+
486+
487+
{{- if and (.Values.cas.httpRoute.enabled | default false) ( gt (len .Values.cas.httpRoute.hostnames) 1 ) -}}
488+
{{- fail "Invalid values: .Values.cas.httpRoute.hostnames can only have one hostname" -}}
489+
{{- end -}}
490+
491+
{{- if and (.Values.controlplane.httpRoute.enabled | default false) ( gt (len .Values.controlplane.httpRoute.hostnames) 1 ) -}}
492+
{{- fail "Invalid values: .Values.controlplane.httpRoute.hostnames can only have one hostname" -}}
493+
{{- end -}}
494+
438495
{{- if $message -}}
439496
{{- printf "\n\nVALUES VALIDATION:\n%s" $message -}}
440497
{{- end -}}
@@ -448,5 +505,4 @@ Return the Nats connection string
448505
{{- $host := required "nats server hostname not set" .Values.controlplane.nats.host }}
449506
{{- $port := required "nats server port not set" .Values.controlplane.nats.port }}
450507
{{- printf "nats://%s:%d" $host ($port | int) }}
451-
{{- end -}}
452-
508+
{{- end -}}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- if or .Values.cas.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 }}
14+
annotations:
15+
{{- include "common.tplvalues.render" ( dict "value" .Values.cas.httpRoute.annotations "context" $) | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
parentRefs:
19+
{{- if .Values.cas.httpRoute.parentRefs }}
20+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.parentRefs "context" .) | nindent 4 }}
21+
{{- else }}
22+
- name: gateway
23+
namespace: {{ include "common.names.namespace" . | quote }}
24+
{{- end }}
25+
hostnames: {{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.hostnames "context" .) | nindent 4 }}
26+
rules:
27+
{{- $port := coalesce .Values.cas.service.port .Values.cas.service.ports.http }}
28+
- backendRefs:
29+
- name: {{ include "chainloop.cas.fullname" . }}
30+
port: {{ $port }}
31+
{{- if .Values.cas.httpRoute.matches }}
32+
matches: {{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.matches "context" .) | nindent 8 }}
33+
{{- end }}
34+
{{- if .Values.cas.httpRoute.filters }}
35+
filters: {{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.filters "context" .) | nindent 8 }}
36+
{{- end }}
37+
- matches:
38+
- headers:
39+
- name: content-type
40+
value: application/grpc
41+
{{- $portAPI := coalesce .Values.cas.serviceAPI.port .Values.cas.serviceAPI.ports.http }}
42+
backendRefs:
43+
- name: {{ include "chainloop.cas.fullname" . }}-api
44+
kind: Service
45+
namespace: {{ include "common.names.namespace" . | quote }}
46+
port: {{ $portAPI }}
47+
{{- if .Values.cas.httpRoute.extraRules }}
48+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.httpRoute.extraRules "context" .) | nindent 4 }}
49+
{{- end }}
50+
{{- 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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- if or .Values.controlplane.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 }}
14+
annotations:
15+
{{- include "common.tplvalues.render" ( dict "value" .Values.controlplane.httpRoute.annotations "context" $) | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
parentRefs:
19+
{{- if .Values.controlplane.httpRoute.parentRefs }}
20+
{{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.parentRefs "context" .) | nindent 4 }}
21+
{{- else }}
22+
- name: gateway
23+
namespace: {{ include "common.names.namespace" . | quote }}
24+
{{- end }}
25+
hostnames: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.hostnames "context" .) | nindent 4 }}
26+
rules:
27+
{{- $port := coalesce .Values.controlplane.service.port .Values.controlplane.service.ports.http }}
28+
- backendRefs:
29+
- name: {{ include "chainloop.controlplane.fullname" . }}
30+
port: {{ $port }}
31+
{{- if .Values.controlplane.httpRoute.matches }}
32+
matches: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.matches "context" .) | nindent 8 }}
33+
{{- end }}
34+
{{- if .Values.controlplane.httpRoute.filters }}
35+
filters: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.filters "context" .) | nindent 8 }}
36+
{{- end }}
37+
- matches:
38+
- headers:
39+
- name: content-type
40+
value: application/grpc
41+
{{- $portAPI := coalesce .Values.controlplane.serviceAPI.port .Values.controlplane.serviceAPI.ports.http }}
42+
backendRefs:
43+
- name: {{ include "chainloop.controlplane.fullname" . }}-api
44+
kind: Service
45+
namespace: {{ include "common.names.namespace" . | quote }}
46+
port: {{ $portAPI }}
47+
{{- if .Values.controlplane.httpRoute.extraRules }}
48+
{{- include "common.tplvalues.render" (dict "value" .Values.controlplane.httpRoute.extraRules "context" .) | nindent 4 }}
49+
{{- end }}
50+
{{- 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" }}

0 commit comments

Comments
 (0)