|
| 1 | +[id="mounting-additional-files-in-your-custom-configuration-using-rhdh-operator"] |
| 2 | += Mounting additional files in your custom configuration using the {product} Operator |
| 3 | + |
| 4 | +You can use the {product-short} Operator to mount extra files, such as a ConfigMap or Secret, to the container in a preferred location. |
| 5 | + |
| 6 | +The `mountPath` field specifies the location where a ConfigMap or Secret is mounted. The behavior of the mount, whether it includes or excludes a `subPath`, depends on the specification of the `key` or `mountPath` fields. |
| 7 | + |
| 8 | +* If `key` and `mountPath` are not specified: Each key or value is mounted as a `filename` or content with a `subPath`. |
| 9 | +* If `key` is specified with or without `mountPath`: The specified key or value is mounted with a `subPath`. |
| 10 | +* If only `mountPath` is specified: A directory containing all the keys or values is mounted without a `subPath`. |
| 11 | + |
| 12 | +[NOTE] |
| 13 | +==== |
| 14 | +* {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. |
| 15 | +* 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. |
| 16 | +==== |
| 17 | + |
| 18 | + |
| 19 | +.Prerequisites |
| 20 | +* You have developer permissions to access the {ocp-short} cluster containing your {product-short} instance using the {openshift-cli}. |
| 21 | +* link:{installing-on-ocp-book-url}[Your {ocp-short} administrator has installed the {product} Operator in {ocp-short}]. |
| 22 | + |
| 23 | +.Procedure |
| 24 | + |
| 25 | +. In {ocp-short}, create your ConfigMap or Secret with the following YAML codes: |
| 26 | ++ |
| 27 | +.Minimal `{my-extra-file-configmap}` ConfigMap example |
| 28 | +==== |
| 29 | +[source,yaml,subs="+attributes,+quotes"] |
| 30 | +---- |
| 31 | +apiVersion: v1 |
| 32 | +kind: ConfigMap |
| 33 | +metadata: |
| 34 | + name: {my-extra-file-configmap} |
| 35 | +data: |
| 36 | + file11.txt: | |
| 37 | + My file11 content |
| 38 | + file 12.txt: | |
| 39 | + My file12 content |
| 40 | +---- |
| 41 | +==== |
| 42 | ++ |
| 43 | +.Minimal `{my-product-secrets}` Secret example |
| 44 | +==== |
| 45 | +[source,yaml,subs="+attributes,+quotes"] |
| 46 | +---- |
| 47 | +apiVersion: v1 |
| 48 | +kind: Secret |
| 49 | +metadata: |
| 50 | + name: {my-product-secrets} |
| 51 | +StringData: |
| 52 | + secret11.txt: | |
| 53 | + secret-content |
| 54 | +---- |
| 55 | +==== |
| 56 | +For more information, see xref:provisioning-your-custom-configuration[Provisioning and using your custom {product} configuration]. |
| 57 | + |
| 58 | +. Set the value of the `configMaps name` to the name of the ConfigMap or `secrets name` to the name of the Secret in your `{product-custom-resource-type}` CR. For example: |
| 59 | ++ |
| 60 | +==== |
| 61 | +[source,yaml,subs="+attributes,+quotes"] |
| 62 | +---- |
| 63 | +spec: |
| 64 | + application: |
| 65 | + extraFiles: |
| 66 | + mountPath: /my/path |
| 67 | + configMaps: |
| 68 | + - name: {my-extra-file-configmap} |
| 69 | + key: file12.txt |
| 70 | + mountPath: /my/my-rhdh-config-map/path |
| 71 | + secrets: |
| 72 | + - name: {my-product-secrets} |
| 73 | + key: secret11.txt |
| 74 | + mountPath: /my/my-rhdh-secret/path |
| 75 | +
|
| 76 | +---- |
| 77 | +==== |
0 commit comments