Tekton 克隆 git 仓库

Tekton 克隆 git仓库

介绍如何使用 Tektonhub 官方 git-clone task 克隆 github 上的源码到本地。
在这里插入图片描述

git-clone task yaml文件下载地址:https://hub.tekton.dev/tekton/task/git-clone

查看git-clone task yaml内容:
在这里插入图片描述
点击Install,选择一种方式创建 task
在这里插入图片描述

这里使用kubectl命令创建官方git-clone task

kubectl apply -f \
https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.9/git-clone.yaml

查看创建的task

$ kubectl get task
NAME             AGE
git-clone        4h32m

git-clone task创建后,可以通过taskRunpipelineRun进行调用。

非认证方式克隆

公开仓库无需配置认证即可直接克隆,这里以克隆 tekton pipeline 官方仓库为例。

创建一个简单的 taskRun 调用 git-clone task 来执行克隆任务,并向git-clone task传递一些自定义参数:

$ cat git-clone-taskrun.yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:generateName: git-clone-taskrun-
spec:taskRef:name: git-clonepodTemplate:hostNetwork: trueworkspaces:- name: outputemptyDir: {}params:- name: urlvalue: https://github.com/tektoncd/pipeline.git- name: revisionvalue: main- name: subdirectoryvalue: pipeline- name: httpProxyvalue: http://192.168.72.1:7890/- name: httpsProxyvalue: http://192.168.72.1:7890/- name: deleteExistingvalue: "true"- name: gitInitImage#value: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:latestvalue: dyrnq/tektoncd-pipeline-cmd-git-init:latest

所有的参数都是在git-clone task中已经预定义的,这里只需传参即可,参数说明:

  • workspaces:必选,为克隆的代码指定一个卷,这里作为演示,使用emptyDir类型的卷
  • url:指定克隆的git仓库地址
  • revision:指定克隆的git仓库分支
  • httpProxy:克隆github很有可能由于众所周知的原因失败,这里使用本地代理,可选
  • subdirectory:配置代码克隆到指定子目录下
  • gitInitImage:指定执行克隆任务的docker镜像,由于官方镜像无法访问,可以在dockerhub搜索可用镜像

应用yaml文件

kubectl create -f git-clone-taskrun.yaml

登录tekton dashboard 确认 taskRun 任务成功,说明已经成功克隆远程仓库到本地:
在这里插入图片描述

basic-auth 认证方式克隆

前置要求:

  • 已准备远程私有 GitHub 仓库
  • 用于访问远程存储库的 GitHub 个人访问令牌 (PAT)。

以basic-auth认证方式为例,注意该pipeline依然调用官方git-clone task执行克隆任务。

1. 创建secret和serviceaccount账号

设置创建 github-pat-secret 时使用的所需环境变量

export GITHUB_USERNAME='<your github.com username>'
export TEKTON_GITHUB_PAT='<your github.com username personal accesstoken>'

创建可以保存您的 GitHub.com 凭据的 Kubernetes secret:

cat >git-clone-sa.yaml<<EOF
apiVersion: v1
kind: Secret
metadata:name: basic-user-passannotations:tekton.dev/git-0: https://github.com
type: kubernetes.io/basic-auth
stringData:username: $GITHUB_USERNAMEpassword: $TEKTON_GITHUB_PAT
---
apiVersion: v1
kind: ServiceAccount
metadata:name: github-bot
secrets:- name: basic-user-pass
EOF

应用yaml文件

kubectl apply -f git-clone-sa.yaml

2. 创建Pipeline和PipelineRun

官方参考:
https://github.com/tektoncd/catalog/blob/main/task/git-clone/0.9/samples/git-clone-checking-out-a-branch.yaml

创建 git 克隆PipelinePipelineRun,该管道将从私有 GitHub 存储库克隆并查看代码中README文件内容:

