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

Commit

Permalink
Merge pull request #63 from tumido/simplify-routes
Browse files Browse the repository at this point in the history
feat: further simplify the config for autogenerated Route host in OCP
  • Loading branch information
tumido committed Jun 20, 2023
2 parents 5f13f2a + 276b932 commit 6117449
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 63 deletions.
2 changes: 1 addition & 1 deletion charts/backstage/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ sources:
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.0.3
version: 2.1.0
68 changes: 38 additions & 30 deletions charts/backstage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Janus-IDP Backstage Helm Chart

[![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)
![Version: 2.0.3](https://img.shields.io/badge/Version-2.0.3-informational?style=flat-square)
![Version: 2.1.0](https://img.shields.io/badge/Version-2.1.0-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

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

```yaml
upstream:
backstage:
appConfig:
app:
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
backend:
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
cors:
origin: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
global:
clusterRouterBase: apps.example.com
```

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

```yaml
Expand Down Expand Up @@ -133,10 +128,12 @@ Kubernetes: `>= 1.19.0-0`

| Key | Description | Type | Default |
|-----|-------------|------|---------|
| route | OpenShift Route parameters | object | `{"annotations":{},"enabled":true,"host":"","path":"/","tls":{"caCertificate":"","certificate":"","destinationCACertificate":"","enabled":true,"insecureEdgeTerminationPolicy":"Redirect","key":"","termination":"edge"},"wildcardPolicy":"None"}` |
| 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"` |
| global.host | Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig` | string | `""` |
| 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"}` |
| route.annotations | Route specific annotations | object | `{}` |
| route.enabled | Enable the creation of the route resource | bool | `true` |
| 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 | `""` |
| 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 }}"` |
| route.path | Path that the router watches for, to route traffic for to the service. | string | `"/"` |
| 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"}` |
| route.tls.caCertificate | Cert authority certificate contents. Optional | string | `""` |
Expand Down Expand Up @@ -186,27 +183,38 @@ Additionally this chart enhances the upstream Backstage chart with following Ope

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

Please enable it using following values:
OpenShift routes are enabled by default. In order to use the chart without it, please switch to the `Ingress` resource via `upstream.ingress` values.

Routes can be further configured via the `route` value.

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:

```yaml
# values.yaml
upstream:
backstage:
extraEnvVars:
- name: "APP_CONFIG_app_baseUrl"
value: "https://{{ .Values.global.host }}"
- name: "APP_CONFIG_backend_baseUrl"
value: "https://{{ .Values.global.host }}"
- name: "APP_CONFIG_backend_cors_origin"
value: "https://{{ .Values.global.host }}"
ingress:
enabled: false
route:
enabled: true
host: "{{ .Values.global.host }}"
tls:
enabled: true
global:
clusterRouterBase: apps.example.com
```

Custom hosts are also supported via following shorthand:

```yaml
# values.yaml
global:
host: backstage.apps.example.com
host: backstage.example.com
```

Please note this is just a templating shorthand. For full manual configuration please pay attention to values under `route` key.

Please note that any custom modifications to how backstage is being exposed may require additional changes to values:

```yaml
# values.yaml
upstream:
appConfig:
app:
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
backend:
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
cors:
origin: 'https://{{- include "janus-idp.hostname" . }}'
```
60 changes: 33 additions & 27 deletions charts/backstage/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,12 @@ Once the chart has been added, install this chart. However before doing so, plea
- To get proper connection between frontend and backend of Backstage please update the `apps.example.com` to match your cluster host:

```yaml
upstream:
backstage:
appConfig:
app:
baseUrl: 'https://{{"{{"}}- print .Release.Name "-" .Release.Namespace -{{"}}"}}.apps.example.com'
backend:
baseUrl: 'https://{{"{{"}}- print .Release.Name "-" .Release.Namespace -{{"}}"}}.apps.example.com'
cors:
origin: 'https://{{"{{"}}- print .Release.Name "-" .Release.Namespace -{{"}}"}}.apps.example.com'
global:
clusterRouterBase: apps.example.com
```

> Tip: you can use `helm upgrade -i --set global.clusterRouterBase=apps.example.com ...` instead of a value file

- If your cluster doesn't provide PVCs, you should disable PostgreSQL persistence via:

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

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

Please enable it using following values:
OpenShift routes are enabled by default. In order to use the chart without it, please switch to the `Ingress` resource via `upstream.ingress` values.

Routes can be further configured via the `route` value.

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:

```yaml
# values.yaml
upstream:
backstage:
extraEnvVars:
- name: "APP_CONFIG_app_baseUrl"
value: "https://{{"{{"}} .Values.global.host {{"}}"}}"
- name: "APP_CONFIG_backend_baseUrl"
value: "https://{{"{{"}} .Values.global.host {{"}}"}}"
- name: "APP_CONFIG_backend_cors_origin"
value: "https://{{"{{"}} .Values.global.host {{"}}"}}"
ingress:
enabled: false
route:
enabled: true
host: "{{"{{"}} .Values.global.host {{"}}"}}"
tls:
enabled: true
global:
clusterRouterBase: apps.example.com
```

Custom hosts are also supported via following shorthand:

```yaml
# values.yaml
global:
host: backstage.apps.example.com
host: backstage.example.com
```

Please note this is just a templating shorthand. For full manual configuration please pay attention to values under `route` key.

Please note that any custom modifications to how backstage is being exposed may require additional changes to values:

```yaml
# values.yaml
upstream:
appConfig:
app:
baseUrl: 'https://{{"{{"}}- include "janus-idp.hostname" . {{"}}"}}'
backend:
baseUrl: 'https://{{"{{"}}- include "janus-idp.hostname" . {{"}}"}}'
cors:
origin: 'https://{{"{{"}}- include "janus-idp.hostname" . {{"}}"}}'
```
12 changes: 12 additions & 0 deletions charts/backstage/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{/*
Returns custom hostname
*/}}
{{- define "janus-idp.hostname" -}}
{{- if .Values.global.host -}}
{{- .Values.global.host -}}
{{- else if .Values.global.clusterRouterBase -}}
{{- print .Release.Name "-" .Release.Namespace "." .Values.global.clusterRouterBase -}}
{{- else -}}
{{ fail "Unable to generate hostname" }}
{{- end -}}
{{- end -}}
15 changes: 15 additions & 0 deletions charts/backstage/values.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"$id": "https://raw.githubusercontent.com/janus-idp/helm-backstage/main/charts/backstage/values.schema.json",
"properties": {
"global": {
"properties": {
"clusterRouterBase": {
"default": "apps.example.com",
"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.",
"type": "string"
},
"host": {
"default": "",
"title": "Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`",
"type": "string"
}
},
"type": "object"
},
"route": {
"additionalProperties": false,
"properties": {
Expand Down
15 changes: 15 additions & 0 deletions charts/backstage/values.schema.tmpl.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
}
}
},
"global": {
"type": "object",
"properties": {
"clusterRouterBase": {
"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.",
"type": "string",
"default": "apps.example.com"
},
"host": {
"title": "Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`",
"type": "string",
"default": ""
}
}
},
"route": {
"title": "OpenShift Route parameters.",
"type": "object",
Expand Down
18 changes: 13 additions & 5 deletions charts/backstage/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
global:
# -- 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.
clusterRouterBase: apps.example.com
# -- Custom hostname shorthand, overrides `global.clusterRouterBase`, `upstream.ingress.host`, `route.host`, and url values in `upstream.backstage.appConfig`
host: ""

# -- Upstream Backstage [chart configuration](https://github.com/backstage/charts/blob/main/charts/backstage/values.yaml)
# @default -- Use Openshift compatible settings
upstream:
Expand All @@ -17,12 +23,12 @@ upstream:
# can't accommodate that properly.
appConfig:
app:
# Please update to match host.
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
# Please update to match host in case you don't want to configure hostname via `global.clusterRouterBase` or `global.host`.
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
backend:
baseUrl: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
baseUrl: 'https://{{- include "janus-idp.hostname" . }}'
cors:
origin: 'https://{{- print .Release.Name "-" .Release.Namespace -}}.apps.example.com'
origin: 'https://{{- include "janus-idp.hostname" . }}'
database:
connection:
password: ${POSTGRESQL_ADMIN_PASSWORD}
Expand Down Expand Up @@ -62,6 +68,8 @@ upstream:
secretKeyRef:
key: postgres-password
name: "{{ .Release.Name }}-postgresql"
ingress:
host: "{{ .Values.global.host }}"


# -- OpenShift Route parameters
Expand All @@ -74,7 +82,7 @@ route:
enabled: true

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

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

0 comments on commit 6117449

Please sign in to comment.