Adding an Environment Variable of a Component
Environment variables of a component are set in the component running environment and provide great flexibility for applications. Environment variables set for a component are local environment variables and take effect only for this 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 environment variables of an application, see Managing Environment Variables of an Application.
Priority of environment variables of the component, application, and environment levels: component > application > environment.
For details about environment variables of an environment, see Managing Environment Variables of an Environment.
Adding an Environment Variable of a Component
- Choose Container Settings > Environment Variable.
- Set component environment variables by referring to the following table.
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.
Name must be unique in the same component. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
Import from 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.
- Set Name.
Name must be unique in the same component. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). 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.
- Set Name.
Name must be unique in the same component. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). 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. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- value1 and value2 are the component environment variable values.
Resource reference
- Click Add Environment Variable and select Resource reference.
- Set Name.
Name must be unique in the same component. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- Select the resource application value or limit value defined by the container from the Variable/Variable Reference drop-down list as the value of the environment variable.
Variable/Variable Reference
Use the field defined by the instance as the value of the environment variable.
- Click Add Environment Variable and select Variable/Variable Reference.
- Set Name.
Name must be unique in the same component. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- In the Variable/Variable Reference drop-down list, select the field defined by the instance as the value of the environment variable.
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