A ConfigMap is a Kubernetes resource used to store non-sensitive configuration data. Its content is defined by users. After a ConfigMap is created, containerized workloads can use it through volume mounts or environment variable injection.
ConfigMaps decouple configuration files from container images, improving workload portability and preventing unnecessary image rebuilds caused by configuration changes.
The core benefits of ConfigMaps include:
Parameter | Description |
|---|---|
Name | Name of the ConfigMap you create, 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 the ConfigMap. Click Add and enter key-value pairs.
|
Tag Management (Optional) | Labels of the ConfigMap. Click Add Label and enter key-value pairs. The key and value must contain 1 to 63 characters that start and end with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. |
The new ConfigMap is displayed in the ConfigMap list.
vi cce-configmap.yaml
File content:
apiVersion: v1kind: ConfigMapmetadata:name: cce-configmapdata:SPECIAL_LEVEL: HelloSPECIAL_TYPE: CCE
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. |
kubectl create -f cce-configmap.yaml
Run the following commands to view the created ConfigMap:
kubectl get cm
Command output:
NAME DATA AGEcce-configmap 3 7m
After creating a ConfigMap, you can update or delete it as described in Table 3.
Operation | Description |
|---|---|
Editing a ConfigMap's YAML file | Click Edit YAML in the row where the target ConfigMap resides to edit its YAML file. |
Updating a ConfigMap |
|
Deleting a ConfigMap | Select the target ConfigMap and choose . Delete the ConfigMap as instructed. |
Rolling back a ConfigMap | Select the target ConfigMap and choose to roll back it to the specified historical version as instructed. This function is available only when the ConfigMap has a historical version. |