当前位置:首页 > 编程笔记 > 正文
已解决

Tekton — 通过tekton-operator部署tekton组件

来自网友在路上 11118111提问 提问时间:2023-11-23 23:48:10阅读次数: 111

最佳答案 问答题库1118位专家为你答疑解惑

文章目录

    • 版本信息
    • 部署准备
    • 安装
    • 卸载tekton组件

Tektoncd Operator 作为一个 Kubernetes 的扩展,可以方便快捷地在 Kubernetes 集群上安装、升级和管理 Tekton Pipelines、Dashboard、Triggers 等组件。

那么本篇文章介绍在K8S集群中如何通过tekton-operator部署Tekton组件。

版本信息

K8S: v1.28.2
tekton-operator: v0.68.1

部署准备

官方已提供部署文件链接,可自行查找所需版本下载 => https://github.com/tektoncd/operator/releases

https://storage.googleapis.com/tekton-releases/operator/previous/v0.68.1/release.yaml

由于网络原因,我们是无法直接使用官方提供gcr.io镜像,因此需要提前准备好镜像并push到自己的私有仓库。

并且我们还要替换掉release.yaml里所有的gcr.io的镜像:
找到release.yaml里的tekton-operator-lifecycle容器,在环境变量里添加如下内容。
环境变量名规范是:{前缀}_{容器名/参数名}

			- name: IMAGE_PIPELINES_PROXYvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/operator/cmd/kubernetes/proxy-webhook:v0.68.1- name: IMAGE_PIPELINES_TEKTON_EVENTS_CONTROLLERvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/events:v0.50.3- name: IMAGE_PIPELINES_WEBHOOKvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook:v0.50.3- name: IMAGE_PIPELINES_CONTROLLERvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/resolvers:v0.50.3- name: IMAGE_PIPELINES_TEKTON_PIPELINES_CONTROLLERvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.3- name: IMAGE_PIPELINES_ARGS__ENTRYPOINT_IMAGEvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint:v0.50.3- name: IMAGE_PIPELINES_ARGS__NOP_IMAGEvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/nop:v0.50.3- name: IMAGE_PIPELINES_ARGS__SIDECARLOGRESULTS_IMAGEvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/sidecarlogresults:v0.50.3- name: IMAGE_PIPELINES_ARGS__WORKINGDIRINIT_IMAGEvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/pipeline/cmd/workingdirinit:v0.50.3- name: IMAGE_TRIGGERS_TEKTON_TRIGGERS_CORE_INTERCEPTORSvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/triggers/cmd/interceptors:v0.25.2- name: IMAGE_TRIGGERS_TEKTON_TRIGGERS_CONTROLLERvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/triggers/cmd/controller:v0.25.2- name: IMAGE_TRIGGERS_WEBHOOKvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/triggers/cmd/webhook:v0.25.2- name: IMAGE_TRIGGERS_ARG__EL_IMAGEvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/triggers/cmd/eventlistenersink:v0.25.2- name: IMAGE_CHAINS_TEKTON_CHAINS_CONTROLLERvalue: registry.cloud-devops.com/tekton-releases/github.com/tektoncd/chains/cmd/controller:v0.17.1- name: IMAGE_JOB_PRUNER_TKNvalue: registry.cloud-devops.com/tekton-releases/dogfooding/tkn

在配置文件中,有如下配置。AUTOINSTALL_COMPONENTS控制tekton-operator在部署完成是否自动部署tekton组件。DEFAULT_TARGET_NAMESPACE指定组件所属命名空间。

apiVersion: v1
data:AUTOINSTALL_COMPONENTS: "true"DEFAULT_TARGET_NAMESPACE: tekton-pipelines
kind: ConfigMap
metadata:labels:operator.tekton.dev/release: develname: tekton-config-defaultsnamespace: tekton-operator

如果AUTOINSTALL_COMPONENTSfalse,在operator部署成功后,需要我们手动触发tekton组件的部署。
在tekton-operator中有个TektonConfig的自定义资源,创建其他组件的顶级 CRD。
当我们创建自己所需的 TektonConfig 对象后,operator会根据配置中的profile字段帮助我们安装相应的其他组件。

Tekton Operator 内置了 3 个 profile:lite、all、basic

ProfileInstalled ComponentPlatformlitePipelineKubernetes, OpenshiftbasicPipeline, Trigger, ChainsKubernetes, OpenshiftallPipeline, Trigger, Dashboard, ChainsKubernetesPipeline, Trigger, Addons, Pipelines as Code, ChainsOpenshift
# To install pipelines, triggers, chains and dashboard (use profile 'all')
$ kubectl apply -f https://raw.githubusercontent.com/tektoncd/operator/main/config/crs/kubernetes/config/all/operator_v1alpha1_config_cr.yamlapiVersion: operator.tekton.dev/v1alpha1
kind: TektonConfig
metadata:name: config
spec:profile: all     targetNamespace: tekton-pipelines   # 指定命名空间pruner:resources:  # 指定可以自动清理的资源- pipelinerun- taskrunkeep: 100  # 清理时要保留的最大资源数schedule: "0 8 * * *"  # 清理资源的频率

安装

  1. 部署tekton-operator

     $ kubectl create -f release.yaml
    

    查看部署结果:

    $ kubectl get pod -n tekton-operator
    

    在这里插入图片描述

  2. 部署tekton组件
    如果AUTOINSTALL_COMPONENTSfalse执行这个命令。否则跳过,tekton会自动部署组件。

    $ kubectl create -f operator_v1alpha1_config_cr.yaml
    

    查看结果

    $ kubectl get pod -n tekton-pipelines
    

    在这里插入图片描述

  3. 替换dashboard镜像
    因为环境变量里还不支持dashboard的镜像替换,这里需要手动更改。

    $ kubectl get TektonInstallerSet
    

    在这里插入图片描述
    编辑dashboard-main-deployment-xrlc2,替换镜像

    $ kubectl edit TektonInstallerSet dashboard-main-deployment-xrlc2
    

    查看结果
    在这里插入图片描述

  4. 访问
    Dashboard 的服务默认通过 ClusterIP 方式进行暴露,我们可以创建一个 Ingress 对象或者修改 Service 为 NodePort 方式进行暴露。

    在这里插入图片描述

卸载tekton组件

卸载tekton其实也很简单,部署时我们知道operator会根据TektonConfig对象部署组件,那么卸载组件也只需要删除这个对象即可。

# 查询对象
$ kubectl get TektonConfig

在这里插入图片描述
删除TektonConfig对象

$ kubectl delete TektonConfig config

查看结果,各个组件在逐步删除
在这里插入图片描述
在这里插入图片描述

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"Tekton — 通过tekton-operator部署tekton组件":http://eshow365.cn/6-42090-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!