Updated on 2024-09-27 GMT+08:00

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

  1. Choose Container Settings > Environment Variable.
  2. Set component environment variables by referring to the following table.

    Environment Variable Type

    Procedure

    Add manually

    Enter the environment variable name and parameter value.

    1. Click Add Environment Variable and select Add manually.
    2. 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.

    1. Create a secret. For details, see Creating a Secret.
    2. Click Add Environment Variable and select Add from secret.
    3. 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 (.).

    4. 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.

    1. Create a configuration item. For details, see Creating a Configuration Item.
    2. Click Add Environment Variable and select Add from ConfigMap.
    3. 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 (.).

    4. 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.