Updated on 2022-04-02 GMT+08:00

ConfigMaps

ConfigMaps allow you to decouple configuration files from container images to enhance the portability of workloads.

ConfigMaps provide the following benefits:

  • Manage configurations for different environments and services.
  • Deploy workloads in different environments. Multiple versions are supported for configuration files so that you can update and roll back workloads easily.
  • Quickly import configurations in the form of files to containers.

After a ConfigMap is created on the MCP console, a ConfigMap with the same name will be created in all clusters deployed on this MCP.

Creating a ConfigMap

  1. Log in to the MCP console. In the navigation pane, choose Resource Management > Configuration Center, and click Create ConfigMap under the ConfigMaps tab.
  2. Set the parameters listed in Table 1.

    Table 1 Parameters for creating a ConfigMap

    Parameter

    Description

    Name

    Name of a ConfigMap, which must be unique in a namespace.

    Namespace

    Namespace to which the ConfigMap belongs. If you do not specify this parameter, the value default is used by default.

    Data

    The workload configuration data can be used in a container or used to store the configuration data. Key specifies the file name, and Value specifies the file content.

    1. Click Add Data.
    2. Set Key and Value.

    Label

    Labels are attached to objects such as workloads, nodes, and Services in key-value pairs.

    Labels define identified attributes of these objects and can be used to manage and select objects.

    1. Click Add Label.
    2. Set Key and Value.

    Description

    Description of the ConfigMap.

    Cluster

    Cluster that will use the ConfigMap you created.

  3. Click Create after the configuration is complete.

Using a ConfigMap

After the ConfigMap is created, you can mount the ConfigMap to a container during workload creation (for details, see Deployments). Then, you can read the ConfigMap data from the mount path of the container.

Related Operations

After creating a ConfigMap, you can update or delete it as described in Table 2.
Table 2 Other operations

Operation

Description

Viewing a YAML file

Click View YAML in the row where the target ConfigMap resides to view its YAML file.

Updating a ConfigMap

  1. Choose More > Update in the Operation column of the target ConfigMap.
  2. Modify the ConfigMap information according to Table 1.
  3. Click Update.

Deleting a ConfigMap

  1. Select the ConfigMaps to be deleted.
  2. Choose More > Delete in the Operation column.
  3. Click Yes.

Viewing events

Select a ConfigMap and choose More > View Event in the Operation column to view the events of the ConfigMap.

NOTE:

Event data will be retained for 1 hour and then automatically deleted.