You can use ConfigMaps to store configurations that do not need to be kept confidential, such as the Java virtual machine (JVM) heap memory, JVM properties, and Java agent. This topic describes how to manage ConfigMaps.

Prerequisites

  • A Kubernetes cluster is created in the Container Service for Kubernetes (ACK) console.
    • To use an ACK cluster in Enterprise Distributed Application Service (EDAS), create a managed Kubernetes cluster or a dedicated Kubernetes cluster in the Container Service for Kubernetes (ACK) console. For more information, see the following topics:
    • To use a serverless Kubernetes cluster in EDAS, create a serverless Kubernetes cluster in the Container Service for Kubernetes (ACK) console. For more information, see Create an ASK cluster.
  • The created Kubernetes cluster is imported to EDAS. For more information, see Import a Kubernetes cluster to the EDAS console.

Background information

You can use ConfigMaps to store configurations that do not need to be kept confidential. ConfigMaps can be passed to containers when you create or deploy applications. If you modify a ConfigMap, the modification takes effect after you redeploy the relevant application.

You can use ConfigMaps in the following two scenarios:

Create a ConfigMap

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Configuration Management > Kubernetes Configurations.
  3. In the left-side pane of the Kubernetes Configurations page, click Configuration Items.
  4. On the Configuration Items page, select a region in the top navigation bar.
  5. On the Configuration Items page, click Create configuration item.
  6. In the Create configuration item panel, set the parameters such as Name and Cluster Name as required.
    Create a ConfigMap
    Parameter Description
    Name The name of the ConfigMap. The name can contain lowercase letters, hyphens (-), and digits. It must start with a letter and cannot end with a hyphen (-). The name can be up to 63 characters in length.
    Cluster Name The Kubernetes cluster for which you want to create the ConfigMap. Select the required Kubernetes cluster from the drop-down list.
    k8sNameSpace The Kubernetes namespace of the cluster. Internal system objects are allocated to different Kubernetes namespaces to form logically isolated projects, groups, or user groups. This way, different groups can be separately managed and can also share the resources of the entire cluster. Valid values:
    • default: the default Kubernetes namespace. If no Kubernetes namespace is specified for an object, the default Kubernetes namespace is used.
    • kube-system: the Kubernetes namespace of the objects that are created by the system.
    • kube-public: the Kubernetes namespace that is automatically created by the system. This Kubernetes namespace can be read by all the users, including the users who are not authenticated.

    In this example, default is selected.

  7. In the Create configuration item panel, specify the configuration items in the ConfigMap in the form of key-value pairs and click Yes.
    You can manually add key-value pairs or import key-value pairs from a file. Select a method as required. Multiple key-value pairs are supported in a single ConfigMap.
    • Manually add key-value pairs.

      Click Add and set the Key and Value parameters.

      Parameter Description
      Key The key of the configuration item. The key can contain letters, digits, underscores (_), hyphens (-), and periods (.).
      Value The value of the configuration item.
    • Import key-value pairs from a file.

      Click Import from file and select the required file. After you upload a file, EDAS automatically parses the data in the file to extract the key-value pairs contained in the file.

      Before EDAS parses a file, EDAS checks the format of the file. Only JSON, YAML, and .properties files are supported.

      Note You must add key-value pairs to your file based on the file format. The following examples show how to specify key-value pairs in files of different formats.
      • JSON format
        {
          "key1": "value1",
          "key2": "value2",
        }
      • YAML format
        key1: value1
        key2: value2
      • .properties file format
        key1=value1
        key2=value2

View a ConfigMap

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Configuration Management > Kubernetes Configurations.
  3. In the left-side pane of the Kubernetes Configurations page, click Configuration Items.
  4. On the Configuration Items page, select a region in the top navigation bar. Then, select a microservice namespace.
  5. On the Configuration Items page, find the ConfigMap that you want to view and click Details.
    You can search for the required ConfigMap by setting the ConfigName, Cluster, Cluster Id, and k8sNamespace parameters.
  6. On the details page of the ConfigMap, view the basic information about the ConfigMap and the key-value pairs in the ConfigMap.

Modify a ConfigMap

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Configuration Management > Kubernetes Configurations.
  3. In the left-side pane of the Kubernetes Configurations page, click Configuration Items.
  4. On the Configuration Items page, select a region in the top navigation bar. Then, select a microservice namespace.
  5. On the Configuration Items page, find the ConfigMap that you want to modify and click Edit.
    You can search for the required ConfigMap by setting the ConfigName, Cluster, Cluster Id, and k8sNamespace parameters.
  6. In the editing panel, modify the keys and values in the ConfigMap based on your requirements and click Yes.
    Note If the ConfigMap is used by an application, redeploy the application after you modify the ConfigMap. Otherwise, the updated configurations do not take effect in the application.

Delete a ConfigMap

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Configuration Management > Kubernetes Configurations.
  3. In the left-side pane of the Kubernetes Configurations page, click Configuration Items.
  4. On the Configuration Items page, select a region in the top navigation bar. Then, select a microservice namespace.
  5. On the Configuration Items page, find the ConfigMap that you want to delete and click Delete.
    You can search for the required ConfigMap by setting the ConfigName, Cluster, Cluster Id, and k8sNamespace parameters.
  6. In the message that appears, click Yes.
    Note We recommend that you do not delete a ConfigMap if it is used by an application. If you delete a ConfigMap that is used by an application, the application cannot properly run after you restart or redeploy the application.