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 containerized workloads.
Benefits of ConfigMaps:
Cluster and node resources have been created. For more information, see Creating a CCE Cluster. If you have available clusters and node resources, skip this operation.
Parameter |
Description |
---|---|
Name |
Name of a ConfigMap, which must be unique in a namespace. |
Cluster |
Cluster that will use the ConfigMap you create. |
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 |
The workload configuration data can be used in a container or used to store the configuration data. Key indicates a file name. Value indicates the content in the file.
|
Labels |
Labels are attached to objects such as workloads, nodes, and Services in key-value pairs. Labels define the identifiable attributes of these objects and are used to manage and select the objects.
|
To create ConfigMaps by uploading a file, ensure that the resource description file has been created. CCE supports files in YAML format. For more information, see ConfigMap Requirements.
The new ConfigMap is displayed in the ConfigMap list.
A ConfigMap resource file must be in YAML format, and the file size cannot exceed 2 MB.
apiVersion: v1 kind: ConfigMap metadata: name: test-configmap data: data-1: value-1 data-2: value-2
vi cce-configmap.yaml
apiVersion: v1 kind: ConfigMap metadata: name: cce-configmap data: SPECIAL_LEVEL: Hello SPECIAL_TYPE: CCE
kubectl create -f cce-configmap.yaml
kubectl get cm
NAME DATA AGE cce-configmap 3 3h cce-configmap1 3 7m
Operation |
Description |
---|---|
Viewing a YAML file |
Click View YAML next to the ConfigMap name to view the YAML file corresponding to the current ConfigMap. |
Updating a ConfigMap |
|
Deleting a ConfigMap |
Select the configuration you want to delete and click Delete. Follow the prompts to delete the ConfigMap. |