Skip to content

Commit 2455cf4

Browse files
authored
RHIDP-8828: Injecting resources for backstage containers (#1464)
* Injecting resources for backstage containers * Added missing content * More changes * Minor changes * Add extra env and pvc config * Incorporated Gennady's comments * Adding close table asciidoc format * Removed redundant file * Updated the table * Minor updates to the table * Incorporated Judy's comments * Incorporated some of Jana's comments * Incorporated Jana's feedback * Consolidating procedure with similar info * Minor change * A few changes * Changes * Merge them all! * Minor comment
1 parent 9f7dd3e commit 2455cf4

3 files changed

+143
-82
lines changed

assemblies/assembly-provisioning-a-custom-configuration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ include::modules/configuring/proc-provisioning-your-custom-configuration.adoc[le
2424

2525
include::modules/configuring/proc-using-the-operator-to-run-rhdh-with-your-custom-configuration.adoc[leveloffset=+1]
2626

27-
include::modules/configuring/proc-mounting-additional-files-in-your-custom-configuration-using-rhdh-operator.adoc[leveloffset=+2]
27+
include::modules/configuring/proc-injecting-custom-files-and-environment-variables-into-backstage-containers.adoc[leveloffset=+2]
2828

2929
include::modules/configuring/proc-using-the-helm-chart-to-run-rhdh-with-your-custom-configuration.adoc[leveloffset=+1]
3030

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="proc-injecting-custom-files-and-environment-variables-into-backstage-containers"]
4+
= Injecting extra files and environment variables into {backstage} containers
5+
6+
The `mountPath` field specifies the location where a ConfigMap or Secret is mounted.
7+
The behavior of the mount, whether it includes or excludes a `subPath`, depends on the specification of the `key` or `mountPath` fields.
8+
9+
* If `key` and `mountPath` are not specified: Each key or value is mounted as a `filename` or content with a `subPath`.
10+
* If `key` is specified with or without `mountPath`: The specified key or value is mounted with a `subPath`.
11+
* If only `mountPath` is specified: A directory containing all the keys or values is mounted without a `subPath`.
12+
* If the `containers` field is not specified: The volume mounts only to the `backstage-backend` container. By default, files mount 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.
13+
14+
[NOTE]
15+
====
16+
* {ocp-short} does not automatically update a volume mounted with `subPath`. By default, the {product-very-short} Operator monitors these ConfigMaps or Secrets and refreshes the {product-very-short} Pod when changes occur.
17+
* For security purposes, {product} does not give the Operator Service Account read access to Secrets. As a result, mounting files from Secrets without specifying both mountPath and key is not supported.
18+
====
19+
20+
.Procedure
21+
22+
. Apply the configuration to your `{product-custom-resource-type} custom resource (CR)`. The following code block is an example:
23+
+
24+
[source,yaml]
25+
----
26+
spec:
27+
application:
28+
extraFiles:
29+
mountPath: _<default_mount_path>_
30+
configMaps:
31+
- name: _<configmap_name_all_entries>_
32+
- name: _<configmap_name_single_key>_
33+
key: _<specific_file_key>_
34+
containers:
35+
- "*"
36+
- name: _<configmap_name_custom_path>_
37+
mountPath: _<custom_cm_mount_path>_
38+
containers:
39+
- backstage-backend
40+
- install-dynamic-plugins
41+
secrets:
42+
- name: _<secret_name_single_key>_
43+
key: _<specific_secret_key>_
44+
containers:
45+
- install-dynamic-plugins
46+
- name: _<secret_name_custom_path>_
47+
mountPath: _<custom_secret_mount_path>_
48+
pvcs:
49+
- name: _<pvc_name_default_path>_
50+
- name: _<pvc_name_custom_path>_
51+
mountPath: _<custom_pvc_mount_path>_
52+
extraEnvs:
53+
configMaps:
54+
- name: _<configmap_name_env_var>_
55+
key: _<env_var_key>_
56+
containers:
57+
- "*"
58+
secrets:
59+
- name: _<secret_name_all_envs>_
60+
envs:
61+
- name: _<static_env_var_name>_
62+
value: "_<static_env_var_value>_"
63+
containers:
64+
- install-dynamic-plugins
65+
----
66+
where:
67+
68+
`spec.application.extraFiles.mountPath`:: Specifies the default base mount path for files if no specific `mountPath` is set for a resource (for example, `/<default_mount_path>`).
69+
`spec.application.extraFiles.configMaps.name`:: Mounts all entries from `<configmap_name_all_entries>` to the default mount path.
70+
`spec.application.extraFiles.configMaps.key`:: Mounts **only the specified key (for example, `<specific_file_key>.txt`) from the ConfigMap.
71+
`spec.application.extraFiles.configMaps.containers`:: Targets all containers (`"*"`) for mounting.
72+
`spec.application.extraFiles.configMaps.mountPath`:: Overrides the default and mounts all ConfigMap entries as a directory at the specified path (for example, `/<custom_cm_mount_path>`).
73+
`spec.application.extraFiles.secrets.key`:: Mounts only a specific key from the Secret.
74+
`spec.application.extraFiles.secrets.mountPath`:: Overrides the default and mounts all Secret entries as a directory at the specified path (for example, `/<custom_secret_mount_path>`).
75+
`spec.application.extraFiles.pvcs.name`:: Mounts the PVC to the default mount path, appending the PVC name (for example, `/<default_mount_path>/<pvc_name_default_path>`).
76+
`spec.application.extraFiles.pvcs.mountPath`:: Overrides the default and mounts the PVC to the specified path (for example, `/<custom_pvc_mount_path>`).
77+
`spec.application.extraEnvs.configMaps.containers`:: Injects the specified ConfigMap key as an environment variable into all containers (`"*"`).
78+
`spec.application.extraEnvs.secrets.name`:: Injects all keys from the Secret as environment variables into the default container.
79+
`spec.application.envs.containers`:: Targets only the listed container for the static environment variable injection.
80+
81+
[NOTE]
82+
====
83+
The following explicit options are supported:
84+
85+
* *No* or an empty field: Mounts only to the `backstage-backend` container.
86+
* `*` (asterisk) as the first and only array element: Mounts to all containers.
87+
* Explicit container names, for example, `install-dynamic-plugins`: Mounts only to the listed containers.
88+
====
89+
90+
.Verification
91+
92+
The files are mounted with the following correct paths and container targets:
93+
94+
[cols="1,2,3,2", options="header"]
95+
|===
96+
| Resource | Target type | Path(s) or name(s) | Container(s)
97+
98+
| ConfigMap (`<configmap_name_all_entries>`)
99+
| File
100+
| `/<default_mount_path>/<file_1_key>`, `/<default_mount_path>/<file_2_key>`
101+
| `backstage-backend`
102+
103+
| ConfigMap (`<configmap_name_single_key>`)
104+
| File
105+
| `/<default_mount_path>/<specific_file_key>.txt`
106+
| All
107+
108+
| ConfigMap (`<configmap_name_custom_path>`)
109+
| Directory
110+
| `/<custom_cm_mount_path>/`
111+
| `backstage-backend`, `install-dynamic-plugins`
112+
113+
| Secret (`<secret_name_single_key>`)
114+
| File
115+
| `/<default_mount_path>/<specific_secret_key>.txt`
116+
| `install-dynamic-plugins`
117+
118+
| Secret (`<secret_name_custom_path>`)
119+
| Directory
120+
| `/<custom_secret_mount_path>/`
121+
| `backstage-backend`
122+
123+
| PVC (`<pvc_name_default_path>`)
124+
| Directory
125+
| `/<default_mount_path>/<pvc_name_default_path>`
126+
| `backstage-backend`
127+
128+
| ConfigMap (`<configmap_name_env_var>`)
129+
| Env Var
130+
| `<env_var_key>`
131+
| All
132+
133+
| Secret (`<secret_name_all_envs>`)
134+
| Env Var
135+
| `<secret_key_a>`, `<secret_key_b>`
136+
| `backstage-backend`
137+
138+
| CRD (`envs`)
139+
| Env Var
140+
| `<static_env_var_name> = <static_env_var_value>`
141+
| `install-dynamic-plugins`
142+
|===

modules/configuring/proc-mounting-additional-files-in-your-custom-configuration-using-rhdh-operator.adoc

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)