Creating a ConfigMap
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 workload.
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.
Creating a ConfigMap
- Log in to the cluster console. In the left navigation pane, choose 3. . You can create a ConfigMap directly or using YAML. If you want to create a ConfigMap using YAML, go to
- Create a ConfigMap directly by clicking Create ConfigMap.
Set the parameters listed in Table 1. The parameters marked with asterisks (*) are mandatory.
Table 1 Parameters for creating a ConfigMap Parameter
Description
*Name
Name of a ConfigMap, which must be unique in a namespace.
*Cluster
Select the cluster for which you want to create a ConfigMap.
*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. Key specifies the file name, and Value specifies the file content.
- Click Add Data.
- 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.
- Click Add Label.
- Set Key and Value.
- Create a ConfigMap using a YAML file by clicking Create Using YAML.
To create a resource by uploading a file, ensure that the resource description file has been created. MCP supports files in JSON or YAML format. For details, see ConfigMap Resource File Configuration.
You can import or directly write the file content in YAML or JSON format. - Click Create after the configuration is complete.
The new ConfigMap is displayed in the ConfigMap list.
ConfigMap Resource File Configuration
A ConfigMap resource file can be in JSON or YAML format, and the file size cannot exceed 2 MB.
- JSON format
The file name is configmap.json and the configuration example is as follows:
{ "kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": "paas-broker-app-017", "namespace": "test" }, "data": { "context": "{\"applicationComponent\":{\"properties\":{\"custom_spec\":{}},\"node_name\":\"paas-broker-app\",\"stack_id\":\"0177eae1-89d3-cb8a-1f94-c0feb7e91d7b\"},\"softwareComponents\":[{\"properties\":{\"custom_spec\":{}},\"node_name\":\"paas-broker\",\"stack_id\":\"0177eae1-89d3-cb8a-1f94-c0feb7e91d7b\"}]}" } }
- YAML format
The file name is configmap.yaml and the configuration example is as follows:
apiVersion: v1 kind: ConfigMap metadata: name: test-configmap data: data-1: value-1 data-2: value-2
Related 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 |
|
Deleting a ConfigMap |
Click Delete in the row where the target ConfigMap resides. Delete the ConfigMap as prompted. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot