Skip to content

Commit bb8e927

Browse files
committed
feat(dex): Add httproutes to dex subchart
1 parent fb2934d commit bb8e927

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,60 @@ 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+
tls: false
687+
## @param dex.httpRoute.annotations Additional annotations for the HTTPRoute resource
688+
##
689+
annotations: {}
690+
## @param dex.httpRoute.labels Additional labels for the HTTPRoute resource
691+
##
692+
labels: {}
693+
## @param dex.httpRoute.parentRefs Gateways the HTTPRoute is attached to. If unspecified, it'll be attached to Gateway named 'gateway' in the same namespace.
694+
## e.g:
695+
## parentRefs:
696+
## - name: my-gateway
697+
## sectionName: http
698+
## namespace: default
699+
##
700+
parentRefs: []
701+
## @param dex.httpRoute.hostnames [array] List of hostnames matching HTTP header
702+
##
703+
hostnames:
704+
- dex.dev.local
705+
## @param dex.httpRoute.matches [array] List of match rules applied to the HTTPRoute for the default svc backend reference
706+
##
707+
matches:
708+
- path:
709+
type: PathPrefix
710+
value: /
711+
## @param dex.httpRoute.filters List of filter rules applied to the HTTPRoute for the default svc backend reference
712+
##
713+
filters: []
714+
## @param dex.httpRoute.extraRules List of extra rules applied to the HTTPRoute
715+
## e.g:
716+
## extraRules:
717+
## - matches:
718+
## - path:
719+
## type: PathPrefix
720+
## value: /login
721+
## filters:
722+
## - type: RequestHeaderModifier
723+
## requestHeaderModifier:
724+
## set:
725+
## - name: My-Overwrite-Header
726+
## value: this-is-the-only-value
727+
## remove:
728+
## - User-Agent
729+
## backendRefs:
730+
## - name: chainloop-dex
731+
## port: 80
732+
##
677733
extraRules: []

0 commit comments

Comments
 (0)