openshift-docs
  • 不知所措的openshift kubernetes
  • 3scale
    • 在openshift使用3scale-operator部署3scale
  • Hyperledger-Fabric
    • Hyperledger Fabric on openshift 3.11
  • adminer
    • helm部署adminer
  • admission-controller
    • k8s nameapce增加默认node-selector和defaultTolerations
  • cert-manager
    • cert-manager-1.5升级到1.6
  • cicd
    • Argocd定时备份到us3
    • Argocd添加服务流程
    • Argocd自定义健康检查
    • helm安装argocd
    • k8s1.22部署gitlab对接keycloak
    • 使用Tekton+Helm-Chart+ArgoCD构建GitOps CICD
    • 使用 Tekton 构建CI流程
    • 使用argocd-notifications通知Tekton触发api-test
    • 使用 docker buildx 构建多CPU架构镜像
    • 使用image-syncer同步多CPU架构镜像到私有仓库
    • 开源helm chart 发布到 https://artifacthub.io/
    • 快速编写通用helm chart
  • client-go
    • k8s client-go 创建ingress示例
  • cluster-monitor-opertor
    • Openshift3.11 alertmanager 持久化
    • cluster-monitor-operator alertmanager配置
    • cluster-monitor-operator添加外部metrics
    • openshift3.11-cluster-monitoring-operator数据持久化
  • config-syncer
    • k8s使用config-syncer(kubed)同步secret
  • dns
    • k8s coredns 优化
    • k8s 使用coredns 自定义hosts 解析
  • dnsmasq
    • MAC 环境使用 dnsmasq 配置openshift相关自定义域名
    • 配置dnsmasq apps通配解析
  • elasticsearch
    • Elasticsearch查询重复数据
    • elasticsearch-kibana-8.10创建向量索引模板
    • openshift3.11中使用ECK安装filebeat+elasticsearch+kibana收集日志初探
    • openshift3.11部署eck1.6+es7.14.1
    • 使用kibana修改数据流索引mapping
  • etcd
    • k8s 1.22 使用cronjob 备份etcd
    • k8s1.22使用CronJob定时备份etcd到US3
    • 使用cronjob备份etcd
    • 恢复openshift3.11-etcd数据快照
  • flowiseai
    • argocd2.2.1+helm3.9-chart+k8s1.22部署flowise
  • ingress-nginx
    • ingress-nginx启用header名称中下划线
  • ipfs
    • golang计算文件ipfs cid
    • helm安装ipfs-cluster
  • kafka
    • banzaicloud-stable/kafka-operator+local-path迁移主机
    • 使用bitnami/kafka部署外部可访问的 kafka
  • keycloak
    • openshift使用keycloak登录
  • kong
    • Kong使用ip-pestriction插件配置IP白名单
    • kong admin api 使用 go-kong 调用
    • kong manager页面显示空白,报错net:ERR_HTTP2_PROTOCOL_ERROR
    • kong helm 安装
    • kong 自定义默认error html
    • 使用kong转发TCP服务
  • kube-flannel
    • kube-flannel-v0.20.1升级v0.22.2
  • kubeadm
    • RockLinux+kubeadm+k8s-1.22.16 升级到1.22.17
    • RockLinux+kubeadm+k8s-1.22.2 升级到1.22.16
  • kubevirt
    • Kubevirt on Openshift
    • kubebirt 中使用 cloud-init
    • kubevirt限制vm发布主机
    • openshift-3.11-kubevirt从v0.19.0升级到v0.27.0
    • 使用alpine-make-vm-image制作alpine-qcow2云镜像
    • 使用virtualbox自定义Alpine-vrit云镜像
  • load-balance
    • ucloud 添加负载均衡报文转发配置
  • metrics-sever
    • k8s-1.22安装metrics-server
  • mongodb
    • 使用argocd部署mongo-express
    • 阿里云 Mongodb副本集实例使用
  • mysql
    • Helm部署mysql
    • helm安装phpmyadmin
    • mysql批量修改utf8mb3为utf8mb4字符集
    • 部署MySQL Server Exporter
  • openfaas
    • OpenFaaS定时任务
    • OpenFaas使用Go模板创建Function
    • helm 安装openfaas
  • operator
    • 使用Operator-SDK构建基于Helm 的 Operator
  • playwright
    • 使用playwright截图Kibana图表
  • prometheus-operator
    • helm+kube-prometheus-stack-prometheus-operator+local-path(storageclass)部署的prometheus迁移主机
    • k8s 1.22 环境 kube-prometheus-stack 22.x 升级至 41.x
    • 使用helm+kube-prometheus-stack只部署prometheus
  • proxy
    • 使用快代理使用海外代理访问海外网站
  • rancher
    • helm 安装rancher 2.6.3
    • rancher-backup使用US3备份
    • rancher2.6.3升级至rancher2.6.9
    • rancher2.6.9对接keycloak
    • 解决rancher-v2.6.3报helm-operator更新rancher-webhook异常问题
    • 解决更新rancher2.6.13后报webhook和fleet chart版本不支持
  • raspberry-pi
    • mac os golang编译ARM环境go-sqlite3项目
    • 无头(headless) raspberry pi 4 ssh wifi 安装(mac)
    • 树莓派4B+raspberry-pi-os-buster在线安装k3s
    • 树莓派Raspberry Pi OS 设置静态ip
    • 树莓派raspberry-pi-os(32bit)安装docker
    • 树莓派raspberry pi os开启ssh
    • 树莓派安装centos7并简单优化
  • rbac
    • openshift给没能打开web terminal终端的用户添加权限
  • registry
    • 使用image-syncer同步所需镜像到仓库
  • ssh
    • Mac OSX ssh隧道使用方法
  • storage
    • lvm分区配置备份与恢复测试
    • openshift3.11使用nfs-client-provisioner+UCloud-UFS提供动态pv存储
    • openshift3.11使用nfs-client-provisioner+阿里云NAS提供动态nfs
    • openshift3.11配置local volume
    • openshift动态nfs
  • tracing
    • Ipfs cluseter使用分布式追踪系统jaeper tracing
  • troubleshooting
    • coredns service 连接超时(connection timed out; no servers could be reached)
    • etcdDatabaseHighFragmentationRatio 异常处理
    • helm更新服务报错提示statefulset更新是被禁止的
    • k8s如果防止容器中出现僵尸进程
    • kubevirt api server 证书过期问题导致openshfit调度异常
    • macOS Chrome访问https://registry-console-default.appsxxx.xxx.xxx/页面显示ERR_CERT_INVALID,且不能点继续
    • master 主机df 卡死
    • openshift project Terminaing处理
    • OpenShift Docker Registry 500
    • 解决openshift3.11 node NotReady csr Pending
    • openshift3.11-pvc-delete-Terminating-hang
    • openshift3.11清理Terminating 状态project
    • pod pending event报错cni无可用IP
    • ucloud环境开启selinux后/var/log/messages不能写入问题
    • ucloud环境开启selinux
    • 解决openshift3.11不能下载redhat registry.access.redhat.com中镜像问题
    • 证书未过期但是报NET::ERR_CERT_AUTHORITY_INVALID证书错误处理
  • walletconnect
    • WalletConnect-Relay 部署