$ cat git-clone-pipelinerun.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:name: cat-branch-readme
spec:params:- name: repo-urltype: stringdescription: The git repository URL to clone from.- name: branch-nametype: stringdescription: The git branch to clone.- name: httpProxytype: stringdescription: The httpProxy params.- name: httpsProxytype: stringdescription: The httpsProxy params.- name: gitInitImagetype: stringdescription: The gitInitImage params.workspaces:- name: shared-datatasks:- name: fetch-repotaskRef:name: git-cloneworkspaces:- name: outputworkspace: shared-dataparams:- name: urlvalue: $(params.repo-url)- name: revisionvalue: $(params.branch-name)- name: httpProxyvalue: $(params.httpProxy)- name: httpsProxyvalue: $(params.httpsProxy)- name: gitInitImagevalue: $(params.gitInitImage)- name: cat-readmerunAfter: ["fetch-repo"]workspaces:- name: sourceworkspace: shared-datataskSpec:workspaces:- name: sourcesteps:- image: zshusers/zsh:4.3.15script: |#!/usr/bin/env zshcat $(workspaces.source.path)/README.md
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:generateName: git-clone-checking-out-a-branch-
spec:serviceAccountName: github-botpipelineRef:name: cat-branch-readmepodTemplate:securityContext:fsGroup: 65532workspaces:- name: shared-datavolumeClaimTemplate:spec:accessModes:- ReadWriteOnceresources:requests:storage: 1Giparams:- name: repo-urlvalue: https://github.com/willzhang/test.git- name: branch-namevalue: main- name: httpProxyvalue: http://192.168.72.1:7890/- name: httpsProxyvalue: http://192.168.72.1:7890/- name: gitInitImagevalue: registry.cn-shenzhen.aliyuncs.com/cnmirror/git-init:latest

参数说明:

  • workspaces:必选,PipelineRun中定义了volumeClaimTemplate类型的workspaces,能够动态申请所需的持久卷,使用kubectl get storageclass命令,确认k8s集群有默认可用的storageclass资源可用,本示例输出为openebs-hostpath (default)
  • serviceAccountName:必选,注意PipelineRun中定义了serviceAccountName: github-bot参数,用于执行任务
  • url:指定克隆的私有github仓库地址
  • revision:指定克隆的git仓库分支
  • gitInitImage:指定执行克隆任务的docker镜像,由于官方镜像无法访问,可以在dockerhub搜索可用镜像

应用yaml文件

kubectl create -f git-clone-pipelinerun.yaml

登录dashbord确认克隆任务是否成功
在这里插入图片描述

ssh-auth认证方式

1. 创建secret和serviceaccount账号

任意一台linux机器,生成 SSH 密钥对

ssh-keygen -t rsa -b 4096 -f id_rsa -q -N ""

将公钥id_rsa.pub上传至github

root@kube001:~# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCXygldZ3tt0ovNLk44pQlJkFzglT71sAh2OcjfpbbloLtQ7JlPwakzW0jBqsK/dOIuqLmMm176diQauX32JrGL8BcOEj0Mp5OGWIwB+lmpMVqd2UMVaPhsfu0q4hmXYUdFiqm2MB68sUJ1/P5FsFYb6N1ZJ/Gi4oXwL9F6BTEzE0eDE6PVHwQRp+2NM7zBkHVx1XJCOzfX4+Xzu93xMid/Zp5Lfsafxx89PDznk6fUtqd53TjoMpxxxxxxx5SLAPVbE0lh8SzHEGXbNGzmQeN2waWLUAw6VaXhgDPApFZ2Id43Ug3+v9dEY79mvK4DZm81Kzsqb7bffWLB5uPr3P5r9bkh8rcajmkd44QU642XFmuGWiQ4MMz0SMerjLEoKn8kEBY6C17qPEcb4kpBWF3hLfGI2XYnxhtvjDSuYbzIvsGzG/lW4AdHyEQcjm4YyVTLPfvwO9mQeZqdsxdYHOrxkjEgGwpVFbe5cRt/1b0IZrBDAfX5+cZsViHWVmtdisbbPkTSQTngBphIhTp1LIVvDNmgYYGQ2I/jlwSHfSLuGi0pbgIdbV8RKmipmAkTNj/4aTLOnqnYyCc7BMTEJZzeIiFu1tkjZULlhwnILTpsYaQe9NDKEHl1Q== root@kube001

配置示例:https://github.com/settings/keys
在这里插入图片描述

获取私钥内容,复制到Secret中ssh-privatekey字段。

