在Serverless Kubernetes集群中轻松运行Argo Workflow

导读

Argo是一个基于kubernetes实现的一个Workflow(工做流)开源工具,基于kubernetes的调度能力实现了工做流的控制和任务的运行。
目前阿里云容器服务ACK集群中已经支持工做流的部署和调度,这里咱们介绍若是在ASK(Serverless Kubernetes)集群中使用Argo,无需预留节点资源池,便可灵活动态的运行工做流任务,并最大化节省用户的计算成本。html

前置条件:git

部署argo workflow controller

# 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 Workflow示例

下面咱们运行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

相关文章
相关标签/搜索