Powered by GitBook
On this page
  • 安装 Tekton
  • 安装 Tekton 核心及Tekton pipelines
  • 允许同一个Pipeline挂载两个pvc
  • 安装 tekton-pipeline
  • 安装 Tekton Cli
  • 安装 Tekton Triggers
  • 安装 Tekton Dashboard
  • 构建 CI 流程
  • 概念描述
  • 触发器(Triggers) 和 事件监听(EventListeners)
  • 拉取模板代码
  • 创建 Tasks
  • 创建 Pipelines
  • 创建 pvcs
  • 创建 Triggers
  • 创建 EventListerners
  • 参考

Was this helpful?

  1. cicd

使用 Tekton 构建CI流程

安装 Tekton

安装 Tekton 核心及Tekton pipelines

curl -o tekton-pipeline.yaml https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

允许同一个Pipeline挂载两个pvc

默认tekton 禁用了同一个pipeline 挂载两个不同pvc, 当前 TriggerTemplate 示例中 source、 cache 两个workspaces 使用了不同的pvc, 所以需要开放限制

编辑 tekton-pipeline.yaml,找到 configmap feature-flags, 看到 disable-affinity-assistant, 值修改为true 。

如果安装前没有修改,也可以安装后kubectl edit configmap feature-flags -n tekton-pipelines 修改

安装 tekton-pipeline

kubectl apply -f tekton-pipeline.yaml

配置Tekton在运行工作流时使用 manual 存储类请求10Gi的持久化卷

kubectl create configmap config-artifact-pvc \
                         --from-literal=size=10Gi \
                         --from-literal=storageClassName=manual \
                         -o yaml -n tekton-pipelines \
                         --dry-run=client | kubectl replace -f -

检查pods

kubectl get pods --namespace tekton-pipelines

安装 Tekton Cli

