Rancher 2 Pipeline Env Var


#1

I’m trying to set some env var for a deployment with pipelines (Even better a config map) but at the moment, I can only set an env var for the steps.

Is possible to set env vars for a Workload in a the deployment yaml?


#2

Yea, just add them to the deployment.yaml like this

spec:
  containers:
  - name: spring-boot-demo
    image: myrepo:443/spring-boot-demo:${CICD_EXECUTION_SEQUENCE}
    env:
      - name: APP_NAME
        value: spring-boot-demo
      - name: BOOT_ADMIN_ENABLED
        value: "true"
      - name: BOOT_ADMIN_PREFER_IP
        value: "true"
      - name: CONTEXT_PATH
        value: /spring-boot-demo
      - name: BOOT_ADMIN_URL
        valueFrom:
          configMapKeyRef:
            key: bootAdminUrl
            name: common
            optional: false

And if you want to insert values through .rancher-pipeline.yml use ${MY_VAR} in the deployment.yaml and like this in the pipeline yaml

- name: Deploy yaml
  steps:
  - applyYamlConfig:
      path: ./deployment.yaml
    env:
      MY_VAR: 236578