0
点赞
收藏
分享

微信扫一扫

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

舍予兄 2021-09-19 阅读 54
CI/CD

一,第一个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!

  • 可以清楚看到,一个task一个pod专门来弄,相当于dockerfile的多阶段啦。
举报

相关推荐

0 条评论