会员登录 - 用户注册 - 设为首页 - 加入收藏 - 网站地图 甲骨文第四财季营收112亿美元 云服务和授权支持业务营收占66%!

甲骨文第四财季营收112亿美元 云服务和授权支持业务营收占66%

时间:2026-09-27 来源: 作者:商品分类 阅读:次

前面我们创建的两个任务 test 和 build-and-push 都已经完成了,我们还可以创建一个流水线来将这两个任务组织起来,形成一个流水线,这里就是我们要使用的 Pipeline 这个 CRD 对象。

创建流水线

比如我们这里的流水线流程为先运行 test 任务,如果通过了再执行后面的 build-and-push 这个任务,那么我们可以创建一个名为 test-pipeline.yaml 的资源对象,内容如下所示:

# test-pipeline.yaml apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata:   name: test-pipeline spec:   resources:  # 为 Tasks 提供输入和输出资源声明     - name: demo-git       type: git     - name: harbor-image       type: image   tasks:  # 添加task到流水线中     # 运行应用测试     - name: test       taskRef:         name: test       resources:         inputs:           - name: repo # Task 输入名称             resource: demo-git # Pipeline 资源名称     # 构建并推送 Docker 镜像     - name: build-and-push       taskRef:         name: build-and-push       runAfter:       - test # 测试任务执行之后       resources:         inputs:         - name: repo  # 指定输入的git仓库资源           resource: demo-git         outputs:  # 指定输出的镜像资源         - name: builtImage           resource: harbor-image 

首先我们需要定义流水线需要哪些资源,可以是输入或者输出的资源,在这里我们只有一个输入,那就是命名为 repo 的应用程序源码的 GitHub 仓库。接下来定义任务,每个任务都通过 taskRef 进行引用,并传递任务需要的输入参数。

同样直接创建这个资源对象即可:

$ kubectl apply -f test-pipeline.yaml pipeline.tekton.dev/test-pipeline created 

前面我们提到过和通过创建 TaskRun 去触发 Task 任务类似,我们可以通过创建一个 PipelineRun 对象来运行流水线。这里我们创建一个名为 test-pipelinerun.yaml 的 PipelineRun 对象来运行流水线,文件内容如下所示:

apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata:   name: test-pipelinerun spec:   serviceAccountName: build-sa   pipelineRef:     name: test-pipeline   resources:   - name: demo-git  # 指定输入的git仓库资源     resourceRef:       name: demo-git   - name: harbor-image  # 指定输出的镜像资源     resourceRef:       name: harbor-image 

定义方式和 TaskRun 几乎一样,通过 serviceAccountName 属性指定 ServiceAccount 对象,pipelineRef 关联流水线对象。同样直接创建这个资源,创建后就会触发我们的流水线任务了:

$ kubectl apply -f test-pipelinerun.yaml pipelinerun.tekton.dev/test-pipelinerun created $ github kubectl get pods | grep test-pipelinerun test-pipelinerun-build-and-push-62g65-pod-6jqqf   0/4     Init:1/2    0          3s test-pipelinerun-test-c4r9m-pod-j7jjd             0/2     Completed   0          12s $ tkn pipelinerun describe test-pipelinerun Name:              test-pipelinerun Namespace:         default Pipeline Ref:      test-pipeline Service Account:   build-sa Timeout:           1h0m0s Labels:  tekton.dev/pipeline=test-pipeline  

(责任编辑:服饰穿搭)

相关内容
  • Google X华人博士发布机器人模拟器SimGAN,ICLR2021已发表
  • 浜戣�绠楁牳蹇冩妧鏈疍ocker鏁欑▼锛欴ocker浣跨敤syslog鏃ュ織椹卞姩绋嬪簭
  • 标签: OpenClaw 黄仁勋 大模型公司
  • 字节跳动重奖大模型人才,Seed部门推百万期权激励计划
  • 组织网友刷好评 亚马逊将两家公司告上法庭
  • 标签: ASML 光刻机 富凯 半导体设备
  • 标签: 大众汽车
  • 标签: 玖物智能 港交所上市 智能机器人 清洁能源
推荐内容
  • 算法的进化:机器会引发战争吗?
  • 云安全日报210406:红帽OpenShift云应用平台发现拒绝服务漏洞,需要尽快升级
  • ​硅基流动上线线蚂蚁集团Ling-mini-2.0,速度与性能双丰收
  • 亚马逊将开发127项新能源计划
  • 标签: 长安汽车 年终奖 不实信息
  • 字节跳动新举措!推出豆包股激励计划,吸引大模型人才