ConfigMaps decouple environment configurations from container images. This helps you efficiently modify application configurations. This topic describes how to create a ConfigMap in an SAE namespace to inject configurations into containers.
Prerequisites
A ConfigMap is created in a namespace. For more information, see Manage a Kubernetes ConfigMap.Procedure
Inject configurations when you create an application
You can use the ConfigMap that you created on the ConfigMaps page of a namespace to inject configurations into containers.
Log on to the SAE console.
In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click Create Application.
In the Basic Information step, configure the parameters and click Next: Application Deployment Configurations.
In the Deployment Configurations step, configure the Technology Stack Programming Language and Application Deployment Method parameters and the corresponding settings.
- In the Configuration Management section, select the ConfigMap from the ConfigMap Name drop-down list and a key from the Key drop-down list. Then, specify the path on which the ConfigMap is mounted in the Mount Path field. Note
- You can create a ConfigMap in the Namespaces module. You can also click Create ConfigMap (K8s configmap) in the Environment Variable Settings section to create a ConfigMap. Then, configure the parameters in the Create ConfigMap panel.
- You can mount all keys of a ConfigMap. To mount all keys of the ConfigMap on the specified path, select All from the Key drop-down list.
- Optional: To reference other ConfigMaps, click Add and repeat the previous step.
Click Next: Confirm Specifications.
In the Specification Confirmation step, view the details of the application and the fee for the selected specifications. Then, click Confirm.
The Creation Completed step appears. You can click Application Details to go to the Basic Information page of the application.
Check whether the configurations have taken effect.
Method 1:
In the left-side navigation pane of the Basic Information page, click Change Records. On the Change Records page, view the change details. If Executed is displayed in the Change Status column, the application is deployed and the configurations have taken effect.
Method 2:
On the Basic Information page, click the Instance Deployment Information tab to view the Status of the instances. If Running is displayed in the Status column, the application is deployed and the configurations have taken effect.
Inject configurations when you deploy an application
After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.
The procedure that can be performed to update an application varies based on the number of instances in the application. This section provides an example on how to configure the required features for an application in which the number of instances is greater than or equal to 1. For information about how to update an application in which the number of instances is 0, see Update an application.
Log on to the SAE console.
In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
In the upper-right corner of the Basic Information page, click Deploy Application.
- In the Configuration Management section, select the ConfigMap from the ConfigMap Name drop-down list and a key from the Key drop-down list. Then, specify the path on which the ConfigMap is mounted in the Mount Path field. Note
- You can create a ConfigMap in the Namespaces module. You can also click Create ConfigMap (K8s configmap) in the Environment Variable Settings section to create a ConfigMap. Then, configure the parameters in the Create ConfigMap panel.
- You can mount all keys of a ConfigMap. To mount all keys of the ConfigMap on the specified path, select All from the Key drop-down list.
- After you configure the settings, click Confirm.
Check whether the configurations have taken effect.
Method 1:
In the left-side navigation pane of the Basic Information page, click Change Records. On the Change Records page, view the change details. If Executed is displayed in the Change Status column, the application is deployed and the configurations have taken effect.
Method 2:
On the Basic Information page, click the Instance Deployment Information tab to view the Status of the instances. If Running is displayed in the Status column, the application is deployed and the configurations have taken effect.