Mounting ConfigMaps and Secrets as files
Mounting application configuration maps and secrets as files
In Kubernetes, you can mount application configurations or secrets as files.
Creating and Mounting a Kubernetes ConfigMap
Before you create and mount the Kubernetes ConfigMap, you must create a DuploCloud Service.
Creating a Kubernetes ConfigMap
In the DuploCloud Portal, navigate to Kubernetes -> Config Maps.
Click Add. The Add Kubernetes Config Map pane displays.
Name the ConfigMap you want to create, such as my-config-map.
Add a Data key/value pair for each file in your config map, separated by a colon (
:
). The key is the file name, and the value is the file's contents.Click Create.
Editing the DuploCloud Service
In the DuploCloud Portal, navigate to Kubernetes -> Services.
Select the service you want to modify from the Name column.
Click the Actions menu and select Edit.
Mounting the Kubernetes ConfigMap as a volume
On the Edit Service: service_name Basic Options page, click Next to navigate to the Advanced Options page.
On the Advanced Options page, in the Volumes field, enter the configuration YAML to mount the ConfigMap as a volume.
Example: mounting a ConfigMap as a volume
For example, to mount a config map named my-config-map
to a directory named /app/my-config
, enter the following YAML code block in the Volumes field:
Example: adding a Key value to select individual ConfigMap items
If you want to select individual ConfigMap items, specifying the subpath for mounting, you can use a different configuration. For example, if you want the key named my-file-name
to be mounted to /app/my-config/config-file
, use the following YAML:
Creating and Mounting a Kubernetes Secret
Before you create and mount a Kubernetes Secret, you must create a DuploCloud Service.
Creating a Kubernetes Secret
In the DuploCloud Portal, navigate to Kubernetes -> Secrets.
Click Add. The Add Kubernetes Secret pane displays.
Enter the Secret Name that you want to create, such as my-secret-files.
Add Secret Details such as a data key/value pair for each file in your secret. The key is the file name, and the value is the file's contents, separated by a colon (
:
).Click Add to create the secret.
Creating a multi-line Kubernetes Secret
Follow the steps in Creating a Kubernetes Secret, defining a Key value using the
PRIVATE_KEY_FILENAME
in the Secret Details field, as shown below.Click Add to create the multi-line secret.
Mount a Kubernetes Secret as a volume
In the DuploCloud Portal, edit the DuploCloud Service.
On the Edit Service: service_name Basic Options page, click Next to navigate to the Advanced Options page.
On the Advanced Options page, in the Volumes field, enter the configuration YAML to mount the Secret as a volume.
Example: mounting a Kubernetes Secret as a volume
For example, to mount a Secret named my-secret-files
to a directory named /app/my-config
, enter the following YAML code block in the Volumes field:
Example: adding a Key value to select individual Secret items
If you want to select individual Secret items, specifying the subpath for mounting, you can use a different configuration. For example, if you want the key named secret-file
to be mounted to /app/my-config/config-file
, use the following YAML:
Last updated