Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 6117449

Browse files
authored
Merge pull request #63 from tumido/simplify-routes
feat: further simplify the config for autogenerated Route host in OCP
2 parents 5f13f2a + 276b932 commit 6117449

File tree

7 files changed

+127
-63
lines changed

7 files changed

+127
-63
lines changed

charts/backstage/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ sources:
4242
# This is the chart version. This version number should be incremented each time you make changes
4343
# to the chart and its templates, including the app version.
4444
# Versions are expected to follow Semantic Versioning (https://semver.org/)
45-
version: 2.0.3
45+
version: 2.1.0

charts/backstage/README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Janus-IDP Backstage Helm Chart
33

44
[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/janus-idp&style=flat-square)](https://artifacthub.io/packages/search?repo=janus-idp)
5-
![Version: 2.0.3](https://img.shields.io/badge/Version-2.0.3-informational?style=flat-square)
5+
![Version: 2.1.0](https://img.shields.io/badge/Version-2.1.0-informational?style=flat-square)
66
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
77

88
A Helm chart for deploying a Backstage application
@@ -73,17 +73,12 @@ Once the chart has been added, install this chart. However before doing so, plea
7373
- To get proper connection between frontend and backend of Backstage please update the `apps.example.com` to match your cluster host:
7474

7575
```yaml
76-
upstream:
77-
backstage:
78-
appConfig:
79-
app:
80-
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
81-
backend:
82-
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
83-
cors:
84-
origin: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
76+
global:
77+
clusterRouterBase: apps.example.com
8578
```
8679
80+
> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file
81+
8782
- If your cluster doesn't provide PVCs, you should disable PostgreSQL persistence via:
8883

8984
```yaml
@@ -133,10 +128,12 @@ Kubernetes: `>= 1.19.0-0`
133128

134129
| Key | Description | Type | Default |
135130
|-----|-------------|------|---------|
136-
| route | OpenShift Route parameters | object | `{"annotations":{},"enabled":true,"host":"","path":"/","tls":{"caCertificate":"","certificate":"","destinationCACertificate":"","enabled":true,"insecureEdgeTerminationPolicy":"Redirect","key":"","termination":"edge"},"wildcardPolicy":"None"}` |
131+
| global.clusterRouterBase | Shorthand for users who do not want to specify a custom HOSTNAME. Used ONLY with the DEFAULT upstream.backstage.appConfig value and with OCP Route enabled. | string | `"apps.example.com"` |
132+
| global.host | Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig` | string | `""` |
133+
| route | OpenShift Route parameters | object | `{"annotations":{},"enabled":true,"host":"{{ .Values.global.host }}","path":"/","tls":{"caCertificate":"","certificate":"","destinationCACertificate":"","enabled":true,"insecureEdgeTerminationPolicy":"Redirect","key":"","termination":"edge"},"wildcardPolicy":"None"}` |
137134
| route.annotations | Route specific annotations | object | `{}` |
138135
| route.enabled | Enable the creation of the route resource | bool | `true` |
139-
| route.host | Set the host attribute to a custom value. If not set, OpenShift will generate it, please make sure to match your baseUrl | string | `""` |
136+
| route.host | Set the host attribute to a custom value. If not set, OpenShift will generate it, please make sure to match your baseUrl | string | `"{{ .Values.global.host }}"` |
140137
| route.path | Path that the router watches for, to route traffic for to the service. | string | `"/"` |
141138
| route.tls | Route TLS parameters <br /> Ref: https://docs.openshift.com/container-platform/4.9/networking/routes/secured-routes.html | object | `{"caCertificate":"","certificate":"","destinationCACertificate":"","enabled":true,"insecureEdgeTerminationPolicy":"Redirect","key":"","termination":"edge"}` |
142139
| route.tls.caCertificate | Cert authority certificate contents. Optional | string | `""` |
@@ -186,27 +183,38 @@ Additionally this chart enhances the upstream Backstage chart with following Ope
186183

187184
This chart offers a drop-in replacement for the `Ingress` resource already provided by the upstream chart via an OpenShift `Route`.
188185

189-
Please enable it using following values:
186+
OpenShift routes are enabled by default. In order to use the chart without it, please switch to the `Ingress` resource via `upstream.ingress` values.
187+
188+
Routes can be further configured via the `route` value.
189+
190+
By default, the chart expects you to expose Backstage via the autogenerated hostname. To provide Backstage pod with the right context, please adjust following value:
190191

191192
```yaml
192193
# values.yaml
193-
upstream:
194-
backstage:
195-
extraEnvVars:
196-
- name: "APP_CONFIG_app_baseUrl"
197-
value: "https://{{ .Values.global.host }}"
198-
- name: "APP_CONFIG_backend_baseUrl"
199-
value: "https://{{ .Values.global.host }}"
200-
- name: "APP_CONFIG_backend_cors_origin"
201-
value: "https://{{ .Values.global.host }}"
202-
ingress:
203-
enabled: false
204-
route:
205-
enabled: true
206-
host: "{{ .Values.global.host }}"
207-
tls:
208-
enabled: true
194+
global:
195+
clusterRouterBase: apps.example.com
196+
```
197+
198+
Custom hosts are also supported via following shorthand:
209199

200+
```yaml
201+
# values.yaml
210202
global:
211-
host: backstage.apps.example.com
203+
host: backstage.example.com
204+
```
205+
206+
Please note this is just a templating shorthand. For full manual configuration please pay attention to values under `route` key.
207+
208+
Please note that any custom modifications to how backstage is being exposed may require additional changes to values:
209+
210+
```yaml
211+
# values.yaml
212+
upstream:
213+
appConfig:
214+
app:
215+
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
216+
backend:
217+
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
218+
cors:
219+
origin: 'https://{{- include "janus-idp.hostname" . }}'
212220
```

charts/backstage/README.md.gotmpl

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,12 @@ Once the chart has been added, install this chart. However before doing so, plea
6767
- To get proper connection between frontend and backend of Backstage please update the `apps.example.com` to match your cluster host:
6868

6969
```yaml
70-
upstream:
71-
backstage:
72-
appConfig:
73-
app:
74-
baseUrl: 'https://{{"{{"}}- print .Release.Name "-" .Release.Namespace -{{"}}"}}.apps.example.com'
75-
backend:
76-
baseUrl: 'https://{{"{{"}}- print .Release.Name "-" .Release.Namespace -{{"}}"}}.apps.example.com'
77-
cors:
78-
origin: 'https://{{"{{"}}- print .Release.Name "-" .Release.Namespace -{{"}}"}}.apps.example.com'
70+
global:
71+
clusterRouterBase: apps.example.com
7972
```
8073

74+
> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file
75+
8176
- If your cluster doesn't provide PVCs, you should disable PostgreSQL persistence via:
8277

8378
```yaml
@@ -155,27 +150,38 @@ Additionally this chart enhances the upstream Backstage chart with following Ope
155150

156151
This chart offers a drop-in replacement for the `Ingress` resource already provided by the upstream chart via an OpenShift `Route`.
157152

158-
Please enable it using following values:
153+
OpenShift routes are enabled by default. In order to use the chart without it, please switch to the `Ingress` resource via `upstream.ingress` values.
154+
155+
Routes can be further configured via the `route` value.
156+
157+
By default, the chart expects you to expose Backstage via the autogenerated hostname. To provide Backstage pod with the right context, please adjust following value:
159158

160159
```yaml
161160
# values.yaml
162-
upstream:
163-
backstage:
164-
extraEnvVars:
165-
- name: "APP_CONFIG_app_baseUrl"
166-
value: "https://{{"{{"}} .Values.global.host {{"}}"}}"
167-
- name: "APP_CONFIG_backend_baseUrl"
168-
value: "https://{{"{{"}} .Values.global.host {{"}}"}}"
169-
- name: "APP_CONFIG_backend_cors_origin"
170-
value: "https://{{"{{"}} .Values.global.host {{"}}"}}"
171-
ingress:
172-
enabled: false
173-
route:
174-
enabled: true
175-
host: "{{"{{"}} .Values.global.host {{"}}"}}"
176-
tls:
177-
enabled: true
161+
global:
162+
clusterRouterBase: apps.example.com
163+
```
164+
165+
Custom hosts are also supported via following shorthand:
178166

167+
```yaml
168+
# values.yaml
179169
global:
180-
host: backstage.apps.example.com
170+
host: backstage.example.com
171+
```
172+
173+
Please note this is just a templating shorthand. For full manual configuration please pay attention to values under `route` key.
174+
175+
Please note that any custom modifications to how backstage is being exposed may require additional changes to values:
176+
177+
```yaml
178+
# values.yaml
179+
upstream:
180+
appConfig:
181+
app:
182+
baseUrl: 'https://{{"{{"}}- include "janus-idp.hostname" . {{"}}"}}'
183+
backend:
184+
baseUrl: 'https://{{"{{"}}- include "janus-idp.hostname" . {{"}}"}}'
185+
cors:
186+
origin: 'https://{{"{{"}}- include "janus-idp.hostname" . {{"}}"}}'
181187
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{/*
2+
Returns custom hostname
3+
*/}}
4+
{{- define "janus-idp.hostname" -}}
5+
{{- if .Values.global.host -}}
6+
{{- .Values.global.host -}}
7+
{{- else if .Values.global.clusterRouterBase -}}
8+
{{- print .Release.Name "-" .Release.Namespace "." .Values.global.clusterRouterBase -}}
9+
{{- else -}}
10+
{{ fail "Unable to generate hostname" }}
11+
{{- end -}}
12+
{{- end -}}

charts/backstage/values.schema.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{
22
"$id": "https://raw.githubusercontent.com/janus-idp/helm-backstage/main/charts/backstage/values.schema.json",
33
"properties": {
4+
"global": {
5+
"properties": {
6+
"clusterRouterBase": {
7+
"default": "apps.example.com",
8+
"title": "Shorthand for users who do not want to specify a custom HOSTNAME. Used ONLY with the DEFAULT upstream.backstage.appConfig value and with OCP Route enabled.",
9+
"type": "string"
10+
},
11+
"host": {
12+
"default": "",
13+
"title": "Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`",
14+
"type": "string"
15+
}
16+
},
17+
"type": "object"
18+
},
419
"route": {
520
"additionalProperties": false,
621
"properties": {

charts/backstage/values.schema.tmpl.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717
}
1818
}
1919
},
20+
"global": {
21+
"type": "object",
22+
"properties": {
23+
"clusterRouterBase": {
24+
"title": "Shorthand for users who do not want to specify a custom HOSTNAME. Used ONLY with the DEFAULT upstream.backstage.appConfig value and with OCP Route enabled.",
25+
"type": "string",
26+
"default": "apps.example.com"
27+
},
28+
"host": {
29+
"title": "Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`",
30+
"type": "string",
31+
"default": ""
32+
}
33+
}
34+
},
2035
"route": {
2136
"title": "OpenShift Route parameters.",
2237
"type": "object",

charts/backstage/values.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
global:
2+
# -- Shorthand for users who do not want to specify a custom HOSTNAME. Used ONLY with the DEFAULT upstream.backstage.appConfig value and with OCP Route enabled.
3+
clusterRouterBase: apps.example.com
4+
# -- Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`
5+
host: ""
6+
17
# -- Upstream Backstage [chart configuration](https://github.com/backstage/charts/blob/main/charts/backstage/values.yaml)
28
# @default -- Use Openshift compatible settings
39
upstream:
@@ -17,12 +23,12 @@ upstream:
1723
# can't accommodate that properly.
1824
appConfig:
1925
app:
20-
# Please update to match host.
21-
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
26+
# Please update to match host in case you don't want to configure hostname via `global.clusterRouterBase` or `global.host`.
27+
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
2228
backend:
23-
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
29+
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
2430
cors:
25-
origin: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
31+
origin: 'https://{{- include "janus-idp.hostname" . }}'
2632
database:
2733
connection:
2834
password: ${POSTGRESQL_ADMIN_PASSWORD}
@@ -62,6 +68,8 @@ upstream:
6268
secretKeyRef:
6369
key: postgres-password
6470
name: "{{ .Release.Name }}-postgresql"
71+
ingress:
72+
host: "{{ .Values.global.host }}"
6573

6674

6775
# -- OpenShift Route parameters
@@ -74,7 +82,7 @@ route:
7482
enabled: true
7583

7684
# -- Set the host attribute to a custom value. If not set, OpenShift will generate it, please make sure to match your baseUrl
77-
host: ""
85+
host: "{{ .Values.global.host }}"
7886

7987
# -- Path that the router watches for, to route traffic for to the service.
8088
path: "/"

0 commit comments

Comments
 (0)