Workflow (argo)
その名の通り、ワークフローを定義するもの
yamlで定義される
以下の2つの役割を担う
定義: 何をどう実行するかを記述する
状態保持: 現在どこまで進んだか等、状態を保持する
例
code:yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-world-
spec:
entrypoint: hello-world
templates:
- name: hello-world
container:
image: busybox
参考
spec
実行されるworkflowを定義する
以下の2つからなる
templates
templateは関数のようなもの
entrypoint
templatesの内、実行の起点となるテンプレート名
code:yaml
spec:
entrypoint: hello-world # 最初に実行されるテンプレート
templates:
- name: hello-world
container:
image: busybox
step
steps テンプレート内で使う処理単位
他のテンプレートを「いつ・どう実行するか」を定義する
名前、使うテンプレート名、引数などを指定できる
例
code:yaml
- name: main
steps:
- - name: step1
template: say-hello
🔧 実用的な理解ポイント
Argo を使って 段階的な処理(ステップ)をKubernetes上で管理したいとき、
各ステップをテンプレートに切り出して、steps や dag を使って 順序制御する
テンプレートは再利用できる(WorkflowTemplate)
🎯 具体的な例(イメージしやすく)
code:yaml
# Workflow全体(entrypointでmainテンプレートから始まる)
spec:
entrypoint: main
templates:
# 1. mainテンプレート:ステップ定義
- name: main
steps:
- - name: step1
template: say-hello
- - name: step2
template: say-bye
# 2. say-hello テンプレート:コンテナ実行
- name: say-hello
container:
image: busybox
# 3. say-bye テンプレート:別のコンテナ実行
- name: say-bye
container:
image: busybox