proposalbot 85e1a6ed92 Changes to cce_umn from docs/doc-exports#770 (Added the support of the OS for fe
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: proposalbot <proposalbot@otc-service.com>
Co-committed-by: proposalbot <proposalbot@otc-service.com>
2023-06-20 14:44:25 +00:00

7.3 KiB

original_name

cce_10_0152.html

Creating a ConfigMap

Scenario

A ConfigMap is a type of resource that stores configuration information required by a workload. Its content is user-defined. After creating ConfigMaps, you can use them as files or environment variables in a containerized workload.

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

Benefits of ConfigMaps:

  • Manage configurations of 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.

Notes and Constraints

  • The size of a ConfigMap resource file cannot exceed 2 MB.
  • ConfigMaps cannot be used in static pods.

Procedure

  1. Log in to the CCE console and access the cluster console.

  2. Choose ConfigMaps and Secrets in the navigation pane and click Create ConfigMap in the upper right corner.

  3. Set parameters.

    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.
    Description Description of the ConfigMap.
    Data

    Data of a ConfigMap, in the key-value pair format.

    Click image1 to add data. The value can be in string, JSON, or YAML format.

    Label Label of the ConfigMap. Enter a key-value pair and click Add.
  4. After the configuration is complete, click OK.

    The new ConfigMap is displayed in the ConfigMap list.

Creating a ConfigMap Using kubectl

  1. Configure the kubectl command to connect an ECS to the cluster. For details, see Connecting to a Cluster Using kubectl <cce_10_0107>.

  2. Create and edit the cce-configmap.yaml file.

    vi cce-configmap.yaml

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cce-configmap
    data:
      SPECIAL_LEVEL: Hello
      SPECIAL_TYPE: CCE
    Table 2 Key parameters
    Parameter Description
    apiVersion The value is fixed at v1.
    kind The value is fixed at ConfigMap.
    metadata.name ConfigMap name, which can be customized.
    data ConfigMap data. The value must be key-value pairs.
  3. Run the following commands to create a ConfigMap.

    kubectl create -f cce-configmap.yaml

    Run the following commands to view the created ConfigMap:

    kubectl get cm

    NAME               DATA            AGE
    cce-configmap      3               7m

After creating a configuration item, you can update or delete it as described in Table 3 <cce_10_0152__table1619535674020>.

Table 3 Related operations
Operation Description
Editing a YAML file Click Edit YAML in the row where the target ConfigMap resides to edit its YAML file.
Updating a ConfigMap
  1. Select the name of the ConfigMap to be updated and click Update.
  2. Modify the secret data. For more information, see Table 1 <cce_10_0152__table16321825732>.
  3. Click OK.
Deleting a ConfigMap

Select the configuration you want to delete and click Delete.

Follow the prompts to delete the ConfigMap.