# Linux AMD 64
# Get the tar.xz
curl -LO https://github.com/tektoncd/cli/releases/download/v0.25.0/tkn_0.25.0_Linux_x86_64.tar.gz
# Extract tkn to your PATH (e.g. /usr/local/bin)
sudo tar xvzf tkn_0.25.0_Linux_x86_64.tar.gz -C /usr/local/bin/ tkn
tkn -h

安装 Tekton Triggers

curl -o tekton-triggres.yaml https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml
kubectl apply --filename tekton-triggres.yaml
curl -o tekton-triggers-interceptors.yaml https://storage.googleapis.com/tekton-releases/triggers/latest/interceptors.yaml
kubectl apply --filename tekton-triggers-interceptors.yaml

检查 pods

kubectl get pods --namespace tekton-pipelines

安装 Tekton Dashboard

curl -L -o tekton-dashboard.yaml https://github.com/tektoncd/dashboard/releases/download/v0.28.0/tekton-dashboard-release.yaml
kubectl apply --filename tekton-dashboard.yaml

检查 pods

kubectl get pods --namespace tekton-pipelines

创建 tekton-dashboard-ingress.yaml, tekton 没有用户管理,所以建议限制ip段访问

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tekton-dashboard-ingress
  namespace: tekton-pipelines
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: 'true'
    #nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    # 限制ip 访问,默认不限制
    nginx.ingress.kubernetes.io/whitelist-source-range: "172.17.0.0/16,127.0.0.1,10.0.0.0/24"
spec:
  tls:
    - hosts:
        - tekton.example.com
      secretName: example-com-tls
  rules:
  - host: tekton.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: tekton-dashboard
            port:
              number: 9097

构建 CI 流程

概念描述

Tekton Pipelines 实体列表

实体
描述

Task

定义一系列启动特定构建或交付工具的步骤,这些工具接收特定的输入并产生特定的输出。

TaskRun

用特定的输入、输出和执行参数实例化一个Task以供执行。可以单独调用,也可以作为Pipeline的一部分调用。

Pipeline

定义一系列完成特定构建或交付目标的任务。可以由事件触发或从PipelineRun调用。

PipelineRun

用特定的输入、输出和执行参数实例化一个Pipeline以供执行。

触发器(Triggers) 和 事件监听(EventListeners)

Tekton Triggers 包含在 Kubernetes 集群上运行的控制器服务以及 Kubernetes 自定义资源 (CRD),它们扩展了 Tekton Pipelines 的功能以支持事件:

拉取模板代码

Tasks/Pipelines 可以从https://hub.tekton.dev/ 中寻找已有项目参考

clone编写好的示例和模板, 期中部分tasks 是从https://hub.tekton.dev/ 中下载修改的。

git clone https://github.com/paradeum-team/tekton-catalog.git

目录结构

tekton-catalog
├── eventListeners
│   └── gitlab-EventListener.yaml
├── LICENSE
├── pipelines
│   ├── golang.yaml
│   └── nodejs.yaml
├── pvcs
│   └── tekton-cache-claim.yaml
├── rbacs
│   └── tekton-triggers-eventlistener-rbac.yaml
├── README.md
├── tasks
│   ├── delete-pipelineruns.yaml
│   ├── dockerfile-lint.yaml
│   ├── git-cli.yaml
│   ├── git-clone.yaml
│   ├── golang-build.yaml
│   ├── kaniko.yaml
│   ├── nodejs-build.yaml
│   └── yq-helm-chart-version.yaml
├── triggers
│   ├── golang-triggerTemplate.yaml
│   └── nodejs-triggerTemplate.yaml
└── triggersBindings
    └── gitlab-nft-triggerBinding.yaml

创建 Tasks

