由于有2 个步骤outer-template
,因此调用inner-template
了两次。内部模板是一个简单的容器,可以将一些文本写入/command_output/result.txt
. 工作流输出尝试通过以下方式读取它:
- name: previous_step_output
valueFrom:
path: /command_output/result.txt
由于某种原因,这似乎确实有效。根据我还创建的文档volumes
,volumeMounts
错误是:
Service Account Name: argo
Templates:
Arguments:
Inputs:
Metadata:
Name: HelloWorld
Outputs:
Steps:
[map[arguments:map[parameters:[map[name:message value:Hello World.....]]] name:init-step templateRef:map[name:outer-template template:HelloWorld]]]
Status:
Conditions:
Status: True
Type: Completed
Finished At: 2021-06-17T23:50:37Z
Message: runtime error: invalid memory address or nil pointer dereference
Nodes:
hello-css4z:
需要一些关于缺少什么的建议。附加内部模板、外部模板和 request.yaml。
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: inner-template
namespace: cali
labels:
workflows.argoproj.io/controller-instanceid: cali
spec:
templates:
- name: InnerJob
metadata:
annotations:
sidecar.istio.io/inject: "false"
inputs:
parameters:
- name: message
- name: previous_step_output
value: ""
resource:
action: create
successCondition: status.succeeded > 0
failureCondition: status.failed > 0
manifest: |
apiVersion: batch/v1
kind: Job
metadata:
namespace: default
generateName: hellojob-
annotations:
sidecar.istio.io/inject: "false"
spec:
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
spec:
volumes:
- emptyDir: {}
name: cali-mount
containers:
- name: export-tenant
image: centos:7
command: [sh, -c]
args: ["echo 'some result' > /command_output/result.txt; cat /command_output/result.txt; sleep 5; echo done; exit 0"]
env:
- name: message
value: "{{inputs.parameters.message}}"
- name: previous_step_output
value: "{{inputs.parameters.previous_step_output}}"
volumeMounts:
- mountPath: /command_output
name: cali-mount
restartPolicy: Never
outputs:
parameters:
- name: job-name
valueFrom:
jsonPath: '{.metadata.name}'
- name: job-obj
valueFrom:
jqFilter: '.'
- name: previous_step_output
valueFrom:
path: /command_output/result.txt
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: outer-template
namespace: cali
labels:
workflows.argoproj.io/controller-instanceid: cali
spec:
entrypoint: HelloWorld
templates:
- name: HelloWorld
inputs:
parameters:
- name: message
steps:
- - name: step-1
templateRef:
name: inner-template
template: InnerJob
arguments:
parameters:
- name: message
value: "{{inputs.parameters.message}}"
- - name: step-2
templateRef:
name: inner-template
template: InnerJob
arguments:
parameters:
- name: message
value: "{{inputs.parameters.message}}"
- name: previous_step_output
value: "{{steps.step-1.outputs.parameters.previous_step_output}}"
请求有效载荷:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-
namespace: cali
labels:
workflows.argoproj.io/controller-instanceid: cali
spec:
entrypoint: HelloWorld
serviceAccountName: argo
templates:
- name: HelloWorld
steps:
- - name: init-step
arguments:
parameters:
- name: message
value: "Hello World....."
templateRef:
name: outer-template
template: HelloWorld