Overview
Search
⌃K
Links

Mounting Config as Files

Mounting Kubernetes ConfigMaps as files
In Kubernetes, you can mount application configuration or secrets as files.

Mount a Kubernetes ConfigMap

The basic steps are:
  1. 1.
    Create a Kubernetes ConfigMap
  2. 2.
    Edit the Service, and add a volume that refers to the config map

Create the Kubernetes ConfigMap

Navigate to the DevOps -> Containers -> EKS / Native page and click the Kubernetes Config Maps tab. Click the blue + Add button to open the 'Add Kubernetes Config Map' form.
  • Give your config map a name, such as my-config-map.
  • Add a data key / value pair for each file that you want to have in your config map. The key will be the file name, and the value will be the file contents.
Click Create to create the config map.

Mount the Kubernetes ConfigMap as a volume

Navigate to the DevOps -> Containers -> EKS / Native page and click the Services tab. In the Actions column, click the
edit icon for the service that you want to edit.
The volume configuration is on the second (Advanced Options) page, so click the Next -> button to skip to that page.
In the Volumes field, enter configuration YAML to mount your config map as a volume. For example, to mount a config map named my-config-map to a directory named /app/my-config, you could use the following YAML:
- Name: my-config
Path: /app/my-config
Spec:
ConfigMap:
Name: my-config-map

Optional Settings for Mounting ConfigMaps

If you want to pick and choose individual ConfigMap items and specify the subpath it will be mounted at, you can use different configuration. For example, if you want the key named my-file-name to mounted to /app/my-config/config-file , you could use the following YAML:
Path: /app/my-config
Spec:
ConfigMap:
Name: my-config-map
Items:
- Key: my-file-name
Path: config-file

Mount a Kubernetes Secret

The basic steps are:
  1. 1.
    Create a Kubernetes Secret
  2. 2.
    Edit the Service, and add a volume that refers to the secret

Create the Kubernetes Secret

Navigate to the DevOps -> Containers -> EKS / Native page and click the Kubernetes Secrets tab. Click the blue + Add button to open the 'Add Kubernetes Secret' form.
  • Give your secret a name, such as my-secret-files.
  • Add a data key / value pair for each file that you want to have in your secret. The key will be the file name, and the value will be the file contents.
Click Add to create the secret.

Create a multi-line Kubernetes Secret

See below example:

Mount the Kubernetes Secret as a volume

Navigate to the DevOps -> Containers -> EKS / Native page and click the Services tab. In the Actions column, click the
edit icon for the service that you want to edit.
The volume configuration is on the second (Advanced Options) page, so click the Next -> button to skip to that page.
In the Volumes field, enter configuration YAML to mount your secret as a volume. For example, to mount a secret named my-secret-files to a directory named /app/my-config, you could use the following YAML:
- Name: my-config
Path: /app/my-config
Spec:
Secret:
SecretName: my-secret-files

Optional Settings for Mounting Secrets

If you want to pick and choose individual Secret items and specify the subpath it will be mounted at, you can use different configuration. For example, if you want the key named secret-file to mounted to /app/my-config/config-file , you could use the following YAML:
- Name: my-config
Path: /app/my-config
Spec:
Secret:
SecretName: my-secret-files
Items:
- Key: secret-file
Path: config-file