root@kube001:~# cat /root/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAgEAl8oJXWd7bdKLzS5OOKUJSZBc4JU+9bAIdjnI36W25aC7UOyZT8Gp
M1tIwarCv3TiLqi5jJte+nYkGrl99iaxi/AXDhI9DKeThliMAfpZqTFandlDFWj4bH7tKu
IZl2FHRYqptjAevLFCdfz+RbBWG+jdWSfxouKF8C/RegUxMxNHgxOj1R8EEaftjTO8wZB1
cdVyQjs31+Pl87vd8TInf2aeS3wrxzSSr40OwuxUeFIKwLQgoMdjmHnXzznThxcE0DdPPT
w855On1Laned046DKUDMMnpDSYgZuZ2WQFgV0zf96+UiwD1WxNJYfEsxxBl2zRs5kHjdsG
li1AMOlWl4YAzwKRWdiHeN1IN/r/XRGO/ZryuA2ZvNSs7Km+2331iwebj69z+a/W5IfK3G
o5pHeOEFOuNlxZrhlokODDM9EjHq4yxKCp/JBAWOgte6jxHG+JKQVh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RGcBtGTv4Hwj0LoRvt+Ts4cx8GNV/dZFWnNVJEvCR9BvVoeiATHA3
0igzO6c69/+K5RRumifMg4xmg5YOvuW8RnCZ7vUmBhKSEFRW3e/6u2UftHgEhQ2tAS+AeH
RnJdY3AWGL3eXd5UzDYEt5DQBnTOHVUlM7bOH3o2GhW814Tha7SdS4EYUNY/4tTml5N+r3
aDVw0IJuOxAF8AAAEBANAOE+4RpubP8DDAG+rRoYQNrtiYAI/Rdu9CR+wkjI4+hrOmnCJu
VEae24TmlNLtWo2GGG0ZE8+zXx+cKRdYj1baS4rDFP+iW9AnxaoAdWp8mW/xJMXSz7wjZk
5VRA5ivtZDLpgyicBwf1PYqHOIGrNedCmmtHDzhV0ERyt7D/Prql3IWVgvz09RdhD3pXcO
DkE4TLs5RMSA2Erh6OddRIwsSM07tXLwalQpuyuoGNMyK/ZidugfQesIEZPwb7cPi35eSQ
5lT2EpjfPsxBSWisUA3U1AIVBhejpK58ZHw6TH/AZEXNFGdENKNwAMV+FR3Rn3V7NTH/y7
SzPzjmCldksAAAAMcm9vdEBrdWJlMDAxAQIDBAUGBw==
-----END OPENSSH PRIVATE KEY-----

创建secret和serviceaccount

$ cat git-clone-sa.yaml
apiVersion: v1
kind: Secret
metadata:name: ssh-keyannotations:tekton.dev/git-0: github.com
type: kubernetes.io/ssh-auth
stringData:ssh-privatekey: |-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcnNhAAAAAwEAAQAAAgEAl8oJXWd7bdKLzS5OOKUJSZBc4JU+9bAIdjnI36W25aC7UOyZT8GpM1tIwarCv3TiLqi5jJte+nYkGrl99iaxi/AXDhI9DKeThliMAfpZqTFandlDFWj4bH7tKuIZl2FHRYqptjAevLFCdfz+RbBWG+jdWSfxouKF8C/RegUxMxNHgxOj1R8EEaftjTO8wZB1cdVyQjs31+Pl87vd8TInf2aeS3wrxzSSr40OwuxU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B8xBzWOSGt9A7K/ypXKnnlWy9NGXnMG+VZir05NNs2nzGvrUAAAEBALrEooyYqrXZtksRhMoGQBUoKg3V7z4FceGVLhwe0zuP18KLA36IPHkSwuP5radGpaB4qXGj/X5lZIwo1FaVy8mYfhh2rApvhbedo3i+e+ngWwP1kNSETlorl3a3Oy3onowTW08YuRGcBtGTv4Hwj0LoRvt+Ts4cx8GNV/dZFWnNVJEvCR9BvVoeiATHA30igzO6c69/+K5RRumifMg4xmg5YOvuW8RnCZ7vUmBhKSEFRW3e/6u2UftHgEhQ2tAS+AeHRnJdY3AWGL3eXd5UzDYEt5DQBnTOHVUlM7bOH3o2GhW814Tha7SdS4EYUNY/4tTml5N+r3aDVw0IJuOxAF8AAAEBANAOE+4RpubP8DDAG+rRoYQNrtiYAI/Rdu9CR+wkjI4+hrOmnCJuVEae24TmlNLtWo2GGG0ZE8+zXx+cKRdYj1baS4rDFP+iW9AnxaoAdWp8mW/xJMXSz7wjZk5VRA5ivtZDLpgyicBwf1PYqHOIGrNedCmmtHDzhV0ERyt7D/Prql3IWVgvz09RdhD3pXcODkE4TLs5RMSA2Erh6OddRIwsSM07tXLwalQpuyuoGNMyK/ZidugfQesIEZPwb7cPi35eSQ5lT2EpjfPsxBSWisUA3U1AIVBhejpK58ZHw6TH/AZEXNFGdENKNwAMV+FR3Rn3V7NTH/y7SzPzjmCldksAAAAMcm9vdEBrdWJlMDAxAQIDBAUGBw==-----END OPENSSH PRIVATE KEY-----
---
apiVersion: v1
kind: ServiceAccount
metadata:name: github-bot
secrets:- name: ssh-key

