Use ConfigMap created as part of step when adding config map environment variables in k8s deploy containers step

(zackery parkhurst) #1


We are in need of the deploy container feature to allow us to choose to use the configmap created as part of this step when adding configmap environment variables during the k8s deploy container step. Currently, the configmap created as part of this step has version appended to the configmap name. Which makes it impossible to map environment variables from it. We need the ability to pick individually which keys from the configmap to add as environment variables and be able to just add all of them as environment variables very similar to the way envfrom works Example:

apiVersion: v1
kind: Pod
  name: dapi-test-pod
    - name: test-container
      command: [ "/bin/sh", "-c", "env" ]
      - configMapRef:
          name: special-config
  restartPolicy: Never

We need this because it is very important that we use the deployContainer step to deploy the CM needed by the application because this step auto-versions them. Without this ability we would have to create the CM in a separate step. Which then if a deployment fails on the pod step but the configmaps have been updated then it can affect the older, running pods. So you can’t guarantee that the old ones will keep running if they need to be restarted since the configmap could have changed.

**UPDATE If we could also get the same abilities for Secret Environment Variables too. Same problem exist where there is no option to choose “Secret created as part of this step”

(Rob Pearson) #3

Hi @zackeryddparkhurst,

Thanks for getting in touch and great question. I’m happy to report that there is a solution for this which was unfortunately undocumented. In this scenario, you can use the following variables to obtain the correct computed config map/secret values.


These variables go in the ‘Name’ field for each appropriate section.

Hope this helps!



(zackery parkhurst) #4

Hello @robpearson,

Thank you for your quick response. That is awesome I will try that out.

Is there a way to have all of the values in CM and/or Secret mapped to environment variables without having to specify every one? Very similar to the way envFrom works in code snippet above?

(Rob Pearson) #5

Hi @zackeryddparkhurst,

Thanks for the reply. Unfortunately, Octopus doesn’t currently support that behaviour but our team agrees it would be helpful and we’ll consider adding it.