Unlike most of the features, global environment variables are configured at the controller level rather than at the tf resource.
Global Environment Variable Configuration
To configure global envs, update the controller’s Deployment by adding any number of
env vars with the
The un-prefixed versions will be added to every task in every tf resource.
Example controller deployment
apiVersion: apps/v1 kind: Deployment metadata: name: "terraform-operator" # ... data omitted spec: # ... data omitted template: # ... data omitted spec: containers: - name: "terraform-operator" image: "isaaguilar/terraform-operator:v0.9.0-pre2" imagePullPolicy: IfNotPresent # ... data omitted env: - name: "TFO_VAR_CLUSTER_NAME" value: "minikube" - name: "TFO_SECRET_PGPASSWORD" valueFrom: secretKeyRef: name: "pgpassword" key: "postgres_secret"
How it works
The environment variables prefixed with
TFO_SECRET_ are stripped of the prefix and added
to a ConfigMap or Secret. Environment variables then get injected into all the tasks via
From the example above, tasks would get the environment variables: