Variables and Artifacts
- Variables use
{{ }}, see workflow-fundamentals.md for the full list - Parameters = small scalar values (strings), artifacts = files/dirs
Variables
workflow.*-name,namespace,uid,status,creationTimestamp,priority,parameters.<n>steps.<step>.*/tasks.<task>.*-outputs.result,outputs.parameters.<n>,outputs.artifacts.<n>,status,exitCodepod.name- pod running the template- anything else about the pod (IP etc) comes from the downward API:
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
Parameters
Workflow parameters
- Defined in
spec.arguments.parameters, overridable at submit
argo submit workflow.yaml -p environment=production -p version=2.0.0
- Used as
{{workflow.parameters.environment}}
Template inputs
value/defaultgives a default, no default = required
inputs:
parameters:
- name: greeting
value: 'Hello'
- name: name
Template outputs
- From a file
outputs:
parameters:
- name: id
valueFrom:
path: /tmp/id.txt
- stdout of
script/containerisoutputs.result(nooutputs.parametersentry needed) jsonPathextracts from a JSON file
outputs:
parameters:
- name: count
valueFrom:
path: /tmp/result.json
jsonPath: '{.count}'
valueFrom.defaultis used if the file is missing
Artifacts
-
Files/dirs passed between steps, stored in the artifact repository
-
Pass with
from:
Prune
arguments:
artifacts:
- name: input-file
from: '{{steps.create-file.outputs.artifacts.output-file}}'
- Inputs can come from a previous step,
git,http,s3,gcs, etc.
apiVersion: v1
kind: Secret
metadata:
name: minio-credentials
namespace: argo
stringData:
accesskey: minio
secretkey: minio123
---
apiVersion: v1
kind: Service
metadata:
name: minio
namespace: argo
spec:
ports:
- port: 9000
selector:
app: minio
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minio
namespace: argo
spec:
selector:
matchLabels:
app: minio
template:
metadata:
labels:
app: minio
spec:
containers:
- name: minio
image: minio/minio:RELEASE.2024-01-13T07-53-03Z
args: [server, /data]
env:
- name: MINIO_ROOT_USER
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: accesskey } }
- name: MINIO_ROOT_PASSWORD
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: secretkey } }
ports:
- containerPort: 9000
volumeMounts:
- { name: data, mountPath: /data }
volumes:
- name: data
emptyDir: {}
apiVersion: v1
kind: Secret
metadata:
name: minio-credentials
namespace: argo
stringData:
accesskey: minio
secretkey: minio123
---
apiVersion: v1
kind: Service
metadata:
name: minio
namespace: argo
spec:
ports:
- port: 9000
selector:
app: minio
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minio
namespace: argo
spec:
selector:
matchLabels:
app: minio
template:
metadata:
labels:
app: minio
spec:
containers:
- name: minio
image: minio/minio:RELEASE.2024-01-13T07-53-03Z
args: [server, /data]
env:
- name: MINIO_ROOT_USER
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: accesskey } }
- name: MINIO_ROOT_PASSWORD
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: secretkey } }
ports:
- containerPort: 9000
volumeMounts:
- { name: data, mountPath: /data }
volumes:
- name: data
emptyDir: {}
inputs:
apiVersion: v1
kind: Secret
metadata:
name: minio-credentials
namespace: argo
stringData:
accesskey: minio
secretkey: minio123
---
apiVersion: v1
kind: Service
metadata:
name: minio
namespace: argo
spec:
ports:
- port: 9000
selector:
app: minio
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minio
namespace: argo
spec:
selector:
matchLabels:
app: minio
template:
metadata:
labels:
app: minio
spec:
apiVersion: v1
kind: Secret
metadata:
name: minio-credentials
namespace: argo
stringData:
accesskey: minio
secretkey: minio123
---
apiVersion: v1
kind: Service
metadata:
name: minio
namespace: argo
spec:
ports:
- port: 9000
selector:
app: minio
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minio
namespace: argo
spec:
selector:
matchLabels:
app: minio
template:
metadata:
labels:
app: minio
spec:
containers:
- name: minio
image: minio/minio:RELEASE.2024-01-13T07-53-03Z
args: [server, /data]
env:
- name: MINIO_ROOT_USER
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: accesskey } }
- name: MINIO_ROOT_PASSWORD
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: secretkey } }
ports:
- containerPort: 9000
volumeMounts:
- { name: data, mountPath: /data }
volumes:
- name: data
emptyDir: {}
containers:
- name: minio
image: minio/minio:RELEASE.2024-01-13T07-53-03Z
args: [server, /data]
env:
- name: MINIO_ROOT_USER
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: accesskey } }
- name: MINIO_ROOT_PASSWORD
valueFrom:
{ secretKeyRef: { name: minio-credentials, key: secretkey } }
ports:
- containerPort: 9000
volumeMounts:
- { name: data, mountPath: /data }
volumes:
- name: data
emptyDir: {}
artifacts:
- name: source-code
path: /src
git:
repo: https://github.com/example/repository.git
revision: main
depth: 1
- name: data-file
path: /data/file.json
http:
url: https://example.com/data.json
- name: dataset
path: /data/dataset.csv
s3:
endpoint: s3.amazonaws.com
bucket: my-bucket
key: datasets/data.csv
accessKeySecret: { name: aws-credentials, key: accessKey }
secretKeySecret: { name: aws-credentials, key: secretKey }
- Outputs
pathis a file or dir, dirs are tarred+gzipped by defaultarchive: none: {}uploads as isoptional: truedoesn’t fail if the path doesn’t exist
outputs:
artifacts:
- name: raw-output
path: /output
archive:
none: {}
- name: maybe
path: /tmp/optional-file.txt
optional: true
Artifact repository
- Default one is set in the
workflow-controller-configmap(artifactRepositorykey)
data:
artifactRepository: |
s3:
bucket: my-workflow-artifacts
endpoint: s3.amazonaws.com
region: us-west-2
accessKeySecret:
name: aws-credentials
key: accessKey
secretKeySecret:
name: aws-credentials
key: secretKey
- Per workflow:
spec.artifactRepositoryRefpointing to a ConfigMap and key
spec:
artifactRepositoryRef:
configMap: custom-artifact-repo-config
key: artifactRepository
- Supported: S3 (AWS, MinIO), GCS, Azure Blob, Artifactory, HDFS, OSS
- MinIO:
s3withendpoint: minio.example.com:9000andinsecure: true - GCS:
gcswithbucket,serviceAccountKeySecret
- MinIO:
- Quick start install already ships MinIO as the repository
keyFormatcustomizes the object path, e.g.{{workflow.name}}/{{pod.name}}
Volumes
- Artifacts copy data through the repo; volumes share data directly
volumeClaimTemplates
- PVC created with the workflow, deleted when it finishes
spec:
volumeClaimTemplates:
- metadata:
name: workspace
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 1Gi
templates:
- name: writer
container:
image: alpine:latest
command: [sh, -c]
args: ["echo 'Shared data' > /workspace/data.txt"]
volumeMounts:
- name: workspace
mountPath: /workspace
ReadWriteOnce+ parallel steps on different nodes can get stuck, useReadWriteManyor keep them sequential
Existing PVC
spec:
volumes:
- name: existing-storage
persistentVolumeClaim:
claimName: my-existing-pvc
emptyDir
- Only shared between containers in the same pod, so it’s not a way to pass data between separate steps (each step is its own pod)
Remember
-
Outputs: parameter from file/
result, artifact from path -
from:passes artifacts,archive.noneskips tar,optionaltolerates missing -
Default repo in
workflow-controller-configmap, override withartifactRepositoryRef -
volumeClaimTemplatesfor shared storage across steps