Argo Workflow允许用户在步骤之间共享计算机(Pod)。这种方法可以在不同步骤之间有效地共享资源,节省了资源以及时间和成本。下面是一个示例。
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: share-pod-
spec:
entrypoint: share-pod
templates:
- name: share-pod
steps:
- - name: step1
template: share-pod-template
- - name: step2
dependencies: [step1]
template: share-pod-template
containers:
- name: shared-container
image: alpine
command: [/bin/sleep, "10000"]
share:
pod: true
- name: share-pod-template
container:
image: alpine
command: ["/bin/sh"]
args: ["-c", "echo 'hello world' && sleep 5"]
在这个示例中,我们使用share
字段来定义共享模式。我们将pod
字段设置为true
,以便在两个步骤之间共享容器。在containers
字段中,我们定义了共享容器所使用的镜像及命令。在share-pod-template
模板中,我们定义了步骤具体的命令。
当工作流运行时,我们将在步骤之间共享容器。当第一个步骤运行时,容器将启动并运行定义的命令。当第二个步骤运行时,我们可以看到共享容器正在运行,再次执行定义的命令。
这是一个简单的示例,但它展示了如何使用Argo Workflow在步骤之间共享计算机。