클러스터 워크플로 템플릿 (Cluster Workflow Templates)
ClusterWorkflowTemplate은 클러스터 범위의 WorkflowTemplate입니다. 네임스페이스가 아니라 클러스터 전체에서 공유되는 템플릿을 정의하고 참조하는 방법을 배워봅니다.
본문
v2.8 이상
소개 (Introduction)
ClusterWorkflowTemplates는 클러스터 범위(cluster scoped)의 WorkflowTemplates입니다. ClusterWorkflowTemplate은 ClusterRole처럼 클러스터 범위로 생성할 수 있고, 클러스터 내 모든 네임스페이스에서 접근할 수 있습니다.
WorkflowTemplates 문서 링크
ClusterWorkflowTemplate 정의하기
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: cluster-workflow-template-print-message
spec:
templates:
- name: print-message
inputs:
parameters:
- name: message
container:
image: busybox
command: [echo]
args: ["{{inputs.parameters.message}}"]
다른 ClusterWorkflowTemplates 참조하기
templateRef 필드에 clusterScope: true를 사용하면 다른 ClusterWorkflowTemplates의 templates를 참조할 수 있습니다. 같은 Workflow 안에서 다른 templates를 참조하는 것과 마찬가지로, steps나 dag 템플릿에서 참조해야 합니다.
예제:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-template-hello-world-
spec:
entrypoint: hello-world
templates:
- name: hello-world
steps: # You should only reference external "templates" in a "steps" or "dag" "template".
- - name: call-print-message
templateRef: # You can reference a "template" from another "WorkflowTemplate or ClusterWorkflowTemplate" using this field
name: cluster-workflow-template-print-message # This is the name of the "WorkflowTemplate or ClusterWorkflowTemplate" CRD that contains the "template" you want
template: print-message # This is the name of the "template" you want to reference
clusterScope: true # This field indicates this templateRef is pointing ClusterWorkflowTemplate
arguments: # You can pass in arguments as normal
parameters:
- name: message
value: "hello world"
ClusterWorkflowTemplate 스펙에서 Workflow 생성하기
v2.9 이상
workflowTemplateRef에 clusterScope: true를 사용하면 ClusterWorkflowTemplate 스펙에서 Workflow를 생성할 수 있습니다. 생성된 Workflow에 인자를 전달하면 클러스터 워크플로 템플릿의 인자와 병합됩니다.
entrypoint와 arguments가 있는 ClusterWorkflowTemplate 예제입니다:
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: cluster-workflow-template-submittable
spec:
entrypoint: print-message
arguments:
parameters:
- name: message
value: hello world
templates:
- name: print-message
inputs:
parameters:
- name: message
container:
image: busybox
command: [echo]
args: ["{{inputs.parameters.message}}"]
entrypoint와 arguments를 ClusterWorkflowTemplate에 전달하면서 이를 Workflow로 생성하는 예제입니다:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: cluster-workflow-template-hello-world-
spec:
entrypoint: print-message
arguments:
parameters:
- name: message
value: "from workflow"
workflowTemplateRef:
name: cluster-workflow-template-submittable
clusterScope: true
WorkflowTemplate을 Workflow로 생성하면서 WorkflowTemplates의 entrypoint와 Workflow Arguments를 사용하는 예제입니다:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: cluster-workflow-template-hello-world-
spec:
workflowTemplateRef:
name: cluster-workflow-template-submittable
clusterScope: true
ClusterWorkflowTemplates 관리하기
CLI
예제 템플릿을 다음과 같이 생성할 수 있습니다:
argo cluster-template create https://raw.githubusercontent.com/argoproj/argo-workflows/main/examples/cluster-workflow-template/clustertemplates.yaml
그런 다음 그 템플릿 중 하나를 사용해 Workflow를 제출합니다:
argo submit https://raw.githubusercontent.com/argoproj/argo-workflows/main/examples/cluster-workflow-template/cluster-wftmpl-dag.yaml
v2.7 이상
ClusterWorkflowTemplate을 Workflow로 제출합니다:
argo submit --from clusterworkflowtemplate/cluster-workflow-template-submittable
kubectl
kubectl apply -f와 kubectl get cwft를 사용합니다.
UI
ClusterWorkflowTemplate 리소스는 UI에서도 관리할 수 있습니다.
더 알아보기 (Learn more)
clusterScope: true가 붙은templateRef는 클러스터 범위 템플릿을 가리킵니다. 네임스페이스 템플릿 참조와 헷갈리지 마세요.workflowTemplateRef로 템플릿을 Workflow처럼 직접 제출할 수 있고, 전달한 인자는 템플릿의 기본 인자와 병합됩니다.- CLI에서는
argo cluster-template create와kubectl get cwft로 관리합니다.