我正在为我的公司做一个小型的概念验证项目,并希望使用 Argo Workflows 来自动化一些数据工程任务。设置起来真的很容易,我已经能够创建许多工作流来处理存储在 Docker 映像中或从 REST API 检索的数据。但是,为了处理我们的敏感数据,我想将 hostPath 持久卷挂载到我的工作流任务之一。当我按照文档操作时,我没有得到所需的行为,目录显示为空。
操作系统:Ubuntu 18.04.4 LTS
Kubernetes 执行器:Minikube v1.20.0
Kubernetes 版本:v1.20.2
Argo Workflows 版本:v3.1.0-rc4
我的持久卷(声明)如下所示:
apiVersion: v1
kind: PersistentVolume
metadata:
name: argo-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/tmp/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: argo-hello
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
我跑
kubectl -n argo apply -f pv.yaml
我的工作流程如下所示:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-world-volumes-
spec:
entrypoint: dag-template
arguments:
parameters:
- name: file
value: /mnt/vol/test.txt
volumes:
- name: datadir
persistentVolumeClaim:
claimName: argo-hello
templates:
- name: dag-template
inputs:
parameters:
- name: file
dag:
tasks:
- name: readFile
arguments:
parameters: [{name: path, value: "{{inputs.parameters.file}}"}]
template: read-file-template
- name: print-message
template: helloargo
arguments:
parameters: [{name: msg, value: "{{tasks.readFile.outputs.result}}"}]
dependencies: [readFile]
- name: helloargo
inputs:
parameters:
- name: msg
container:
image: lambertsbennett/helloargo
args: ["-msg", "{{inputs.parameters.msg}}"]
- name: read-file-template
inputs:
parameters:
- name: path
container:
image: alpine:latest
command: [sh, -c]
args: ["find /mnt/vol; ls -a /mnt/vol"]
volumeMounts:
- name: datadir
mountPath: /mnt/vol
当这个工作流执行时,它只会打印一个空目录,即使我用文件填充了主机目录。有什么我从根本上想念的吗?谢谢你的帮助。