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

Commit d83df53

Browse files
authored
feat: add fallback value for janus-idp.hostname for openshift clusters (#169)
* feat: add fallback value for janus-idp.hostname for openshift clusters * chore: update defaults, documentation and update errors to be more verbose * chore: update tests for new default value of `global.clusterRouterBase` * chore: update docs and error message
1 parent 6247ac5 commit d83df53

File tree

8 files changed

+63
-58
lines changed

8 files changed

+63
-58
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
helm repo update
6161
6262
- name: Run chart-testing (lint)
63-
run: ct lint --config ct.yaml
63+
run: ct lint --config ct.yaml --helm-extra-args="--set upstream.backstage.image.tag=latest --set global.clusterRouterBase=app.example.yaml"
6464

6565
- name: Create KIND Cluster
6666
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
@@ -70,7 +70,7 @@ jobs:
7070

7171
- name: Run chart-testing (latest)
7272
# test with latest stable backstage-showcase release
73-
run: ct install --config ct-install.yaml --helm-extra-set-args="--set=upstream.backstage.image.tag=latest"
73+
run: ct install --config ct-install.yaml --helm-extra-set-args="--set=upstream.backstage.image.tag=latest --set=global.clusterRouterBase=app.example.com"
7474
test-next:
7575
name: Test Next Release
7676
runs-on: ubuntu-latest
@@ -100,7 +100,7 @@ jobs:
100100
helm repo update
101101
102102
- name: Run chart-testing (lint)
103-
run: ct lint --config ct.yaml
103+
run: ct lint --config ct.yaml --helm-extra-args="--set upstream.backstage.image.tag=next --set global.clusterRouterBase=app.example.yaml"
104104

105105
- name: Create KIND Cluster
106106
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
@@ -110,4 +110,4 @@ jobs:
110110

111111
- name: Run chart-testing (next)
112112
# test with the next backstage-showcase version (main branch)
113-
run: ct install --config ct-install.yaml --helm-extra-set-args="--set=upstream.backstage.image.tag=next"
113+
run: ct install --config ct-install.yaml --helm-extra-set-args="--set=upstream.backstage.image.tag=next --set=global.clusterRouterBase=app.example.com"

charts/backstage/Chart.yaml

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

charts/backstage/README.md

Lines changed: 21 additions & 24 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.11.4](https://img.shields.io/badge/Version-2.11.4-informational?style=flat-square)
5+
![Version: 2.12.0](https://img.shields.io/badge/Version-2.12.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
@@ -70,15 +70,6 @@ helm repo add janus-idp https://janus-idp.github.io/helm-backstage
7070

7171
Once the chart has been added, install this chart. However before doing so, please review the default `values.yaml` and adjust as needed.
7272

73-
- To get proper connection between frontend and backend of Backstage please update the `apps.example.com` to match your cluster host:
74-
75-
```yaml
76-
global:
77-
clusterRouterBase: apps.example.com
78-
```
79-
80-
> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file
81-
8273
- If your cluster doesn't provide PVCs, you should disable PostgreSQL persistence via:
8374

8475
```yaml
@@ -132,12 +123,12 @@ Kubernetes: `>= 1.19.0-0`
132123
| global.auth.backend | Backend service to service authentication <br /> Ref: https://backstage.io/docs/auth/service-to-service-auth/ | object | `{"enabled":true,"existingSecret":"","value":""}` |
133124
| global.auth.backend.enabled | Enable backend service to service authentication, unless configured otherwise it generates a secret value | bool | `true` |
134125
| global.auth.backend.existingSecret | Instead of generating a secret value, refer to existing secret | string | `""` |
135-
| global.auth.backend.value | Instead of generating a secret value, use fo;lowing value | string | `""` |
136-
| 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"` |
126+
| global.auth.backend.value | Instead of generating a secret value, use the following value | string | `""` |
127+
| 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 | `""` |
137128
| global.dynamic.includes | Array of YAML files listing dynamic plugins to include with those listed in the `plugins` field. Relative paths are resolved from the working directory of the initContainer that will install the plugins (`/opt/app-root/src`). | list | `["dynamic-plugins.default.yaml"]` |
138129
| global.dynamic.includes[0] | List of dynamic plugins included inside the `janus-idp/backstage-showcase` container image, some of which are disabled by default. This file ONLY works with the `janus-idp/backstage-showcase` container image. | string | `"dynamic-plugins.default.yaml"` |
139130
| global.dynamic.plugins | List of dynamic plugins, possibly overriding the plugins listed in `includes` files. Every item defines the plugin `package` as a [NPM package spec](https://docs.npmjs.com/cli/v10/using-npm/package-spec), an optional `pluginConfig` with plugin-specific backstage configuration, and an optional `disabled` flag to disable/enable a plugin listed in `includes` files. It also includes an `integrity` field that is used to verify the plugin package [integrity](https://w3c.github.io/webappsec-subresource-integrity/#integrity-metadata-description). | list | `[]` |
140-
| global.host | Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig` | string | `""` |
131+
| global.host | Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`. If neither `global.clusterRouterBase` nor `global.host` are set, the helm chart will attempt to autofill with the hostname of the [OCP Ingress configuration](https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html/networking/configuring-ingress#nw-installation-ingress-config-asset_configuring-ingress) | string | `""` |
141132
| 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"}` |
142133
| route.annotations | Route specific annotations | object | `{}` |
143134
| route.enabled | Enable the creation of the route resource | bool | `true` |
@@ -167,7 +158,7 @@ Features enabled by the default chart configuration:
167158
2. Exposes a `Route` for easy access to the instance
168159
3. Enables OpenShift-compatible PostgreSQL database storage
169160

170-
For additional instance features please consuls [documentation for `janus-idp/backstage-showcase`](https://github.com/janus-idp/backstage-showcase/).
161+
For additional instance features please consult the [documentation for `janus-idp/backstage-showcase`](https://github.com/janus-idp/backstage-showcase/tree/main/showcase-docs).
171162

172163
Additional features can be enabled by extending the default configuration at:
173164

@@ -182,9 +173,9 @@ upstream:
182173

183174
## Features
184175

185-
This charts defaults to using the Janus-IDP Backstage Showcase image that is OpenShift compatible:
176+
This charts defaults to using the [latest Janus-IDP Backstage Showcase image](https://quay.io/janus-idp/backstage-showcase:latest) that is OpenShift compatible:
186177

187-
```
178+
```console
188179
quay.io/janus-idp/backstage-showcase:latest
189180
```
190181

@@ -194,29 +185,35 @@ Additionally this chart enhances the upstream Backstage chart with following Ope
194185

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

197-
OpenShift routes are enabled by default. In order to use the chart without it, please switch to the `Ingress` resource via `upstream.ingress` values.
188+
OpenShift routes are enabled by default. In order to use the chart without it, please set `route.enabled` to `false` and switch to the `Ingress` resource via `upstream.ingress` values.
198189

199-
Routes can be further configured via the `route` value.
190+
Routes can be further configured via the `route` field.
200191

201-
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:
192+
By default, the chart expects you to expose Backstage via the autogenerated hostname, which is automatically obtained from the OpenShift Ingress Configurations.
193+
194+
To manually provide the Backstage pod with the right context, please add the following value:
202195

203196
```yaml
204197
# values.yaml
205198
global:
206199
clusterRouterBase: apps.example.com
207200
```
208201
209-
Custom hosts are also supported via following shorthand:
202+
> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file
203+
204+
Custom hosts are also supported via the following shorthand:
210205

211206
```yaml
212207
# values.yaml
213208
global:
214209
host: backstage.example.com
215210
```
216211

217-
Please note this is just a templating shorthand. For full manual configuration please pay attention to values under `route` key.
212+
> Note: Setting either `global.host` or `global.clusterRouterBase` will disable the automatic hostname discovery.
213+
When both fields are set, `global.host` will take precedence.
214+
These are just templating shorthands. For full manual configuration please pay attention to values under the `route` key.
218215

219-
Please note that any custom modifications to how backstage is being exposed may require additional changes to values:
216+
Any custom modifications to how backstage is being exposed may require additional changes to the `values.yaml`:
220217

221218
```yaml
222219
# values.yaml
@@ -233,12 +230,12 @@ upstream:
233230

234231
### Vanilla Kubernetes compatibility mode
235232

236-
In order to deploy this chart on vanilla Kubernetes or any other non-OCP platform, please make sure to apply following changes. Further customization may be required, depending on your exact Kubernetes setup:
233+
In order to deploy this chart on vanilla Kubernetes or any other non-OCP platform, please make sure to apply the following changes. Note that further customizations may be required, depending on your exact Kubernetes setup:
237234

238235
```yaml
239236
# values.yaml
240237
global:
241-
host: # Specify your own Ingress host
238+
host: # Specify your own Ingress host as automatic hostname discovery is not supported outside of OpenShift
242239
route:
243240
enabled: false # OpenShift Routes do not exist on vanilla Kubernetes
244241
upstream:

charts/backstage/README.md.gotmpl

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ helm repo add janus-idp https://janus-idp.github.io/helm-backstage
6464

6565
Once the chart has been added, install this chart. However before doing so, please review the default `values.yaml` and adjust as needed.
6666

67-
- To get proper connection between frontend and backend of Backstage please update the `apps.example.com` to match your cluster host:
68-
69-
```yaml
70-
global:
71-
clusterRouterBase: apps.example.com
72-
```
73-
74-
> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file
75-
7667
- If your cluster doesn't provide PVCs, you should disable PostgreSQL persistence via:
7768

7869
```yaml
@@ -123,7 +114,7 @@ Features enabled by the default chart configuration:
123114
2. Exposes a `Route` for easy access to the instance
124115
3. Enables OpenShift-compatible PostgreSQL database storage
125116

126-
For additional instance features please consuls [documentation for `janus-idp/backstage-showcase`](https://github.com/janus-idp/backstage-showcase/).
117+
For additional instance features please consult the [documentation for `janus-idp/backstage-showcase`](https://github.com/janus-idp/backstage-showcase/tree/main/showcase-docs).
127118

128119
Additional features can be enabled by extending the default configuration at:
129120

@@ -138,9 +129,9 @@ upstream:
138129

139130
## Features
140131

141-
This charts defaults to using the Janus-IDP Backstage Showcase image that is OpenShift compatible:
132+
This charts defaults to using the [latest Janus-IDP Backstage Showcase image](https://quay.io/janus-idp/backstage-showcase:latest) that is OpenShift compatible:
142133

143-
```
134+
```console
144135
quay.io/janus-idp/backstage-showcase:latest
145136
```
146137

@@ -150,29 +141,35 @@ Additionally this chart enhances the upstream Backstage chart with following Ope
150141

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

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.
144+
OpenShift routes are enabled by default. In order to use the chart without it, please set `route.enabled` to `false` and switch to the `Ingress` resource via `upstream.ingress` values.
154145

155-
Routes can be further configured via the `route` value.
146+
Routes can be further configured via the `route` field.
156147

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:
148+
By default, the chart expects you to expose Backstage via the autogenerated hostname, which is automatically obtained from the OpenShift Ingress Configurations.
149+
150+
To manually provide the Backstage pod with the right context, please add the following value:
158151

159152
```yaml
160153
# values.yaml
161154
global:
162155
clusterRouterBase: apps.example.com
163156
```
164157

165-
Custom hosts are also supported via following shorthand:
158+
> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file
159+
160+
Custom hosts are also supported via the following shorthand:
166161

167162
```yaml
168163
# values.yaml
169164
global:
170165
host: backstage.example.com
171166
```
172167

173-
Please note this is just a templating shorthand. For full manual configuration please pay attention to values under `route` key.
168+
> Note: Setting either `global.host` or `global.clusterRouterBase` will disable the automatic hostname discovery.
169+
When both fields are set, `global.host` will take precedence.
170+
These are just templating shorthands. For full manual configuration please pay attention to values under the `route` key.
174171

175-
Please note that any custom modifications to how backstage is being exposed may require additional changes to values:
172+
Any custom modifications to how backstage is being exposed may require additional changes to the `values.yaml`:
176173

177174
```yaml
178175
# values.yaml
@@ -190,12 +187,12 @@ upstream:
190187

191188
### Vanilla Kubernetes compatibility mode
192189

193-
In order to deploy this chart on vanilla Kubernetes or any other non-OCP platform, please make sure to apply following changes. Further customization may be required, depending on your exact Kubernetes setup:
190+
In order to deploy this chart on vanilla Kubernetes or any other non-OCP platform, please make sure to apply the following changes. Note that further customizations may be required, depending on your exact Kubernetes setup:
194191

195192
```yaml
196193
# values.yaml
197194
global:
198-
host: # Specify your own Ingress host
195+
host: # Specify your own Ingress host as automatic hostname discovery is not supported outside of OpenShift
199196
route:
200197
enabled: false # OpenShift Routes do not exist on vanilla Kubernetes
201198
upstream:

charts/backstage/templates/_helpers.tpl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ Returns custom hostname
66
{{- .Values.global.host -}}
77
{{- else if .Values.global.clusterRouterBase -}}
88
{{- printf "%s-%s.%s" (include "common.names.fullname" .) .Release.Namespace .Values.global.clusterRouterBase -}}
9+
{{/*
10+
Attempt to obtain a fallback value for the hostname from the openshift cluster if both global.host and global.clusterRouterBase are "" and if deployed on Openshift
11+
*/}}
12+
{{- else if .Capabilities.APIVersions.Has "config.openshift.io/v1/Ingress" }}
13+
{{- $cluster := (lookup "config.openshift.io/v1" "Ingress" "" "cluster") -}}
14+
{{- if and (hasKey $cluster "spec") (hasKey $cluster.spec "domain") }}
15+
{{- printf "%s-%s.%s" (include "common.names.fullname" .) .Release.Namespace $cluster.spec.domain -}}
16+
{{- else -}}
17+
{{ fail "Unable to generate hostname, OCP Ingress Resource is missing `spec.domain` field. Please provide a valid hostname in `global.host` or `global.clusterRouterBase` instead" }}
18+
{{- end }}
919
{{- else -}}
10-
{{ fail "Unable to generate hostname" }}
20+
{{ fail "Unable to generate hostname, please provide a valid hostname in `global.host` or `global.clusterRouterBase`" }}
1121
{{- end -}}
1222
{{- end -}}
1323

charts/backstage/values.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"value": {
2323
"default": "",
24-
"title": "Instead of generating a secret value, use fo;lowing value",
24+
"title": "Instead of generating a secret value, use the following value",
2525
"type": "string"
2626
}
2727
},
@@ -33,7 +33,7 @@
3333
"type": "object"
3434
},
3535
"clusterRouterBase": {
36-
"default": "apps.example.com",
36+
"default": "",
3737
"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.",
3838
"type": "string"
3939
},

charts/backstage/values.schema.tmpl.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"clusterRouterBase": {
2424
"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.",
2525
"type": "string",
26-
"default": "apps.example.com"
26+
"default": ""
2727
},
2828
"host": {
2929
"title": "Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`",
@@ -93,7 +93,7 @@
9393
"default": ""
9494
},
9595
"value": {
96-
"title": "Instead of generating a secret value, use fo;lowing value",
96+
"title": "Instead of generating a secret value, use the following value",
9797
"type": "string",
9898
"default": ""
9999
}

0 commit comments

Comments
 (0)