Skip to main content Link Search Menu Expand Document (external link)

Env

The env trait modifies the environment variables of a component being capable of adding variables, replacing or removing them. The operation can target a container within a component.

The following snippet shows an example application with a component with two containers and the env trait removing and setting environment variables on the sidecar. For more information, check the sidecar trait documentation.

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: my-app
  annotations: 
    version: "v0.0.1"
    description: "My application"
spec:
  components:
    - name: busybox
      type: worker
      properties:
        image: my-app-image:v1.0.0
        cmd: ["cmd"]
      traits:
        - type: sidecar
          properties:
            name: container-name
            image: my-container-image:v1.0.0
        - type: env
          properties:
            containerName: container-name # (Optional) Specify the name of the target container, if not set, use the component name
            env: # (Required) environment variables to merge
              key_1: value_1
              key_2: value_2
            unset: ["ENV_VAR1", ..., "ENV_VARN"] # (Optional) existing variable to 
            replace: true # (Optional) replace all environment variables