argo-workflows icon indicating copy to clipboard operation
argo-workflows copied to clipboard

template substitution for `configMapKeyRef`

Open liuzqt opened this issue 3 years ago • 4 comments

Summary

want to support template substitution for configMap

something like:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: error-handling1-runner1-task
spec:
  templates:
    - name: runner1
      inputs:
        parameters:
          - name: config-map-name
          - name: img-from-config-map
            valueFrom:
              configMapKeyRef:
                name: "{{inputs.parameters.config-map-name}}"
                key: image
      container:
        image: "{{inputs.parameters.img-from-config-map}}"
        command: [sh, -c]
        args:
          [
            "echo this is runner1 {{inputs.parameters.config-map-name}} {{inputs.parameters.img-from-config-map}}",
          ]

I've tried the example above but it's not working, I suppose this feature is not supported yet. But if my usage is wrong pls let me know.

Use Cases

I might have several parallel configMap (or something like branching) and I would like to indicate the workflow which configMap to pick from


Message from the maintainers:

Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.

liuzqt avatar Mar 08 '22 19:03 liuzqt

This might not be possible unfortunately. The security model of the workflow controller means it typcially cannot read configmap in the user's namespace. We would not want to change this.

However, I think there is a similar issue for config maps in parameters. Did you check for that feature?

alexec avatar Mar 09 '22 16:03 alexec

@alexec sorry but what do you mean by config maps in parameters...basically I was trying to retrieve value from configMap as one of the input parameters, but also want to "template-ize" the configMap name from another input parameter

liuzqt avatar Mar 10 '22 02:03 liuzqt

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: arguments-parameters-from-configmap-
  labels:
    workflows.argoproj.io/test: "true"
  annotations:
    workflows.argoproj.io/description: |
      This example demonstrates loading parameter values from configmap.
      Note that the "simple-parameters" ConfigMap (defined in examples/configmaps/simple-parameters-configmap.yaml)
      needs to be created first before submitting this workflow.
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    inputs:
      parameters:
      # Parameters can also be passed via configmap reference.
      - name: message
        valueFrom:
          configMapKeyRef:
            name: simple-parameters
            key: msg
    container:
      image: argoproj/argosay:v2
      args: ["echo", "{{inputs.parameters.message}}"]

alexec avatar Mar 10 '22 06:03 alexec

@alexec that's what I'm using for now, and I want to do further template substitution like

      parameters:
      # Parameters can also be passed via configmap reference.
      - name: config-map-name
      - name: message
        valueFrom:
          configMapKeyRef:
            name: {{inputs.parameters.config-map-name}}
            key: msg

but I guess that's not easy to do......I'll try to find some other workaround

liuzqt avatar Mar 10 '22 22:03 liuzqt