Search code examples
kubernetesargo-workflows

Argo Workflow args using echo to redirect to file without printing


I have the following Argo Workflow using a Secret from Kubernetes:

args:
      - |
        export TEST_FILENAME="./test.txt"
        echo "$TEST_DATA" > $TEST_FILENAME
        chmod 400 $TEST_FILENAME
      env:
      - name: TEST_DATA
        valueFrom:
          secretKeyRef:
            name: test_data
            key: testing

I need to redirect TEST_DATA to a file when I run the Argo Workflow, but the data of TEST_DATA always shows in the argo-ui log. How can I redirect the data to the file without showing the data in the log?


Solution

  • echo shouldn't be writing $TEST_DATA to logs the way your code is written. So I'm not sure what's going wrong.

    However, I think there's an easier way to write a secret to a file. Add a volume to your Workflow spec, and a volume mount to the container section of the step spec.

      containers:
      - name: some-pod
        image: some-image
        volumeMounts:
        - name: test-mount
          mountPath: "/some/path/"
          readOnly: true
      volumes:
      - name: test-volume
        secret:
          secretName: test_data
          items:
          - key: testing
            path: test.txt