September 14, 2023

Go Templating syntax is used everywhere in Kubernetes world. The most popular use case and a place you can find it are… Helm Charts. But other products such as Argo Workflows use it as well and that can sometimes become a problem – how can you properly escape… escaping syntax? Let’s see on the example.

Here I have an excerpt from WorkflowTemplate I use for OpenFaaS on my Kubernetes clusters:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: openfaas
spec:
  arguments:
    parameters:
      - name: repoUrl
        value: "[email protected]:luktom-cloud/sample.git"

  # some parts removed for brevity [...]

  templates:
    - name: main
      dag:
        tasks:
          - name: faas-build
            inline:
              inputs:
                artifacts:
                  - name: sources
                    path: /data/src
                    git:
                      repo: "{{ workflow.parameters.repoUrl }}"
                      # [...]

This template (provided we put a full manifest for it, ofz) will work if you apply it to Kubernetes clusters, but if you move it to templates folder in Helm chart… that’s the different story:

~/t/test> helm template .
Error: parse error at (test/templates/pipeline-openfaas.yaml:44): function "workflow" not defined

Use --debug flag to render out invalid YAML

Helm thinks the escaping syntax using {{ is for templating, which is partially true as technically it’s a template, but… for Argo Workflows and we don’t want Helm to treat it as its own!

What we can do? Use template literal!

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: openfaas
spec:
  arguments:
    parameters:
      - name: repoUrl
        value: "[email protected]:luktom-cloud/sample.git"

  # some parts removed for brevity [...]

  templates:
    - name: main
      dag:
        tasks:
          - name: faas-build
            inline:
              inputs:
                artifacts:
                  - name: sources
                    path: /data/src
                    git:
                      repo: {{`"{{ workflow.parameters.repoUrl }}"`}}
                      # [...]

As you can see I surrounded my Argo Workflows template with {{` and `}} and it solves the issue!

If you have more Argo Workflow variables than Helm ones (or not have any of them), you can also surround whole file contents with {{` and `}} and it’ll do the job.

It’s not nice, I admit, but I think it’s better than dealing with post renderers in Helm, especially if you use GitOps approach with e.g. ArgoCD.

I hope that little trick save you a couple minutes of debugging!

Subscribe to my mailing list to get updated about new blog posts!

You may also find these posts interesting:

Escaping Argo Workflows templates in Helm

Go Templating syntax is used everywhere in Kubernetes world. The most popular

About the author - Łukasz Tomaszkiewicz

My name is Łukasz Tomaszkiewicz and I help developers and devops engineers to accelerate their career in public cloud.

For many years I've supported developer teams in delivering cloud based solutions - from design phase, through automation of deployment to monitoring and optimization as well as day-to-day operations.

In my professional life I'm mainly focused on AWS infrastructure, however - after hours - I like doing my own side projects as it helps me understanding the issues developers may have while using the cloud.

  • Interesting analysis! Seeing platforms like ph889 games prioritize RNG & quick onboarding (under 60s!) is key for building trust in the Philippines market. Transparency matters!

  • Interesting analysis! Seeing platforms like ph889 games prioritize RNG & quick onboarding (under 60s!) is key for building trust in the Philippines market. Transparency matters!

  • F68vip is the real deal! It’s where all the high rollers are playing. Join the VIP club and experience the difference. Check it out you won’t regret it!: f68vip

  • F68vip is the real deal! It’s where all the high rollers are playing. Join the VIP club and experience the difference. Check it out you won’t regret it!: f68vip

  • F68vip is the real deal! It’s where all the high rollers are playing. Join the VIP club and experience the difference. Check it out you won’t regret it!: f68vip

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    >