工作流程叢集基於開源Argo Workflow專案構建,適用於CI/CD流水線、資料處理、機器學習和模擬計算等。本文通過樣本介紹如何建立Argo工作流程。
適用範圍
工作流程ServiceAccount
工作流程可指定ServiceAccount用於運行中訪問其他Kubernetes資源,您可以建立自己的ServiceAccount,工作流程叢集會為ServiceAccount自動綁定許可權,
操作步驟
工作流程叢集支援通過Argo CLI或Argo UI建立工作流程。
通過Argo CLI建立
步驟一:安裝Argo CLI
阿里雲Argo CLI完全相容開源Argo CLI,並增強了Metrics能力和日誌能力。阿里雲Argo CLI支援查看工作流程的CPU、記憶體資源消耗及運行成本,並擷取已刪除Pod的日誌。
下載阿里雲Argo CLI。
以下步驟以Linux系統為例,Darwin(macOS)版Argo CLI的下載連結是https://ack-one.oss-cn-hangzhou.aliyuncs.com/cli/v3.4.12/argo-cli-aliyun-darwin 。
wget https://ack-one.oss-cn-hangzhou.aliyuncs.com/cli/v3.4.12/argo-cli-aliyun-linux為argo-cli-aliyun-linux授予可執行許可權。
chmod +x argo-cli-aliyun-linux將執行檔案移動到環境變數包含的目錄下,例如:
/usr/local/bin/。mv argo-cli-aliyun-linux /usr/local/bin/argo
步驟二:建立工作流程
建立並複製下方樣本到helloworld-workflow.yaml檔案。
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: helloworld-- # 工作流程名稱首碼 spec: entrypoint: helloworld # 指定入口工作流程範本 templates: - name: helloworld container: image: mirrors-ssl.aliyuncs.com/busybox:latest command: - sh - -c args: - echo "Hello, world!"; sleep 60;提交工作流程。
argo submit helloworld-workflow.yaml查看工作流程狀態。
擷取工作流程列表。
argo list預期輸出:
NAME STATUS AGE DURATION PRIORITY helloworld-lgdpp Succeeded 2m 37s 0查看工作流程狀態。
argo get helloworld-lgdpp預期輸出:
Name: hello-world-lgdpp Namespace: default ServiceAccount: unset (will run with the default ServiceAccount) Status: Succeeded Conditions: PodRunning False Completed True .... Duration: 1 minute 46 seconds Progress: 1/1 ResourcesDuration: 17s*(1 cpu),17s*(100Mi memory) STEP TEMPLATE PODNAME DURATION MESSAGE ✔ hello-world-lgdpp helloworld hello-world-lgdpp 1m
通過Argo UI建立
登入容器Argo工作流程叢集控制台,單擊目的地組群名稱。
在叢集資訊頁面中,選擇基礎資訊頁簽,單擊下方工作流程控制台(Argo)卡片,訪問Argo UI。
單擊左側workflow template選項,在NAMESPACE中輸入default,查看預製的工作流程範本。

選擇任意工作流程範本,單擊SUBMIT,運行工作流程。
