当前位置:网站首页>云原生的 CICD 框架:Tekton
云原生的 CICD 框架:Tekton
2022-07-02 12:50:00 【CSDN云计算】

作者 | AddoZhang
来源 | 云原生指北
Tekton 是 Google 开源的 Kubernetes 原生CI/CD 系统,功能强大扩展性强。前身是 Knavite 里的 build-pipeline 项目,后期孵化成独立的项目。并成为 CDF 下的四个项目之一, 其他三个分别是 Jenkins, Jenkins X, Spinnaker。
为什么说 Tekton 是 Kubernetes 原生的, 因其基于 Kubernetes 的 CRD 定义了 Pipeline 流水线。
CRD 及说明:
Task: 构建任务, 可以定义一些列的 steps. 每个 step 由一个 container 执行.
TaskRun: task 实际的执行, 并提供执行所需的参数. 这个对象创建后, 就会有 pod 被创建。
Pipeline: 定义一个或者多个 task 的执行, 以及 PipelineResource 和各种定义参数的集合。
PipelineRun: 类似 task 和 taskrun 的关系: 一个定义一个执行. PipelineRun 则是 pipeline 的实际执行. 创建后也会创建 pod 来执行各个 task。
PipelineResource: 流水线的输入资源, 比如 github/gitlab 的源码, 某种存储服务的文件, 或者镜像等. 执行时, 也会作为 pod 的其中一个 container 来运行(比如拉取代码)。
Condition: 在 pipeline 的 task 执行时通过添加 condition 来对条件进行评估, 进而判断是否执行 task. 目前是WIP的状态, 待#1137的完成、
组件:
tekton-pipelines-controller: 监控 CRD 对象(TaskRun, PipelineRun)的创建, 为该次执行创建 pod.tekton-pipelines-webhook: 对 apiserver 提供 http 接口做 CRD 对象的校验
安装
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml检查安装的tekton相关的CRD:
kubectl api-resources | grep tekton
clustertasks tekton.dev false ClusterTask
conditions tekton.dev true Condition
pipelineresources tekton.dev true PipelineResource
pipelineruns pr,prs tekton.dev true PipelineRun
pipelines tekton.dev true Pipeline
taskruns tr,trs tekton.dev true TaskRun
tasks tekton.dev true Tasktekton 的两个pod:
kubectl get pods --namespace tekton-pipelines
NAME READY STATUS RESTARTS AGE
tekton-pipelines-controller-556d8f4494-2qthv 1/1 Running 0 11m
tekton-pipelines-webhook-849cff5cf-8m5qq 1/1 Running 0 11m安装CLI
cli: https://github.com/tektoncd/cli#installing-tkn
brew install tektoncd-cliTekton: hello world
创建一个简单的Task, 只有一个step就是打印出”hello world”
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: echo-hello-world
spec:
steps:
- name: echo
image: alpine
command:
- echo
args:
- "hello world"创建一个TaskRun执行上面的Task
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: echo-hello-world-task-run
spec:
taskRef:
name: echo-hello-world运行task:
kubectl apply -f <name-of-file.yaml>检查TaskRun的输出, 执行命令:
tkn taskrun describe echo-hello-world-task-runName: echo-hello-world-task-run
Namespace: tekton-pipelines
Task Ref: echo-hello-world
Status
STARTED DURATION STATUS
21 minutes ago 1 minute Succeeded
Input Resources
No resources
Output Resources
No resources
Params
No params
Steps
NAME STATUS
echo CompletedSucceeded状态表示task执行成功.
查看实际的输出, 执行命令:
tkn taskrun logs echo-hello-world-task-run结果:
[echo] hello world
往期推荐

点分享

点收藏

点点赞

点在看
边栏推荐
- mysql数据库mysqldump为啥没有创建数据库的语句
- Route service grid traffic through two-level gateway design
- Conditions and solutions of deadlock
- Maui learning road (III) -- in depth discussion of winui3
- 数据湖(十一):Iceberg表数据组织与查询
- sim2real环境配置教程
- Does bone conduction earphone have external sound? Advantages of bone conduction earphones
- 2022 the latest and most detailed will successfully set the background image in vscade and solve unsupported problems at the same time
- Song of cactus - throwing stones to ask the way (2)
- 【题解】Educational Codeforces Round 82
猜你喜欢

What is Amazon keyword index? The consequences of not indexing are serious

JS learning notes - data types

Another graduation season

JS learning notes - operators

手机app通达信添加自定义公式(分时T+0)为例子讲解

win10系统升级一段时间后,内存占用过高

Some problems about MySQL installation

潘多拉 IOT 开发板学习(RT-Thread)—— 实验2 RGB LED 实验(学习笔记)

Vscade set multi line display of tab

处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin
随机推荐
Data Lake (11): Iceberg table data organization and query
数仓中的维度表与事实表
死锁的条件及解决方法
2022 the latest and most detailed will successfully set the background image in vscade and solve unsupported problems at the same time
Compress words (kmp/ string hash, double hash)
Source code look me
请问怎么在oracle视图中使用stustr函数
Boot 事务使用
HMS core machine learning service helps zaful users to shop conveniently
Construction and business practice of Zhongke brain knowledge map platform
Add user-defined formula (time sharing t+0) to mobile app access as an example
Conditions and solutions of deadlock
Vscode设置标签页多行显示
做机器视觉哪个软件好?
/Bin/ld: cannot find -lgssapi_ krb5
Effectively use keywords to increase Amazon sales
结构体的内存对齐
Flink real-time data warehouse (7): Flink realizes the full pull module to extract data in MySQL
Multi data source configuration code
JS learning notes - variables