ConfigMaps let you store non-sensitive, unencrypted configuration data separately from your application code in Container Service for Kubernetes (ACK). For example, if your app reads a DATABASE_HOST environment variable, you can set it to localhost for local development and to a Kubernetes Service name in your cluster—without rebuilding the container image each time.
Prerequisites
Before you begin, ensure that you have:
An ACK managed cluster or ACK Serverless cluster. See Create an ACK managed cluster or Create an ACK Serverless cluster.
Create a ConfigMap
Log on to the ACK console. In the left-side navigation pane, click ACK consoleClusters.
On the Clusters page, click the name of the cluster you want to manage, then choose Configurations > ConfigMaps in the left-side navigation pane.
On the ConfigMap page, select the namespace where you want to create the ConfigMap.
Create the ConfigMap using one of the following methods:
Method 1: Click Create
In the upper-right corner, click Create.
In the Create panel, enter a name for the ConfigMap.
The name can contain lowercase letters, digits, hyphens (-), and periods (.). This field is required. Other resources reference this name to retrieve the configuration data.
Click + Add, enter a key and a value, then click OK.
To add multiple entries, repeat this step. Alternatively, click Import to import a JSON file to create the ConfigMap.
Method 2: Click Create from YAML
In the upper-right corner, click Create from YAML.
In the Sample Template drop-down list, select one of the following options:
Option
Description
Custom
Write the ConfigMap definition in YAML syntax.
Resource - ConfigMap
Start from a pre-filled template named
aliyun-configthat includes two example variable files:game.propertiesandui.properties. Modify the template to fit your needs.Click Create.
After the ConfigMap is created, it appears on the ConfigMap page.
View, edit, and delete ConfigMaps
Updating a ConfigMap affects all applications that reference it.
On the ConfigMap page, you can perform the following operations:
| Operation | Steps |
|---|---|
| View details | Click the name of the ConfigMap. |
| Edit key-value pairs | In the Actions column, click Edit. Update the Name or Value fields, then save. |
| Edit YAML | In the Actions column, click Edit YAML. In the View in YAML panel, update the definition and click OK. |
| Delete | In the Actions column, click Delete. |
What's next
For more information about how to use ConfigMaps in pods, see Configure a pod to use a ConfigMap.