美文网首页
tekton从入门到跑路-2-用一个pipeline串起多个ta

tekton从入门到跑路-2-用一个pipeline串起多个ta

作者: 万州客 | 来源:发表于2021-02-04 10:48 被阅读0次

这是tekton的基本功能了,这里作一下演示,还没有涉及到具体编译,而只是简单的echo。

一,第一个task定义
task-hello.yaml

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello-tekton
spec:
  steps:
    - name: hello-tekton
      image: rancher/library-busybox:1.31.1
      command:
        - echo
      args:
        - "Hello Tekton!"
  • 为什么使用 rancher/library-busybox:1.31.1,因为小,只有几m。
    应用到集群
    kubectl apply -f task-hello.yaml

二,第二个task定义
task-goodby.yaml

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: tekton-goodbye
spec:
  steps:
    - name: tekton-goodbye
      image: rancher/library-busybox:1.31.1
      command:
        - echo
      args:
        - "Goodbye Tekton!"
  • 不解释,和前一个一样,只是输出差别。
    应用到集群
    kubectl apply -f task-goodby.yaml
    三,pipeline定义
    pipeline-tekton.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: hello-goodbye
spec:
  tasks:
  - name: hello
    taskRef:
      name: hello-tekton
  - name: goodbye
    runAfter:
     - hello
    taskRef:
      name: tekton-goodbye
  • 使用了runAfter来定义顺序
  • 一个task一个Pod,依次运行
    应用到集群
    kubectl apply -f pipeline-tekton.yaml
    四,运行结果
[root@localhost tekton]# tkn pipeline start hello-goodbye
PipelineRun started: hello-goodbye-run-lrq6d

In order to track the PipelineRun progress run:
tkn pipelinerun logs hello-goodbye-run-lrq6d -f -n default
[root@localhost tekton]# tkn pipelinerun logs hello-goodbye-run-lrq6d -f -n default
[hello : hello-tekton] Hello Tekton!

[goodbye : tekton-goodbye] Goodbye Tekton!
2021-02-04 10_42_48-214 - root@localhost_~_tekton - Xshell 6 (Free for Home_School).png
  • 可以清楚看到,一个task一个pod专门来弄,相当于dockerfile的多阶段啦。

相关文章

网友评论

      本文标题:tekton从入门到跑路-2-用一个pipeline串起多个ta

      本文链接:https://www.haomeiwen.com/subject/jtfbtltx.html