environment-variablesargo-workflowsargo

argo workflow set array of integer as container env


How to set array of integer as container env in argo workflow:

apiVersion: argoproj.io/v1alpha1
kind: Workflow                  # new type of k8s spec
metadata:
  generateName: hello-world-    # name of the workflow spec
spec:
  entrypoint: whalesay          # invoke the whalesay template
  templates:
 —name: whalesay              # name of the template
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world"]
      env:
      - name: ARRAY_OF_INTEGER
      - value: '[1, 2, 3, 4]'
      resources:                # limit the resources
        limits:
          memory: 32Mi
          cpu: 100m

the ARRAY_OF_INTEGER is set as array of string, how to set the env as array of integer?


Solution

  • An environment variable is, by definition, a string. If you need to process the stringified array as an array, then you need to write code in your whalesay step to parse the string into an array.