Argo安装和workflow实例配置文件解析

博客 动态
0 280
羽尘
羽尘 2022-02-09 22:55:10
悬赏:0 积分 收藏

Argo 安装和 workflow 实例配置文件解析

一、Argo 安装配置

1.1 Argo 安装

$ kubectl create ns argo$ kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/master/manifests/quick-start-postgres.yaml$ kubectl get all -n argo

image-20220209215125019

1.2 修改 Argo 服务对外访问

$ kubectl edit svc argo-server -n argo...  selector:    app: argo-server  sessionAffinity: None  type: NodePort   # 修改为 NodePortstatus:...

保存退出跟 vim 操作一样,成功退出后等待即可。

1.3 Web 访问 Argo

[root@k8s-master01 ~]# kubectl get svc -n argoNAME                                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGEservice/argo-server                   NodePort    10.233.11.72    <none>        2746:31335/TCP   23h...

image-20220208092758566

1.4 Linux 安装 Argo CLI

$ curl -sLO https://github.com/argoproj/argo/releases/download/v3.0.2/argo-linux-amd64.gz$ gunzip argo-linux-amd64.gz$ chmod +x argo-linux-amd64$ mv ./argo-linux-amd64 /usr/local/bin/argo$ argo version

其他版本链接:https://github.com/argoproj/argo-workflows/releases

我安装 v3.2.8 版本时,在命令行创建 workflow 的时候,一直卡住不动,UI 界面也不同步 workflow,后面换一个低点版本就解决该问题了。

如果你也遇到我类似的问题,可以试着换个版本试试。

二、官方工作流实例

2.1 hello-world 实例

构建工作流

[root@k8s-master01 argo]# argo submit -n argo --watch https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/hello-world.yaml

hello-world.yaml配置文件解析

apiVersion: argoproj.io/v1alpha1kind: Workflowmetadata:  generateName: hello-world-   # workflow 名字  labels:         # 标签    workflows.argoproj.io/archive-strategy: "false"  annotations:    # 为用户添加的额外注解    workflows.argoproj.io/description: |      This is a simple hello world example.      You can also run it in Python: https://couler-proj.github.io/couler/examples/#hello-worldspec:  entrypoint: whalesay   # 表示第一个执行的模板名称,让工作流知道从哪个模板开始执行,类似于 main 函数  templates:             # 以下是模板内容  - name: whalesay       # 模板名称    container:           # 容器内容      image: docker/whalesay:latest   # 调用 docker/whalesay 镜像      command: [cowsay]               # 调用 cowsay 命令      args: ["hello world"]           # 执行内容

Pod 初始化

image-20220209092639408

工作流完成

image-20220209092750882

查看 Pod Logs

[root@k8s-master01 argo]# argo logs -n argo @latest# @latest  查看最新工作流log

image-20220209092837250

Argo UI 也可以同步查看 Pod 运行信息

image-20220209093009412

image-20220209093035693

2.2 Steps 类型的 workflow

接下来练习稍微复杂点的 Workflow,hello-hello-hello.yml配置文件解析

apiVersion: argoproj.io/v1alpha1kind: Workflowmetadata:  generateName: steps-          # Workflow 的名称前缀spec:  entrypoint: hello-hello-hello # 表示第一个执行的模板名称,让工作流知道从哪个模板开始执行,类似于 main 函数  # 该templates中有两个模板,分别是:hello-hello-hello和whalesay  templates:  - name: hello-hello-hello     # 第一个模板 hello-hello-hello     steps:                      # template 的类型是 steps    # 一个 template 有多种类型,分别为:container、script、dag、steps、resource、suspend    - - name: hello1            # 在 steps 类型中,[--] 表示顺序执行,[-] 表示并行执行        template: whalesay      # 引用 whalesay 模板        arguments:          parameters:          - name: message            value: "hello1"    - - name: hello2a           # [--] 顺序执行        template: whalesay        arguments:          parameters:          - name: message            value: "hello2a"      - name: hello2b           # [-] 表示跟上一步并行运行        template: whalesay        arguments:          parameters:          - name: message            value: "hello2b"  - name: whalesay   # 第二个模板 whalesay     inputs:          # input、output 实现数据交互      parameters:      - name: message    container:      image: docker/whalesay  # 镜像名称      command: [cowsay]       # 执行命令      args: ["{{inputs.parameters.message}}"]  # 执行的 value

构建 workflow

[root@k8s-master01 argo]# lshello-hello-hello.yml  hello-world.yaml[root@k8s-master01 argo]# argo submit -n argo hello-hello-hello.yml --watch# submit    创建工作流# -n argo   存放的命名空间# --watch   实时监听工作流

QQ截图20220209211252

在 Argo Web 界面查看,此时工作流正在构建中

QQ截图20220209211242

第一个 hello 已经执行完成,并打印相应的信息

QQ截图20220209211312

image-20220209214213293

第一个完成之后,接下来 hello2a 和 hello2b 会并行执行

image-20220209214434447

hello2a 和 hello2b 都会打印相关信息,然后结束整个workflow

image-20220209214658209

以上非常基础的 Argo Workflow 学习,连门都没入,希望能和大佬们交流交流。


作者:神奇二进制
文章出处:https://www.cnblogs.com/l-hh/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
文章如有叙述不当的地方,欢迎指正。如果觉得文章对你有帮助,可以精神上的支持 [推荐] 或者 [关注我] ,一起交流,共同进步!

posted @ 2022-02-09 22:02 神奇二进制 阅读(0) 评论(0) 编辑 收藏 举报
回帖
    羽尘

    羽尘 (王者 段位)

    2335 积分 (2)粉丝 (11)源码

     

    温馨提示

    亦奇源码

    最新会员