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 details page. 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 to which the ConfigMap will belong.
- Create a ConfigMap directly by clicking Create ConfigMap.
Set the parameters listed in Table 1.
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. The current namespace 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.
Click and enter the key and value. Key indicates the configuration name, and Value indicates the configuration content.
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.
- Enter the label key and value.
- Click Add.
- 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