argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
15.08k stars 3.2k forks source link

Support templating in environment variables #6664

Open nicorikken opened 3 years ago

nicorikken commented 3 years ago

Summary

Support {{ input.parameters.json-env }} type templating in the env section of the container spec.

Use Cases

I'm trying to reduce passing parameters between all the steps. A way to pass a structure in the env section would help me with this.

I use Workflow Templates to trigger data science like jobs. Of the current 22 arguments from the UI most end up in environment variables. Some interpolation of parameters happens in an earlier step, so the arguments get passed to the initial main step and then to the actual step doing the work (compute). The arguments/parameters are now defined in 5!! different places:

We have 2 templates for different use-cases, which are about 80% similar. So when we make modifications to the expected application input (about once a month), we have to adjust this on 5 places in 2 templates, which is a cause for a lot of errors and frustration. Ideally I would like to directly load the environment from the spec.arguments.parameters from the UI, but I can understand that that will be difficult, if only because the main step would need to have inputs defined.

I was thinking of using the Sprig function to pass a stuctured object from main to compute and destructure it into environment variables, but any templating like env: [ "{{inputs.parameters.json-env}}" ] causes Argo Workflow parsing errors. I tested it with Argo Workflows version 3.0.7.

Another idea for my use-case would be to create a dedicated configmap, mount it, and clean it up afterwards.


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

alexec commented 2 years ago

I don't think this is fixable. Sorry.