Skip to content

Commit ff60712

Browse files
froblesmartintumido
andauthoredDec 16, 2022
feat: define extra app config which generates ConfigMap (#23)
* feat: define extra app config which generates ConfigMap * change appConfig from multiline string to dict * docs: document the usage of appConfig key to generate ConfigMap automatically * chore: load ConfigMap with tplvalues from Bitnami common instead of just toYaml * tests: appConfig and extraVolumes * docs: warn about appConfig vs extraAppConfig priority * docs: reference section with MarkDown link Co-authored-by: Tom Coufal <7453394+tumido@users.noreply.github.com> * docs: reference Backstage config docs and template to clarify config priority * docs: typo Co-authored-by: Tom Coufal <7453394+tumido@users.noreply.github.com> * fix: run helm-docs * fix: do not use specific drivers on CI tests * chore: bump minor version Co-authored-by: Tom Coufal <7453394+tumido@users.noreply.github.com>
1 parent 3f3a618 commit ff60712

9 files changed

+86
-3
lines changed
 

‎charts/backstage/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.9.0
18+
version: 0.10.0
1919

2020
dependencies:
2121
- name: common

‎charts/backstage/README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Backstage Helm Chart
33

4-
![Version: 0.9.0](https://img.shields.io/badge/Version-0.9.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
4+
![Version: 0.10.0](https://img.shields.io/badge/Version-0.10.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
55

66
A Helm chart for deploying a Backstage application
77

@@ -85,6 +85,7 @@ The command removes all the Kubernetes components associated with the chart and
8585

8686
| Key | Description | Type | Default |
8787
|-----|-------------|------|---------|
88+
| backstage.appConfig | Generates ConfigMap and configures it in the Backstage pods | object | `{}` |
8889
| backstage.args | | list | `[]` |
8990
| backstage.command[0] | | string | `"node"` |
9091
| backstage.command[1] | | string | `"packages/backend"` |
@@ -239,6 +240,21 @@ Now that the ConfigMap has been created on your Kubernetes cluster, you can refe
239240

240241
The chart will mount the content of the ConfigMap as a new `app-config.extra.yaml` file and automatically pass the extra configuration to your instance.
241242

243+
### Pass configuration to be stored in a ConfigMap
244+
245+
> :warning: In case of using both appConfig and extraAppConfig, appConfig will have higher priority over extraAppConfig. For more information you can check the [Backstage docs](https://backstage.io/docs/conf/writing#configuration-files) and how this [Helm Chart configures the Backstage arguments](templates/backstage-deployment.yaml)
246+
247+
In addition to following the [previous step "Pass extra configuration files"](#pass-extra-configuration-files), you can get the Config Map automatically deployed with this Helm Chart by defining the key `appConfig`:
248+
249+
```diff
250+
backstage:
251+
+ appConfig:
252+
+ app:
253+
+ baseUrl: https://somedomain.tld
254+
```
255+
256+
The chart will mount the content of the ConfigMap as a new `app-config-from-configmap.yaml` file and automatically pass the extra configuration to your instance.
257+
242258
### Configuring Chart PostgreSQL
243259

244260
With the Backstage Helm Chart, it offers - as a subchart - a Bitnami PostgreSQL database. This can be enabled by switching `postgresql.enabled` to true (it is `false` by default). If switched on, the Helm Chart, on deployment, will automatically deploy a PostgreSQL instance and configure it with the credentials you specify. There are multiple ways of doing this that will be detailed below.

‎charts/backstage/README.md.gotmpl

+15
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ Now that the ConfigMap has been created on your Kubernetes cluster, you can refe
170170

171171
The chart will mount the content of the ConfigMap as a new `app-config.extra.yaml` file and automatically pass the extra configuration to your instance.
172172

173+
### Pass configuration to be stored in a ConfigMap
174+
175+
> :warning: In case of using both appConfig and extraAppConfig, appConfig will have higher priority over extraAppConfig. For more information you can check the [Backstage docs](https://backstage.io/docs/conf/writing#configuration-files) and how this [Helm Chart configures the Backstage arguments](templates/backstage-deployment.yaml)
176+
177+
In addition to following the [previous step "Pass extra configuration files"](#pass-extra-configuration-files), you can get the Config Map automatically deployed with this Helm Chart by defining the key `appConfig`:
178+
179+
```diff
180+
backstage:
181+
+ appConfig:
182+
+ app:
183+
+ baseUrl: https://somedomain.tld
184+
```
185+
186+
The chart will mount the content of the ConfigMap as a new `app-config-from-configmap.yaml` file and automatically pass the extra configuration to your instance.
187+
173188
### Configuring Chart PostgreSQL
174189

175190
With the Backstage Helm Chart, it offers - as a subchart - a Bitnami PostgreSQL database. This can be enabled by switching `postgresql.enabled` to true (it is `false` by default). If switched on, the Helm Chart, on deployment, will automatically deploy a PostgreSQL instance and configure it with the credentials you specify. There are multiple ways of doing this that will be detailed below.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
backstage:
2+
appConfig:
3+
app:
4+
# Let's test that everything is fine with comments
5+
title: The very best Backstage Helm Chart! :D
6+
baseUrl: https://somedomain.tl
7+
backend:
8+
baseUrl: https://somedomain.tl
9+
listen:
10+
port: 12345
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
backstage:
2+
extraVolumeMounts:
3+
- name: test
4+
mountPath: /somepath
5+
readOnly: true
6+
extraVolumes:
7+
- name: test
8+
emptyDir:
9+
sizeLimit: 5Mi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- if .Values.backstage.appConfig }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: backstage-app-config
6+
data:
7+
app-config.yaml: |
8+
{{- include "common.tplvalues.render" ( dict "value" .Values.backstage.appConfig "context" $) | nindent 4 }}
9+
{{- end }}

‎charts/backstage/templates/backstage-deployment.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ spec:
4343
{{- include "common.tplvalues.render" ( dict "value" .Values.backstage.extraVolumes "context" $ ) | nindent 8 }}
4444
{{- end }}
4545
{{- end }}
46+
{{- if .Values.backstage.appConfig }}
47+
- name: backstage-app-config
48+
configMap:
49+
name: backstage-app-config
50+
{{- end }}
4651
{{- if .Values.backstage.image.pullSecrets }}
4752
imagePullSecrets:
4853
{{- range .Values.backstage.image.pullSecrets }}
@@ -83,6 +88,10 @@ spec:
8388
- {{ .filename | quote }}
8489
{{- end }}
8590
{{- end }}
91+
{{- if .Values.backstage.appConfig }}
92+
- "--config"
93+
- "app-config-from-configmap.yaml"
94+
{{- end }}
8695
{{- end }}
8796
{{- if .Values.backstage.extraEnvVarsSecrets }}
8897
envFrom:
@@ -114,13 +123,18 @@ spec:
114123
- name: backend
115124
containerPort: {{ .Values.backstage.containerPorts.backend }}
116125
protocol: TCP
117-
{{- if (or .Values.backstage.extraAppConfig (and .Values.backstage.extraVolumeMounts .Values.backstage.extraVolumes)) }}
126+
{{- if (or .Values.backstage.extraAppConfig .Values.backstage.appConfig (and .Values.backstage.extraVolumeMounts .Values.backstage.extraVolumes)) }}
118127
volumeMounts:
119128
{{- range .Values.backstage.extraAppConfig }}
120129
- name: {{ .configMapRef }}
121130
mountPath: "/app/{{ .filename }}"
122131
subPath: {{ .filename }}
123132
{{- end }}
133+
{{- if .Values.backstage.appConfig }}
134+
- name: backstage-app-config
135+
mountPath: /app/app-config-from-configmap.yaml
136+
subPath: app-config.yaml
137+
{{- end }}
124138
{{- if .Values.backstage.extraVolumeMounts }}
125139
{{- include "common.tplvalues.render" ( dict "value" .Values.backstage.extraVolumeMounts "context" $ ) | nindent 12 }}
126140
{{- end }}

‎charts/backstage/values.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ backstage:
143143
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
144144
containerSecurityContext: {}
145145

146+
# Allows to define the appConfig as a multiline string that generates a ConfigMap
147+
# automatically, not requiring to have it pre provisioned as with the extraAppConfig key.
148+
# DO NOT USE if you need to put sensitive data in the appConfig.
149+
# E.g:
150+
# appConfig:
151+
# app:
152+
# baseUrl: https://somedomain.tld
153+
# -- Generates ConfigMap and configures it in the Backstage pods
154+
appConfig: {}
155+
146156
## @section Traffic Exposure parameters
147157

148158
## Service parameters

0 commit comments

Comments
 (0)
Please sign in to comment.