HiveBrain v1.2.0
Get Started
← Back to all entries
patternkubernetesMinor

Use a Kustomize image transformation on an Argo CronWorkflow

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
kustomizeimageargocronworkflowtransformationuse

Problem

I am developing an ETL pipeline using Argo Workflows, and in order to handle environment related configurations, I am using Kustomize.

Here is the base/cronworkflow.yaml file

apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: cronworkflow
spec:
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 3
  successfulJobsHistoryLimit: 3
  startingDeadlineSeconds: 300
  workflowSpec:
    entrypoint: start
    templates:
    - name: start
      container:
        name: my-start-task
        image: app-image
        command:
          - /bin/sh
          - -xec
          - |
            ./entrypoint.sh
        env:
          - name: AWS_ACCESS_KEY_ID
            valueFrom:
              secretKeyRef:
                name: aws-creds
                key: access-key


Kustomize doesn't seem to work well when using patchesStrategicMerge, because it can only deal (out of the box at least) only with standard k8s kinds. With 3rd party kinds, it will simply overwrite the entire tree structure instead of trying to merge.

I had to use patchesJson6902 on the yaml file defining my Argo CronWorkflow, but now the images transformer doesn't seem to work anymore.

Am I missing something? Is there a convenient way to fix the behavior of patchesStrategicMerge? Are argo workflows "type definitions" for Kustomize available somewhere?

Solution

Kustomize offers a way to "hint" where to find image tags.

Add a file called kustomconfig.yaml:
images:
  • path: spec/templates[]/container/image


kind: WorkflowTemplate
  • path: spec/templates[]/script/image


kind: WorkflowTemplate


Add the following to your kustomization.yaml:
configurations:
  • kustomconfig.yaml




You're done. The images transformer will pick up those fields.

Context

StackExchange DevOps Q#14091, answer score: 8

Revisions (0)

No revisions yet.