Environment variables separate configuration from application code, letting you customize runtime behavior across environments without redeploying. They also keep sensitive data -- such as database credentials and API keys -- out of your source code.
Background information
EDAS supports three types of environment variables for applications deployed on Kubernetes clusters:
|
Type |
Description |
Use case |
|
Custom |
Key-value pairs you define directly |
Application-specific settings like |
|
ConfigMap |
References to Kubernetes ConfigMap entries |
Shared, non-sensitive configuration across multiple applications |
|
Secret |
References to Kubernetes Secret entries |
Passwords, certificates, API keys |
ConfigMaps and Secrets must be in the same region, cluster, and Kubernetes namespace as the application that references them.
To create a ConfigMap, see Create a configuration item. To create a Secret, see Create a Secret.
Prerequisites
Before you begin, make sure that you have:
-
An EDAS account with access to the EDAS console
-
A Kubernetes cluster created in EDAS
-
(Optional) A ConfigMap or Secret in the same region, cluster, and Kubernetes namespace as your application
Add environment variables
You can configure environment variables when you create an application or when you deploy an existing application. In both cases, the variables are passed to the container at startup.
Saving environment variable changes restarts the application. Configure environment variables during off-peak hours to minimize impact.
Add variables during application creation
-
Log on to the EDAS console.
-
In the top navigation bar, select a region. In the upper part of the page, select a namespace.
-
In the upper-left corner, click Create Application.
-
In the Basic Information step, set Cluster Type to Kubernetes Clusters and select your Application Runtime Environment (see Application runtime options), then click Next.
-
In the Configurations step, configure the environment information, basic information, deployment method, and resource parameters, then click Next.
-
In the Advanced Settings step, click Environment Variables and add variables using any of the methods described in Variable configuration methods.
-
Click Create Application.
-
On the Creation Completed page, review the settings in Basic Information, Configurations, and Advanced Settings, then click Create Application.
-
On the Application Overview page, click View Details. On the Change List page, monitor the deployment progress. After the change completes, verify that the pod status in the Basic Information section shows the pod is running.
Add variables during application deployment
If you did not configure environment variables during application creation, add them when you deploy or redeploy the application.
-
Log on to the EDAS console.
-
In the top navigation bar, select a region. In the upper part of the page, select a namespace.
-
From the Cluster Type drop-down list, select Container Service or Serverless Kubernetes Cluster.
-
Find the target application and click its name.
-
On the Overview or Basic information page, choose Deploy > Deploy in the upper-right corner.
-
On the Select Deployment Mode page, select a deployment mode and click Start Deployment.
-
Set the runtime environment and deployment package, then click Environment Variables to add variables using any of the methods described in Variable configuration methods.
-
Click OK.
Variable configuration methods
You can add variables individually or in bulk.
Add a single variable
Choose one of the following methods based on your variable type:
Custom variable
Enter a variable name and value directly.

To configure JVM heap memory, JVM properties, or Java agent parameters, set the following:
-
Variable Name: CATALINA_OPTS
-
Variable Value: [Parameter to be added] $(EDAS_CATALINA_OPTS)
Common environment variables for MySQL images:
|
Variable |
Required |
Description |
|
|
Yes |
Sets the MySQL root password |
|
|
No |
Creates an additional user account with a password |
|
|
No |
Specifies a database to create at container startup |
For other image types, configure environment variables based on the image documentation.
ConfigMap reference
Select a ConfigMap from the Variable Value/Variable Reference drop-down list, then select a key-value pair from the ConfigMap.
Secret reference
Select a Secret from the Variable Value/Variable Reference drop-down list, then select a key-value pair from the Secret.
Add multiple variables in bulk
To inject environment variables in bulk from a ConfigMap or Secret, configure the following parameters:
|
Parameter |
Description |
|
Type |
Select Configuration Items (ConfigMap) or Secret. Custom variables are not supported in bulk mode. |
|
Configuration Mode |
env: Select specific key-value pairs from the ConfigMap or Secret. envFrom: Inject all key-value pairs from the ConfigMap or Secret. |
|
Configuration Items |
Select a ConfigMap from the drop-down list. |
|
Reference Environment Variable |
Select key-value pairs to inject (available in env mode only). |
You can add a maximum of 100 environment variables at a time. After adding variables, set the variable names based on your requirements.
Verify the result
Confirm that environment variables are active using either method:
-
Change records: In the left-side navigation pane of the application details page, click Change Records. If the Change Status column shows Success, the configuration is in effect.
-
Pod status: On the Application Overview page, click Running Pods (Click View) next to Running Status. In the Pod section, check the Status column. A green dot indicates the application is running with the updated configuration.
Application runtime options
Select the runtime environment that matches your application type:
|
Runtime |
Description |
|
Java > Custom |
Deploy using a custom image in a Kubernetes cluster |
|
Java > Java |
Deploy a Dubbo or Spring Boot application using a JAR package. Configurable: Java Environment. |
|
Java > Tomcat |
Deploy a Dubbo or Spring application using a WAR package. Configurable: Java Environment, Container Version. |
|
Java > EDAS-Container (HSF) |
Deploy an HSF application using a WAR or FatJar package. Configurable: Java Environment, Pandora Version, Ali-Tomcat Version. |
|
PHP |
Deploy a PHP application that runs on Apache HTTP Server |
|
Node.js, C++, Go, and Other Languages |
Deploy using a custom image in a Kubernetes cluster |