cat tekton-catalog/tasks/*.yaml | kubectl -n tekton-pipelines create -f -

创建 Pipelines

示例 Pipelines 中的Pipeline 流程图

执行创建pipelines

cat tekton-catalog/pipelines/*.yaml | kubectl -n tekton-pipelines create -f -

创建 pvcs

酌情修改pvcs 中的yaml 内容,创建cache pvc, size 10Gi , storageClassName: manual

cat tekton-catalog/pvcs/*.yaml | kubectl -n tekton-pipelines create -f -

创建 Triggers

创建EventListernets 和 Triggers使用的sa, 并授权

cat tekton-catalog/rbacs/*.yaml | kubectl -n tekton-pipelines create -f -

酌情修改并创建 TriggerBindings

kubectl -n tekton-pipelines apply -f tekton-catalog/triggersBindings/gitlab-nft-triggerBinding.yaml

TriggerTemplates根据 Pipeline 创建PipelineRun, 创建 TriggerTemplates

cat tekton-catalog/triggers/*.yaml | kubectl -n tekton-pipelines create -f -

创建 EventListerners

创建tekton 访问 gitlab 的认证 secret

gitlab-secret.yaml

kind: Secret
apiVersion: v1
metadata:
  name: gitlab-basic-auth-secret
type: Opaque
stringData:
  .gitconfig: |
    [credential "http://gitlab.example.com"]
      helper = store
    [credential "https://gitlab.example.com"]
      helper = store
  .git-credentials: |
    http://cicd:xxxxxxxx@gitlab.example.com
    https://cicd:xxxxxxxx@gitlab.example.com
kubectl -n tekton-pipelines apply -f gitlab-secret.yaml

创建tekton 访问registry 仓库的认证secret

config.json

{"auths":{"registry.paradeum.com":{"username":"cicd","password":"xxxxxxxx","auth":"xxxxxxxxxxx"}}}
kubectl create secret generic pld-cicd-secret \
  -n tekton-pipelines \
  --from-file=config.json=./config.json \
  --type=kubernetes.io/dockerconfig

项目代码集成webhook

创建 gitlab webhook 使用的 secret gitlab-webhook-secret.yaml

apiVersion: v1
kind: Secret
metadata:
  name: gitlab-webhook-secret
  namespace: tekton-pipelines
type: Opaque
stringData:
  secretToken: "xxxxxx"
kubectl apply -f gitlab-webhook-secret.yaml

gitlab 项目中

设置-集成 输入tekton webhook地址

https://tekton-trigger-gitlab.example.com
tekton webhook token

Add webhook

酌情修改并创建EventListerners

示例跟默认是只监听了 项目 Tag push event,Code Git Repo 打tag 会通知 EventListerner, EventListerner 再通过 Interceptors、TriggerBindings、TriggerTempates 生成对应PipelineRun

kubectl -n tekton-pipelines apply -f tekton-catalog/eventListeners/gitlab-EventListener.yaml

参考

https://github.com/paradeum-team/tekton-catalog/

https://www.qikqiak.com/post/create-ci-pipeline-with-tekton-1/

https://www.bianchengquan.com/article/511721.html

https://www.qikqiak.com/k8strain2/devops/tekton/overview/

https://github.com/tektoncd/dashboard/blob/main/docs/install.md

https://github.com/tektoncd/pipeline/blob/v0.31.0/docs/install.md

https://github.com/tektoncd/triggers/blob/v0.16.0/docs/install.md

https://github.com/tektoncd/operator

https://tekton.dev/docs/getting-started/

https://tekton.dev/docs/triggers/install/

https://github.com/IBM/ibm-garage-tekton-tasks

https://github.com/tektoncd/catalog/

https://kubernetes.io/zh/docs/tasks/debug-application-cluster/debug-running-pod/

http://hbchen.com/post/devops/2021-08-09-tekton-golang/

https://cloud.tencent.com/developer/article/1645052

https://www.51cto.com/article/668514.html

https://seankhliao.com/blog/12020-04-28-tekton-pipelines/

https://spex.top/archives/Kubernetes-cronjon-auto-cleanup-tekton-pipelinerun.html

Previous使用Tekton+Helm-Chart+ArgoCD构建GitOps CICDNext使用argocd-notifications通知Tekton触发api-test

Last updated 2 years ago

Was this helpful?

- 在Kubernetes集群的指定端口监听事件。指定一个或多个Triggers。

- EventListener检测到事件时会发生什么。一个Trigger 指定一个TriggerTemplate ,一个TriggerBinding,还有一个可选的Interceptor。

- 在 EventListener 检测到事件时实例化或执行的资源(例如 TaskRun 或 PipelineRun)指定蓝图。它暴露了可以在模板资源中的任何位置使用的参数。

- 从EventListeners 的 Trigger 定义中的提取扩展的变量数据,以及填充相应的TriggerTemplate中定义的参数。然后TriggerTemplate根据参数值填充相关的TaskRun或PipelineRun中的参数。

- TriggerBinding的集群范围版本,特别适合在集群中重用。

- Interceptor是在 TriggerBinding 之前运行的特定平台的catch-all事件处理器。 它允许您执行有效数据过滤、验证(使用秘密)、转换、定义和测试触发条件,以及实现其他有用的处理。 一旦事件数据通过Interceptor,它就会在您将有效数据传递给 TriggerBinding 之前进入Trigger。 您还可以使用Interceptor来修改关联Trigger的行为。

EventListener
Trigger
TriggerTemplate
TriggerBinding
ClusterTriggerBinding
Interceptor
Tekton工作流程图.png
pld-tekton-pipeline流程图