Argo是一個基於kubernetes實現的一個Workflow(工做流)開源工具,基於kubernetes的調度能力實現了工做流的控制和任務的運行。
目前阿里雲容器服務ACK集羣中已經支持工做流的部署和調度,這裏咱們介紹若是在ASK(Serverless Kubernetes)集羣中使用Argo,無需預留節點資源池,便可靈活動態的運行工做流任務,並最大化節省用戶的計算成本。html
前置條件:git
# ags install # kubectl -n argo get pod NAME READY STATUS RESTARTS AGE argo-ui-5c5dbd7d75-hxqfd 1/1 Running 0 60s workflow-controller-848cf55b64-6pzc9 1/1 Running 0 60s # kubectl -n argo get configmap NAME DATA AGE workflow-controller-configmap 0 4m55s
argo默認使用docker executor api,在serverless集羣中咱們須要切換成k8sapi才能正常工做。github
# kubectl -n argo edit configmap workflow-controller-configmap apiVersion: v1 kind: ConfigMap ... data: config: | containerRuntimeExecutor: k8sapi
下面咱們運行Hello-World example:https://github.com/argoproj/argo/blob/master/examples/hello-world.yamldocker
# ags submit https://raw.githubusercontent.com/argoproj/argo/master/examples/hello-world.yaml Name: hello-world-l26sx Namespace: default ServiceAccount: default Status: Pending Created: Fri Nov 15 14:45:15 +0800 (now) # kubectl get pod NAME READY STATUS RESTARTS AGE hello-world-l26sx 0/2 Completed 0 88s # ags list NAME STATUS AGE DURATION PRIORITY hello-world-l26sx Succeeded 1m 1m 0
當咱們須要使用大規格資源來運行workflow時,能夠在workflow中給pod指定anntation。api
注意此狀況不要在container中指定大規格requests/limits,由於argo生成的pod中包含多個container,給單個container指定大規格的requests/limits會致使eci沒法給pod分配匹配的資源,進而致使建立失敗。咱們推薦給pod指定ecs規格或者cpu/mem保證pod正常運行,以下。less
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: hello-world- spec: entrypoint: whalesay templates: - name: whalesay metadata: annotations: k8s.aliyun.com/eci-instance-type : "ecs.ic5.3xlarge" container: image: docker/whalesay:latest command: [cowsay] args: ["hello world"]
當運行結束後,能夠清理workflow資源。工具
# ags delete hello-world-l26sx Workflow 'hello-world-l26sx' deleted # kubectl get pod No resources found.
咱們能夠看到,由於ASK集羣自然無需管理節點資源池,全部pod按需建立,很好的匹配了Argo工做流的任務形態,靈活動態的按需分配計算資源,更好的節省成本。ui
閱讀原文阿里雲
本文爲雲棲社區原創內容,未經容許不得轉載。url