Skip to content

Commit 4b06a69

Browse files
committed
support path based routing
1 parent eaa44a4 commit 4b06a69

13 files changed

Lines changed: 249 additions & 18 deletions

File tree

README.md.gotmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ helm install convoy convoy/convoy --values values.yaml
3939
```bash
4040
helm install convoy .
4141
```
42-
4342
{{ template "chart.valuesSection" . }}
4443

4544
{{- if not .SkipVersionFooter }}

charts/agent/templates/_helpers.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
1313
{{- define "convoy-agent.fullname" -}}
14-
{{- if .Values.fullnameOverride }}
15-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- if or .Values.fullNameOverride .Values.fullnameOverride }}
15+
{{- coalesce .Values.fullNameOverride .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1616
{{- else }}
1717
{{- $name := default .Chart.Name .Values.nameOverride }}
1818
{{- if contains $name .Release.Name }}

charts/agent/templates/deployment.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ spec:
9191
- name: HTTP_PROXY
9292
value: {{ .Values.env.proxy | quote }}
9393
- name: CONVOY_LOGGER_LEVEL
94-
value: {{ .Values.env.log_level | quote }}
94+
value: {{ coalesce .Values.env.log_level .Values.global.convoy.log_level "error" | quote }}
9595
- name: CONVOY_ENV
9696
value: {{ .Values.env.environment | quote }}
9797
- name: CONVOY_SIGNUP_ENABLED
9898
value: {{ .Values.env.sign_up_enabled | quote }}
99+
- name: CONVOY_ROOT_PATH
100+
value: {{ .Values.env.root_path | quote }}
99101
{{- if or .Values.global.convoy.cacert_secret_name .Values.global.convoy.cacert_content }}
100102
- name: CONVOY_DISPATCHER_CACERT_PATH
101103
value: "/etc/convoy/ca.crt"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "convoy-agent.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
5+
apiVersion: networking.k8s.io/v1
6+
{{- else -}}
7+
apiVersion: apiextensions.k8s.io/v1
8+
{{- end }}
9+
kind: Ingress
10+
metadata:
11+
name: {{ $fullName }}
12+
labels:
13+
{{- include "convoy-agent.labels" . | nindent 4 }}
14+
{{- with .Values.ingress.annotations }}
15+
annotations:
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
18+
spec:
19+
{{- with .Values.ingress.ingressClassName }}
20+
ingressClassName: {{ . | quote }}
21+
{{- end }}
22+
{{- if .Values.ingress.tls }}
23+
tls:
24+
{{- range .Values.ingress.tls }}
25+
- hosts:
26+
{{- range .hosts }}
27+
- {{ . | quote }}
28+
{{- end }}
29+
secretName: {{ .secretName }}
30+
{{- end }}
31+
{{- end }}
32+
rules:
33+
{{- range .Values.ingress.hosts }}
34+
- host: {{ .host | quote }}
35+
http:
36+
paths:
37+
{{- range .http.paths }}
38+
- path: {{ .path }}
39+
pathType: {{ .pathType }}
40+
backend:
41+
service:
42+
name: {{ $fullName }}
43+
port:
44+
number: {{ $svcPort }}
45+
{{- end }}
46+
{{- end }}
47+
{{- end }}

charts/agent/templates/rollout.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ spec:
9393
- name: HTTP_PROXY
9494
value: {{ .Values.env.proxy | quote }}
9595
- name: CONVOY_LOGGER_LEVEL
96-
value: {{ .Values.env.log_level | quote }}
96+
value: {{ coalesce .Values.env.log_level .Values.global.convoy.log_level "error" | quote }}
9797
- name: CONVOY_ENV
9898
value: {{ .Values.env.environment | quote }}
9999
- name: CONVOY_SIGNUP_ENABLED
100100
value: {{ .Values.env.sign_up_enabled | quote }}
101+
- name: CONVOY_ROOT_PATH
102+
value: {{ .Values.env.root_path | quote }}
101103
{{- if or .Values.global.convoy.cacert_secret_name .Values.global.convoy.cacert_content }}
102104
- name: CONVOY_DISPATCHER_CACERT_PATH
103105
value: "/etc/convoy/ca.crt"

charts/agent/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ env:
7272
proxy: ""
7373
sign_up_enabled: false
7474
log_level: "error"
75+
# -- Base path when exposed behind a path-prefix (e.g. Ingress path /agent). Sets CONVOY_ROOT_PATH. Use "" when each service has its own hostname.
76+
root_path: ""
7577
auth:
7678
file:
7779
basic: []
@@ -167,6 +169,18 @@ rollout:
167169
enabled: false
168170
strategy: {}
169171

172+
ingress:
173+
enabled: false
174+
annotations: {}
175+
ingressClassName: ""
176+
tls: []
177+
hosts:
178+
- host: agent.example.com
179+
http:
180+
paths:
181+
- path: /
182+
pathType: Prefix
183+
170184
autoscaling:
171185
enabled: true
172186
minReplicas: 2

charts/server/templates/_helpers.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
1313
{{- define "convoy-server.fullname" -}}
14-
{{- if .Values.fullnameOverride }}
15-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- if or .Values.fullNameOverride .Values.fullnameOverride }}
15+
{{- coalesce .Values.fullNameOverride .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1616
{{- else }}
1717
{{- $name := default .Chart.Name .Values.nameOverride }}
1818
{{- if contains $name .Release.Name }}

charts/server/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ spec:
9898
- name: CONVOY_ROOT_PATH
9999
value: {{ .Values.env.root_path | quote }}
100100
- name: CONVOY_LOGGER_LEVEL
101-
value: {{ .Values.env.log_level | quote }}
101+
value: {{ coalesce .Values.env.log_level .Values.global.convoy.log_level "error" | quote }}
102102
- name: CONVOY_SIGNUP_ENABLED
103103
value: {{ .Values.env.sign_up_enabled | quote }}
104104
- name: CONVOY_MAX_RESPONSE_SIZE

charts/server/templates/ingress.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ metadata:
1616
{{- toYaml . | nindent 4 }}
1717
{{- end }}
1818
spec:
19-
ingressClassName: {{ .Values.ingress.ingressClassName }}
19+
{{- with .Values.ingress.ingressClassName }}
20+
ingressClassName: {{ . | quote }}
21+
{{- end }}
2022
{{- if .Values.ingress.tls }}
2123
tls:
2224
{{- range .Values.ingress.tls }}
@@ -42,4 +44,4 @@ spec:
4244
number: {{ $svcPort }}
4345
{{- end }}
4446
{{- end }}
45-
{{- end }}
47+
{{- end }}

charts/server/templates/rollout.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ spec:
100100
- name: CONVOY_ROOT_PATH
101101
value: {{ .Values.env.root_path | quote }}
102102
- name: CONVOY_LOGGER_LEVEL
103-
value: {{ .Values.env.log_level | quote }}
103+
value: {{ coalesce .Values.env.log_level .Values.global.convoy.log_level "error" | quote }}
104104
- name: CONVOY_SIGNUP_ENABLED
105105
value: {{ .Values.env.sign_up_enabled | quote }}
106106
- name: CONVOY_MAX_RESPONSE_SIZE

0 commit comments

Comments
 (0)