Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

:_mod-docs-content-type: PROCEDURE

[id="proc-injecting-custom-files-and-environment-variables-into-backstage-containers"]
= Injecting extra files and environment variables into {backstage} containers

By default, files mount only to the `backstage-backend` container. If the `containers` field is not specified, the volume mounts only to the `backstage-backend` container. You can also specify other targets, including a list of containers by name (such as `dynamic-plugin-install` or selectcustom sidecars) or select all containers in the {backstage} Pod.

. To mount files and injecting environment variables into different container targets, apply the configuration to your `{product-custom-resource-type} custom resource (CR)` as shown in the following code:
+
[source,yaml]
----
spec:
application:
extraFiles:
mountPath: /my/path
configMaps:
- name: cm1
- name: cm2
key: file21.txt
containers:
- "*"
- name: cm3
mountPath: /my/cm3/path
containers:
- backstage-backend
- install-dynamic-plugins
secrets:
- name: secret1
key: file3.txt
containers:
- install-dynamic-plugins
- name: secret2
mountPath: /my/secret2/path
pvcs:
- name: myclaim1
- name: myclaim2
mountPath: /vol/my/claim

extraEnvs:
configMaps:
- name: cm1
key: ENV_VAR1
containers:
- "*"
secrets:
- name: secret1
envs:
- name: MY_VAR
value: "my-value"
containers:
- install-dynamic-plugins
----
where:

`spec.application.extraFiles.mountPath`:: Specifies default mount path for extraFiles without a specific mountPath
`spec.application.extraFiles.configMaps.name`:: Mounts all entries from cm1 to `/my/path/`
`spec.application.extraFiles.configMaps.key`:: Mounts only `file21.txt`
`spec.application.extraFiles.configMaps.container`:: Targets all containers
`spec.application.extraFiles.configMaps.mountPath`:: Mounts all entries as a directory
`spec.application.extraFiles.configMaps.secrets.key`:: Specify key for security
`spec.application.extraFiles.configMaps.secrets.mountPath`:: Mounts all secret entries as a directory
`spec.application.extraFiles.configMaps.pvcs.name`:: Mounts to /my/path/myclaim1 (using default mountPath)
`spec.application.extraFiles.configMaps.pvcs.mountPath`:: Overrides default mountPath
`spec.application.extraEnvs.configMaps.containers`:: Injects into all containers
`spec.application.secrets.configMaps.containers`:: Injects all keys from secret1
`spec.application.envs.containers`:: Targets only this container.

The following explicit options are supported:

* *No* or an empty field: Mounts only to the `backstanamege-backend` container.
* `*` (asterisk) as the first and only array element: Mounts to all containers.
* Explicit container names, for example, `install-dynamic-plugins`: Mounts only to the listed containers.

.Verification

The files are mounted with the following paths and container targets:

[cols="1,2,3,2", options="header"]
|===
| Resource | Target type | Path(s) or name(s) | Container(s)

| ConfigMap (`cm1`)
| File
| `/my/path/file11.txt`, `/my/path/file12.txt`
| `backstage-backend`

| ConfigMap (`cm2`)
| File
| `/my/path/file21.txt`
| All

| ConfigMap (`cm3`)
| Directory
| `/my/cm3/path/`
| `backstage-backend`, `install-dynamic-plugins`

| Secret (`secret1`)
| File
| `/my/path/file3.txt`
| `install-dynamic-plugins`

| Secret (`secret2`)
| Directory
| `/my/secret2/path/`
| `backstage-backend`

| PVC (`myclaim1`)
| Directory
| `/my/path/myclaim1`
| `backstage-backend`

| ConfigMap (`cm1`)
| Env Var
| `ENV_VAR1`
| All

| Secret (`secret1`)
| Env Var
| `ENV_VAR3`, `ENV_VAR4`
| `backstage-backend`

| CRD (`envs`)
| Env Var
| `MY_VAR = my-value`
| `install-dynamic-plugins`
|===
3 changes: 3 additions & 0 deletions titles/configuring/master.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ include::assemblies/assembly-configuring-external-postgresql-databases.adoc[leve
include::modules/configuring-deployment/proc-configuring-deployment-by-using-the-operator.adoc[leveloffset=+1]


include::modules/configuring/proc-injecting-custom-files-and-environment-variables-into-backstage-containers.adoc[leveloffset=+1]


include::assemblies/assembly-configuring-high-availability.adoc[leveloffset=+1]


Expand Down