甲骨文第四财季营收112亿美元 云服务和授权支持业务营收占66%
前面我们创建的两个任务 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
(责任编辑:校园风采)
- 标签: Merge Labs OpenAI 脑机接口 萨姆·奥特曼
- 宾夕法尼亚大学研究发现:对AI越“粗鲁”回答准确率越高
- 亚马逊云科技陈晓建:云安全防护要像空气和水一样无处不在
- 云计算开发:Python练习实例-输出一个随机数
- 经逆向工程,Transformer「翻译」成数学框架 | 25位学者撰文
- 意大利出版商投诉谷歌 AI 概述,呼吁改善新闻可见性
- 扎克伯格再抨苹果隐私政策 并称其已成Facebook最大竞争对手之一
- 谷歌称“隐私沙盒”对广告收入几乎无影响 但隐私方面仍不明朗
- AutoAI:同步 ModelOps 和 DevOps,推动数字化转型
- 标签: 哈啰单车 哈啰普惠 98后招聘 招聘年龄歧视
- AI实战,用Python玩个自动驾驶!
- 标签: Waymo Alphabet 自动驾驶出租车 无人驾驶
- 标签: 零跑汽车 一汽股权 内资股认购
- 聊聊Hive数据类型和简单使用