应用yaml文件

kubectl apply -f git-clone-sa.yaml

2.创建Pipeline和PipelineRun

创建 git 克隆PipelineRun,该管道将从私有 GitHub 存储库克隆并简单列出内容:

$ cat git-clone-pipelinerun.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:name: cat-branch-readme
spec:params:- name: repo-urltype: stringdescription: The git repository URL to clone from.- name: branch-nametype: stringdescription: The git branch to clone.- name: gitInitImagetype: stringdescription: The gitInitImage params.workspaces:- name: shared-datatasks:- name: fetch-repotaskRef:name: git-cloneworkspaces:- name: outputworkspace: shared-dataparams:- name: urlvalue: $(params.repo-url)- name: revisionvalue: $(params.branch-name)- name: gitInitImagevalue: $(params.gitInitImage)- name: cat-readmerunAfter: ["fetch-repo"]workspaces:- name: sourceworkspace: shared-datataskSpec:workspaces:- name: sourcesteps:- image: zshusers/zsh:4.3.15script: |#!/usr/bin/env zshcat $(workspaces.source.path)/README.md
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:generateName: git-clone-checking-out-a-branch-
spec:serviceAccountName: github-botpipelineRef:name: cat-branch-readmepodTemplate:securityContext:fsGroup: 65532workspaces:- name: shared-datavolumeClaimTemplate:spec:accessModes:- ReadWriteOnceresources:requests:storage: 1Giparams:- name: repo-urlvalue: git@github.com:willzhang/test.git- name: branch-namevalue: main- name: gitInitImagevalue: registry.cn-shenzhen.aliyuncs.com/cnmirror/git-init:latest

参数说明:

  • 注意修改克隆URL地址格式为:git@github.com:willzhang/test.git
  • 去除httproxy部分,以免影响ssh认证

应用yaml文件

kubectl create -f git-clone-pipelinerun.yaml

登录dashbord 查看参数信息,确认克隆任务是否成功
在这里插入图片描述

显示 git 仓库 README 信息
在这里插入图片描述

参考:https://redhat-scholars.github.io/tekton-tutorial/tekton-tutorial/private_reg_repos.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/277915.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

5G工业网关视频传输应用

随着科技的不断进步&#xff0c;5G网络技术已经成为了当前最热门的话题之一。而其中一个引人注目的领域就是5G视频传输和5G工业网关应用。在传统网络通信中&#xff0c;由于带宽和延迟的限制&#xff0c;视频传输常常受到限制&#xff0c;而工业网关应用也存在着链路不稳定、数…

HTML基础标签

但实际上无论声明为中文还是英文都可以写&#xff0c;中文/英文 主要是浏览器在进行调用翻译功能的时候&#xff0c;会按照声明的语言来进行翻译。 标签语义&#xff1a; 标签的属性一般都是在第一个标签中定义该标签效果所拥有的属性。 即标签的作用是什么 <>标签功能…

