While most types of Kubernetes secrets store sensitive information, ConfigMaps store general configuration information, such as a group of config files. Because ConfigMaps don’t store sensitive information, they can be updated automatically, and therefore don’t require their containers to be restarted following update (unlike most secret types, which require manual updates and a container restart to take effect).

ConfigMaps accept key value pairs in common string formats, like config files or JSON blobs. After you upload a config map, any workload can reference it as either an environment variable or a volume mount.

Note: ConfigMaps are only available within namespaces and not projects. (https://rancher.com/docs/rancher/v2.x/en/k8s-in-rancher/projects-and-namespaces/#namespaces) ConfigMaps store general configuration information for an application, such as configuration files, command-line arguments, environment variables, etc. ConfigMaps accept key value pairs in common string formats, like config files or JSON blobs. Add ConfigMaps to your Rancher workspaces so that you can add them to your workloads later.

Note: ConfigMaps can only be applied to namespaces and not projects.

  1. From the Global view, select the project containing the namespace that you want to add a ConfigMap to.

  2. From the main menu, select Resources > Config Maps. Click Add Config Map.

  3. Enter a Name for the Config Map.

    Note: Kubernetes classifies ConfigMaps as secrets, and no two secrets in a project or namespace can have duplicate names. Therefore, to prevent conflicts, your ConfigMaps must have a unique name among the other certificates, ConfigMaps, registries, and secrets within your workspace.

  4. Select the Namespace you want to add Config Map to. You can also add a new namespace on the fly by clicking Add to a new namespace.

  5. From Config Map Values, click Add Config Map Value to add a key value pair to your ConfigMap. Add as many values as you need.

  6. Click Save.

    Note: Don’t use ConfigMaps to store sensitive data use a secret.

    Tip: You can add multiple key value pairs to the ConfigMap by copying and pasting.

    Bulk Key Value Pair Copy/Paste

Result: Your ConfigMap is added to the namespace. You can view it in the Rancher UI from the Resources > Config Maps view.

What’s Next?

Now that you have a ConfigMap added to a namespace, you can add it to a workload that you deploy from the namespace of origin. You can use the ConfigMap to specify information for you application to consume, such as:

  • Application environment variables.
  • Specifying parameters for a Volume mounted to the workload.

For more information on adding ConfigMaps to a workload, see Deploying Workloads.