'How can I use Argo Workflows templates in Helm?

Is it possible to use Helm to deploy Argo workflows? I get an error like below when I do a helm install

Error: UPGRADE FAILED: parse error at (workflows/templates/my_dag.yaml:47): function "workflow" not defined

The yaml itself has both Argo and Helm interpolations with {{..}}. I understand why it fails. Is there a way around this?

I've had a look at this but it does not look like something I want to do as it sort of changes the syntax.



Solution 1:[1]

It is possible. I've been on a team that regularly deployed Helm-templated WorkflowTemplates.

There are two ways to work around the Helm/Argo template tag collision. (As you know, the issue is that Helm's Go templating language and Argo's templating language both use {{}} to denote templated areas.)

Option 1:

The first way is to carefully nest the tags. For example, if I want to use {{steps.hello-world.result}} as an Argo-template, I can write it as {{`{{steps.hello-world.result}}`}}. The outer {{ tells Helm to start interpreting templated code. The backtick tells Helm to interpret the backtick-delimited contents literally. And finally, the inner {{ is installed in the cluster as a plain-text part of the Workflow and eventually interpreted by Argo as a template.

Here's a modified version of the arguments-parameters example modified to be deployed with Helm.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: arguments-parameters-
spec:
  entrypoint: whalesay
  arguments:
    parameters:
    - name: message
      value: hello world
  templates:
  - name: whalesay
    inputs:
      parameters:
      - name: message
    container:
      image: docker/whalesay:latest
      command: [cowsay]
      args: ["{{`{{inputs.parameters.message}}`}}"]

Option 2:

The second work-around is described in the blog post you linked. That approach does change the syntax. The first approach uses a funny-looking syntax, but it is still technically just Helm's and Argo's default syntax.

If the {{`{{yikes}}`}} work-around doesn't solve your error message, please post the whole workflow (or a redacted/simplified version), and I'd be happy to take a look.

Related:

The above is for Argo-in-Helm (Jinja2-in-Go) templating. If you need somethingelse-in-Argo (somethingelse-in-Jinja2) templating, where somethingelse also uses {{, check out this answer: How to escape "{{" and "}}" in argo workflow

Solution 2:[2]

It Option1 fail an other workaround can be

{{ "{{inputs.parameters.message}}"|quote}}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Thomas