Configuring Environment Variables of a Component
Component Environment Variable Overview
Environment variables are set in the container running environment and can be modified after component deployment, ensuring the flexibility of applications.
Environment variables set for an application component are local environment variables and take effect only for this application component.
If you add an application environment variable to the application where the component is located and the name of the application environment variable is the same as that of the component environment variable in the application, the application environment variable is shielded by the component environment variable and does not take effect for the component. For details about how to add application environment variables, see Managing Application Environment Variables.
Configuring Environment Variables of a Component
- Choose Container Settings > Environment Variable.
- Set component environment variables by referring to the following table.
Environment Variable Type
Procedure
Add manually
Enter the environment variable name and parameter value.
- Click Add Environment Variable and select Add manually.
- Set Name and Variable/Variable Reference to add an environment variable.
The environment variable must be unique in a component. Enter 1 to 64 characters. Do not start with a digit. Only use letters, digits, underscores (_), hyphens (-), and periods (.).
Import from a secret
Import the value of a key in a secret as the environment variable value.
- Create a secret. For details, see Creating a Secret.
- Click Add Environment Variable and select Add from secret.
- Enter Name.
The environment variable must be unique in a component. Enter 1 to 64 characters. Do not start with a digit. Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- Select a secret key from the Variable/Variable Reference drop-down list.
After the import, there will be a component environment variable named after the variable name entered in 3. The value is the value of the selected key.
Import from configuration items
Import the value of a key in a configuration item as the environment variable value.
- Create a configuration item. For details, see Creating a Configuration Item.
- Click Add Environment Variable and select Add from ConfigMap.
- Enter Name.
The environment variable must be unique in a component. Enter 1 to 64 characters. Do not start with a digit. Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- Select a configuration item key from the Variable/Variable Reference drop-down list.
After the import, there will be a component environment variable named after the variable name entered in 3. The value is the value of the selected key.
Import from a file
Click Import and select a local configuration file.
The file must be a key-value pair mapping file in JSON or YAML format. A maximum of 200 environment variables can be imported at a time. Example:
{"key1": "value1", "key2": "value2"}
- key1 and key2 are the component environment variable names. The variable names must be unique in a component. Enter 1 to 64 characters. Do not start with a digit. Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- value1 and value2 are the application environment variable values.
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