install
# Download the binary
curl -sLO https://github.com/argoproj/argo/releases/download/v2.12.4/argo-linux-amd64.gz
# Unzip
gunzip argo-linux-amd64.gz
# Make binary executable
chmod +x argo-linux-amd64
# Move binary to path
mv ./argo-linux-amd64 /usr/local/bin/argo
# Test installation
argo version
Core Concepts
The Workflow
- It defines the workflow to be executed.
- It stores the state of the workflow.
Workflow Spec
The workflow to be executed is defined in the Workflow.spec
field. The core structure of a Workflow spec is a list of templates
and an entrypoint
.
templates
can be loosely thought of as "functions": they define instructions to be executed. The entrypoint
field defines what the "main" function will be – that is, the template that will be executed first.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-world- # Name of this Workflow
spec:
entrypoint: whalesay # Defines "whalesay" as the "main" template
templates:
- name: whalesay # Defining the "whalesay" template
container:
image: docker/whalesay
command: [cowsay]
args: ["hello world"] # This template runs "cowsay" in the "whalesay" image with arguments "hello world"
template Types
Template Definitions
CONTAINER
- name: whalesay
container:
image: docker/whalesay
command: [cowsay]
args: ["hello world"]
SCRIPT
A convenience wrapper around a container
. The spec is the same as a container, but adds the source:
field which allows you to define a script in-place. The script will be saved into a file and executed for you. The result of the script is automatically exported into an Argo variable either {{tasks..outputs.result}}
or {{steps..outputs.result}}
, depending how it was called.
- name: gen-random-int
script:
image: python:alpine3.6
command: [python]
source: |
import random
i = random.randint(1, 100)
print(i)
RESOURCE
Performs operations on cluster Resources directly. It can be used to get, create, apply, delete, replace, or patch resources on your cluster.
This example creates a ConfigMap
resource on the cluster:
- name: k8s-owner-reference
resource:
action: create
manifest: |
apiVersion: v1
kind: ConfigMap
metadata:
generateName: owned-eg-
data:
some: value
SUSPEND
A suspend template will suspend execution, either for a duration or until it is resumed manually. Suspend templates can be resumed from the CLI (with argo resume
), the API endpoint, or the UI.
- name: delay
suspend:
duration: "20s"
Template Invocators¶
These templates are used to invoke/call other templates and provide execution control.
STEPS¶
A steps template allows you to define your tasks in a series of steps. The structure of the template is a "list of lists". Outer lists will run sequentially and inner lists will run in parallel. You can set a wide array of options to control execution, such as when:
clauses to conditionally execute a step.
In this example step1
runs first. Once it is completed, step2a
and step2b
will run in parallel:
- name: hello-hello-hello
steps:
- - name: step1
template: prepare-data
- - name: step2a
template: run-data-first-half
- name: step2b
template: run-data-second-half
DAG¶
A dag template allows you to define your tasks as a graph of dependencies. In a DAG, you list all your tasks and set which other tasks must complete before a particular task can begin. Tasks without any dependencies will be run immediately.
In this example A
runs first. Once it is completed, B
and C
will run in parallel and once they both complete, D
will run:
- name: diamond
dag:
tasks:
- name: A
template: echo
- name: B
dependencies: [A]
template: echo
- name: C
dependencies: [A]
template: echo
- name: D
dependencies: [B, C]
template: echo
Workflow Variables
Some fields in a workflow specification allow for variable references which are automatically substituted by Argo.
How to use variables
Variables are enclosed in curly braces and may include whitespace between the brackets and variable.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-world-parameters-
spec:
entrypoint: whalesay
arguments:
parameters:
- name: message
value: hello world
templates:
- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
# args: ["{{ inputs.parameters.message }}"] <- good
args: ["{{inputs.parameters.message}}"] # good
配置minio
$ helm repo add minio https://helm.min.io/ # official minio Helm charts
$ helm repo update
$ helm install argo-artifacts minio/minio --set service.type=LoadBalancer --set fullnameOverride=argo-artifacts --set persistence.enabled=false
Login to the Minio UI using a web browser (port 9000) after obtaining the external IP using kubectl
.
$ kubectl get service argo-artifacts
在配置文件中统一配置minio存储引擎
kubectl edit configmap workflow-controller-configmap -n argo
增加如下
data:
config: |
artifactRepository:
s3:
bucket: my-bucket
endpoint: argo-artifacts:9000
insecure: true
# accessKeySecret and secretKeySecret are secret selectors.
# It references the k8s secret named 'argo-artifacts-minio'
# which was created during the minio helm install. The keys,
# 'accesskey' and 'secretkey', inside that secret are where the
# actual minio credentials are stored.
accessKeySecret:
name: argo-artifacts
key: accesskey
secretKeySecret:
name: argo-artifacts
key: secretkey
NOTE: When minio is installed via Helm, it generates credentials, which you will use to login to the UI: Use the commands shown below to see the credentials
- AccessKey: kubectl get secret argo-artifacts -o jsonpath='' | base64 --decode
- SecretKey: kubectl get secret argo-artifacts -o jsonpath='' | base64 --decode
Create a bucket named my-bucket
from the Minio UI.