Add all Environment Variables from an existing secret -

Hi,
We have a solution that uses K8s and has secrets shared across multiple containers (not ideal but there are valid reasons behind this), the secret is deployed separately and in the same namespace as the containers.

When setting up each container I am attempting to use the “Add all Environment Variables from a secret”, however this does not add any values. I am able to add them individually using the “Add individual environment variable from a secret” however as I’m trying to create a template this is not an idea workflow.

Is there a bug here or something I’m missing as all the examples I’ve found reference secrets deployed alongside the container rather than independently of it as is our case.

Hi @marc,

Thanks for reaching out! I’ll do what I can to assist you.

When you say you’re attempting to add all environment variables from a secret, how are the environment variables formatted within the secret?

We have a blog post that goes over this process if you haven’t seen it already: Exposing Octopus variables to a Kubernetes container - Octopus Deploy.

Any additional information you can provide would be helpful or if the above blog post helps you resolve the issue, please let me know!

Kind Regards,
Adam

I think this line is key to my issue from that article " To expose the secret as environment variables, we expand the Secret Environment Variables section of the container definition".

My secret is deployed independently so that explains why it’s not creating the env vars.

Is there a way to achieve this?

Hi @marc,

Just jumping in for Adam while he’s offline, I’d be happy to help with your Kube secrets!

We are currently looking for customers who use Kubernetes to interview so we can make sure we are working on the right features, I hope you don’t mind that I’ve passed your email along so someone from our product team should reach out to see if you’d be interested.

I noticed in the Kube docs about the envFrom feature that it’s only available for clusters 1.16+ (1.6 looks to be a typo):

From my understanding of a secret deployed independently, I’ve created a secret using one Octopus project, and then referenced it using the Add all Environment Variables from a secret in another Octopus project, which while it didn’t show any env variables in the Cloud console (AKS), I was able to reference the secret’s key as the name of the variable, screenshots below.

The hello-world Secret defined in first project:

That same Secret referenced in second project:

Then using kubectl exec the Secret value is shown:

If this isn’t the behaviour you are seeing I’d be happy to look into it further, could you please send through the deployment yaml to our secure Upload Portal that should have all the info we need:

Looking forward to getting to the bottom of this, feel free to reach out with any questions!