Bài này chúng ta sẽ mount secret thành volume trong workflow và apply cho container.
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: name: wf-secret-volume spec: entrypoint: dag-template ###define volume in workflow volumes: - name: test-secret-vol secret: secretName: test-secret arguments: parameters: - name: message1 value: Task 1 is executed - name: message2 value: Task 2 is executed templates: - name: dag-template inputs: parameters: - name: message1 - name: message2 dag: tasks: - name: Task1 arguments: parameters: [{name: text, value: "{{inputs.parameters.message1}}"}] template: task-template - name: Task2 arguments: parameters: [{name: text, value: "{{inputs.parameters.message2}}"}] template: task-template - name: Task3 template: task-secret-volume dependencies: [Task1] - name: task-template inputs: parameters: - name: text script: image: python:3.8-slim command: source: | p = "{{inputs.parameters.text}}" print(p) - name: task-secret-volume container: image: python:3.8-slim command: args: ['with open("/secrets/test-password", "r") as f: lines = f.read(); print(lines)'] volumeMounts: - name: test-secret-vol mountPath: "/secrets"
Đầu tiên thì bạn define volume:
Tiếp theo là mount volume vào container: