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
- Access the cluster console. In the navigation pane, choose ConfigMaps and Secrets. Then, click the ConfigMaps tab. You can create a ConfigMap directly or using YAML. If you want to create a ConfigMap using YAML, go to 4.
- Select the namespace that the ConfigMap will belong to.
- Create a ConfigMap directly by clicking Create ConfigMap.
Configure the parameters as described in Table 1.
Table 1 Parameters for creating a ConfigMap Parameter
Description
Name
Name of the ConfigMap you create, which must be unique in a namespace.
Namespace
Namespace that the ConfigMap belongs to. The current namespace is used by default.
Description
Description of the ConfigMap.
ConfigMap Data
The workload configuration data can be used in a container or used to store the configuration data.
Click and enter the key and value. Key indicates the configuration name, and Value indicates the configuration content.
NOTE:ConfigMaps can be used to create workload storage volumes and configure workload environment variables. When configuring workload environment variables, ensure that the ConfigMap data is not empty.
Label
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.
- Enter the key and value.
- Click Confirm.
- Create a ConfigMap from a YAML file by clicking Create from YAML.
To create a resource by uploading a file, ensure that the resource description file has been created. UCS 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. - When the configuration is complete, click OK.
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
Related Operations
Operation |
Description |
---|---|
Viewing details |
Click the ConfigMap name to view its details. |
Editing a YAML file |
Click Edit YAML in the row where the target ConfigMap resides to edit its YAML file. |
Updating a ConfigMap |
|
Deleting a ConfigMap |
Click Delete in the row where the target ConfigMap resides, and click Yes. |
Deleting ConfigMaps in batches |
|
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