十四、YARN核心架构

1、目标 &#xff08;1&#xff09;掌握YARN的运行角色和角色之间的关系 &#xff08;2&#xff09;理解使用容器做资源分配和隔离 2、核心架构 &#xff08;1&#xff09;和HDFS架构的对比 HDFS架构&#xff1a; YARN架构&#xff1a;&#xff08;主从模式&#xff09; &…

随机森林1(了解整体知识架构)

很多人想学习或者了解随机森林&#xff0c;查到的资料都是先讲熵&#xff0c;再讲决策树&#xff0c;然后再讲随机森林&#xff0c;前面坚持不下来或者一个地方没理解透彻&#xff0c;导致无法向下学习&#xff0c;而且公式讲解不够清晰&#xff0c;例子不够详细&#xff0c;很…

Python多态原理及实现

对于弱类型的语言来说&#xff0c;变量并没有声明类型&#xff0c;因此同一个变量完全可以在不同的时间引用不同的对象。当同一个变量在调用同一个方法时&#xff0c;完全可能呈现出多种行为&#xff08;具体呈现出哪种行为由该变量所引用的对象来决定&#xff09;&#xff0c;…

持续集成交付CICD:Jenkins使用基于SaltStack的CD流水线部署前后端应用

目录 一、实验 1.Jenkins使用基于SaltStack的CD流水线部署后端应用 2.Jenkins使用基于SaltStack的CD流水线部署前端应用 一、实验 1.Jenkins使用基于SaltStack的CD流水线部署后端应用 &#xff08;1&#xff09;GitLab添加Token (2)Jenkins添加凭据 &#xff08;3&#xf…

c++面经总结

C基础语法 C和c的区别 c中new和delete是对内存分配的运算符&#xff0c;取代了c中的malloc和free 标准c中的字符串类取代了标准c函数库头文件中的字符数组处理函数(c中没有字符串类型). 在c中&#xff0c;允许有相同的函数名&#xff0c;不过他们的参数类型不能完全相同&…

如何连接到 Azure SQL 数据库(下)

在《如何连接到 Azure SQL 数据库&#xff08;上&#xff09;》中&#xff0c;我们已经了解到了以下内容↓↓↓ 开始之前&#xff1a;Azure 连接凭据和防火墙 如何检索 Azure 连接凭据如何配置服务器防火墙使用 SQL Server Management Studio 连接到 Azure使用 dbForge Studio…

(1)(1.8) MSP(MultiWii 串行协议)(4.1 版)

文章目录 前言 1 协议概述 2 配置 3 参数说明 前言 ArduPilot 支持 MSP 协议&#xff0c;可通过任何串行端口进行遥测和传感器。这允许 ArduPilot 将其遥测数据发送到 MSP 兼容设备&#xff08;如大疆护目镜&#xff09;&#xff0c;用于屏幕显示&#xff08;OSD&#xff…

HarmonyOS 应用开发 —— ArkTS 可复用代码块梳理

目录 ArkTS 复用代码块弹窗提醒网络请求消息通知如何给任意组件添加 multiState&#xff1f;如何给 ListItem 添加删除按钮&#xff0c; ArkTS 复用代码块 记录一下自己这几天学习成果&#xff0c;我发官方文档很全&#xff0c;都是有时候查找起来不是很容易&#xff0c;因此总…

Go delve调试工具的简单应用

Delve是个啥 Delve is a debugger for the Go programming language. The goal of the project is to provide a simple, full featured debugging tool for Go. Delve should be easy to invoke and easy to use. Chances are if you’re using a debugger, things aren’t go…

BearPi Std 板从入门到放弃 - 先天神魂篇(7)(RT-Thread 定时器-软件定时器)

简介 RT-Thread 软件定时器的简单使用步骤 创建项目 参考 BearPi RT-Thread项目创建 定时器管理接口 定时器时钟节拍 定时器管理相关函数 定时器类型 #define RT_TIMER_FLAG_ONE_SHOT 0x0 //一次性计时器 #define RT_TIMER_FLAG_PERIODIC 0x2 // 周期性定时器 #…