Updated on 2024-01-22 GMT+08:00

Setting Component Environment Variables

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.

This topic describes how to configure component environment variables in different deployment modes during component deployment. For details about the component deployment mode, see Deploying a Component.

Deploying a Component Using CCE

During component deployment, add environment variables on the Advanced Settings page by referring to the following steps.

  1. Choose Advanced Settings > Component Configuration.
  2. Add environment variables by referring to Table 1.

    Currently, environment variables can be added using any of the following methods:
    Table 1 Environment variable types

    Environment Variable Type

    Procedure

    Add manually

    1. Click Add Environment Variable and select Add manually.
    2. Set Name and Variable/Variable Reference to add an environment variable.

    Import from secret

    1. Create a secret. For details, see Creating a Secret.
    2. Click Add Environment Variable and select Add from secret.
    3. Set Name.
    4. Select a secret from the Variable/Variable Reference drop-down list.

    Import from configuration items

    1. Create a configuration item. For details, see Creating a Configuration Item.
    2. Click Add Environment Variable and select Add from ConfigMap.
    3. Set Name.
    4. Select a configuration item from the Variable/Variable Reference drop-down list.

    Import from a file

    Click Import and select a local configuration file.

    The imported file must be a key-value pair mapping file in JSON or YAML format. For example:

    {"key1":"value1","key2":"value2"}