当前位置:网站首页>云原生的 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
往期推荐

点分享

点收藏

点点赞

点在看
边栏推荐
- Does bone conduction earphone have external sound? Advantages of bone conduction earphones
- OSPF - route aggregation [(summary) including configuration commands] | address summary calculation method - detailed explanation
- 仙人掌之歌——投石问路(3)
- Add user-defined formula (time sharing t+0) to mobile app access as an example
- idea jar包冲突排查
- 触发器:Mysql实现一张表添加或删除一条数据,另一张表同时添加
- 隐藏在 Nebula Graph 背后的星辰大海
- Sqlserver queries which indexes are underutilized
- 虚假的暑假
- Flink real-time data warehouse (IX): incremental synchronization of data in MySQL
猜你喜欢

华为云服务器安装mysqlb for mysqld.service failed because the control process exited with error code.See “sys

JS learning notes - process control

JS learning notes - data types

分析超700万个研发需求发现,这8门编程语言才是行业最需要的!

Yyds dry inventory method of deleting expired documents in batch

解决** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau

曆史上的今天:支付寶推出條碼支付;分時系統之父誕生;世界上第一支電視廣告...

微信v3native支付设置的结束时间处理办法

SSM整合-异常处理器及项目异常处理方案

GraphX 图计算实践之模式匹配抽取特定子图
随机推荐
Boot 连接 Impala数据库
Summary of multithreading and thread synchronization knowledge
End time processing method of wechat v3native payment settings
win10系统升级一段时间后,内存占用过高
如何实现十亿级离线 CSV 导入 Nebula Graph
MySQL min() finds the minimum value under certain conditions, and there are multiple results
Kubernetes family container housekeeper pod online Q & A?
Data Lake (11): Iceberg table data organization and query
Yyds dry inventory company stipulates that all interfaces use post requests. Why?
Maui学习之路(三)--Winui3深入探讨
How to use stustr function in Oracle view
分析超700万个研发需求发现,这8门编程语言才是行业最需要的!
Does bone conduction earphone have external sound? Advantages of bone conduction earphones
Best practices for building multi architecture images
注册成为harmonyos开发者并安装DevEco Studio 3.0 Beta2 for HarmonyOS
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
2020.4.12 byte written test questions B DP D monotone stack
JS learning notes - operators
What are the necessary functions of short video app development?
数据湖(十一):Iceberg表数据组织与查询