Environment Variables

Defining container environment variables and setting values dynamically

This content is associated with a legacy version of the Replicated product. For the current Replicated product documentation, see docs.replicated.com.

Container Environment Variables

The 12-factor app encourages the use of environment variables for configuration, and Replicated supports this design pattern. You can specify environment variables, which will be injected into a container when it’s created.

Environment variables can be created with static values or customer supplied values.

Environment variables support the Replicated template library.

There is also a flag provided to exclude anything secret from the support bundle.

  env_vars:
    - name: EXTERNAL_SERVICE_USERNAME
      value: myapp
    - name: JWT_SIGNING_KEY
      value: '{{repl ConfigOption "jwt_signing_key" }}'
      is_excluded_from_support: true

    - name: POSTGRES_URI
      value: 'postgres://{{repl ConfigOption "postgres_user"}}:{{repl ConfigOption "postgres_pass"}}@{{repl ConfigOption "postgres_host"}}:5432'
      is_excluded_from_support: true
      when: '{{repl ConfigOptionEquals "bring_own_postgres" "1"}}'
    - name: POSTGRES_URI
      value: 'postgres://myappuser:{{repl ConfigOption "generated_password"}}@{{repl NodePrivateIPAddress "DB" "postgres"}}:5432'
      is_excluded_from_support: true
      when: '{{repl ConfigOptionEquals "bring_own_postgres" "0"}}

when

The when attribute will cause an environment variable not to be injected when the template evaluates to false. In the above example, only one POSTGRES_URI variable will be set in the container, depending on the value of the bring_own_postgres config option.

is_excluded_from_support

Having environment variables in Support Bundles can be useful when troubleshooting. However, environment variables can contain sensitive data. Setting is_excluded_from_support to true will exclude them from Support Bundles. We recommend excluding any sensitive data from support bundles.