日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

阿里云Kubernetes服务上使用Tekton完成应用发布初体验

發布時間:2024/8/23 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 阿里云Kubernetes服务上使用Tekton完成应用发布初体验 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Tekton 是一個功能強大且靈活的 Kubernetes 原生開源框架,用于創建持續集成和交付(CI/CD)系統。通過抽象底層實現細節,用戶可以跨多云平臺和本地系統進行構建、測試和部署。

本文是基于阿里云Kubernetes服務部署Tekton Pipeline,并使用它完成源碼拉取、應用打包、鏡像推送和應用部署的實踐過程。

Tekton Pipeline中有5類對象,核心理念是通過定義yaml定義構建過程.構建任務的狀態存放在status字段中。

其中5類對象分別是:PipelineResouce、Task、TaskRun、Pipeline、PipelineRun。

Task是單個任務的構建過程,需要通過定義TaskRun任務去運行Task。

Pipeline包含多個Task,并在此基礎上定義input和output,input和output以PipelineResource作為交付。

PipelineResource是可用于input和output的對象集合。

同樣地,需要定義PipelineRun才會運行Pipeline。

1. 在阿里云Kubernetes集群中部署Tekton Pipeline

kubectl apply --filename https://storage.googleapis.com/tekton-releases/latest/release.yaml

查看Tekton Pipelines組件是否運行正常:

$ kubectl -n tekton-pipelines get po NAME READY STATUS RESTARTS AGE tekton-pipelines-controller-6bcd7ff5d6-vzmrh 1/1 Running 0 25h tekton-pipelines-webhook-6856cf9c47-l6nj6 1/1 Running 0 25h

2. 創建Git Resource, Registry Resource

編輯?git-pipeline-resource.yaml?:

apiVersion: tekton.dev/v1alpha1 kind: PipelineResource metadata:name: git-pipeline-resource spec:type: gitparams:- name: revisionvalue: tekton- name: urlvalue: https://code.aliyun.com/haoshuwei/jenkins-demo.git

git repo的分支名稱為?tekton?。

編輯?registry-pipeline-resource.yaml?:

apiVersion: tekton.dev/v1alpha1 kind: PipelineResource metadata:name: registry-pipeline-resource spec:type: imageparams:- name: urlvalue: registry.cn-hangzhou.aliyuncs.com/haoshuwei/tekton-demo

容器鏡像倉庫地址為?registry.cn-hangzhou.aliyuncs.com/haoshuwei/tekton-demo, 標簽為?latest

創建pipeline resource:

$ kubectl -n tekton-pipelines create -f git-pipeline-resource.yaml $ kubectl -n tekton-pipelines create -f registry-pipeline-resource.yaml

查看已創建的pipeline resource資源:

$ kubectl -n tekton-pipelines get PipelineResource NAME AGE git-pipeline-resource 2h registry-pipeline-resource 2h

3. 創建Git Repo/Docker Registry Authentication

拉取私有git源碼項目需要配置使用Git Repo Authentication;拉取和推送docker鏡像需要配置Docker Registry Authentication。在Tekton Pipeline中,Git Repo/Docker Registry Authentication會被定義成ServiceAccount來使用。

編輯 secret?tekton-basic-user-pass-git.yaml?:

apiVersion: v1 kind: Secret metadata:name: tekton-basic-user-pass-gitannotations:tekton.dev/git-0: https://code.aliyun.com type: kubernetes.io/basic-auth stringData:username: <cleartext non-encoded>password: <cleartext non-encoded>

編輯 secret?tekton-basic-user-pass-registry.yaml?:

apiVersion: v1 kind: Secret metadata:name: tekton-basic-user-pass-registryannotations:tekton.dev/docker-0: https://registry.cn-hangzhou.aliyuncs.com type: kubernetes.io/basic-auth stringData:username: <cleartext non-encoded>password: <cleartext non-encoded>

編輯 serviceaccount?tekton-git-and-registry.yaml?:

apiVersion: v1 kind: ServiceAccount metadata:name: tekton-git-and-registry secrets:- name: tekton-basic-user-pass-git- name: tekton-basic-user-pass-registry

創建serviceaccount:

$ kubectl -n tekton-pipelines create -f tekton-basic-user-pass-git.yaml $ kubectl -n tekton-pipelines create -f tekton-basic-user-pass-registry.yaml $ kubectl -n tekton-pipelines create -f tekton-git-and-registry.yaml

查看secret以及sa:

$ kubectl -n tekton-pipelines get secret NAME TYPE DATA AGE default-token-pwncj kubernetes.io/service-account-token 3 25h tekton-basic-user-pass-git kubernetes.io/basic-auth 2 151m tekton-basic-user-pass-registry kubernetes.io/basic-auth 2 151m tekton-git-and-registry-token-tr95m kubernetes.io/service-account-token 3 151m tekton-pipelines-controller-token-lc2fv kubernetes.io/service-account-token 3 25h webhook-certs Opaque 3 25h $ kubectl -n tekton-pipelines get sa NAME SECRETS AGE default 1 25h tekton-git-and-registry 3 152m tekton-pipelines-controller 1 25h

4. 配置serviceaccount tekton-git-and-registry獲取命名空間tekton-pipelines的管理權限用于部署應用

創建ClusterRoleBinding?tekton-cluster-admin?:

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata:name: tekton-cluster-admin subjects:- kind: ServiceAccountname: tekton-git-and-registrynamespace: tekton-pipelines roleRef:kind: ClusterRolename: cluster-adminapiGroup: rbac.authorization.k8s.io

5. 創建一個Task

創建task?build-app.yaml?:

apiVersion: tekton.dev/v1alpha1 kind: Task metadata:name: build-app spec:inputs:resources:- name: java-demotype: gitparams:- name: pathToDockerFiledescription: The path to the dockerfile to builddefault: /workspace/java-demo/Dockerfile- name: pathToContextdescription: The build context used by Kanikodefault: /workspace/java-dem- name: pathToYamldescription: The path to teh manifest to applyoutputs:resources:- name: builtImagetype: imagesteps:- name: build-mvn-packageimage: registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-slave-maven:3.3.9-jdk-8-alpineworkingDir: /workspace/java-democommand:- mvnargs:- package- -B- -DskipTests- name: build-docker-imageimage: registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-slave-kaniko:0.6.0command:- kanikoargs:- --dockerfile=${inputs.params.pathToDockerFile}- --destination=${outputs.resources.builtImage.url}- --context=${inputs.params.pathToContext}- name: deploy-appimage: registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-slave-kubectl:1.11.5command:- kubectlargs:- apply- -f- ${inputs.params.pathToYaml}

6. 創建TaskRun運行任務

創建taskrun?build-app-task-run.yaml?:

apiVersion: tekton.dev/v1alpha1 kind: TaskRun metadata:name: build-app-task-run spec:serviceAccount: tekton-git-and-registrytaskRef:name: build-apptrigger:type: manualinputs:resources:- name: java-demoresourceRef:name: git-pipeline-resourceparams:- name: pathToDockerFilevalue: Dockerfile- name: pathToContextvalue: /workspace/java-demo- name: pathToYamlvalue: /workspace/java-demo/deployment.yamloutputs:resources:- name: builtImageresourceRef:name: registry-pipeline-resource

7. 查看構建狀態以及日志

查看taskrun狀態:

$ kubectl -n tekton-pipelines get taskrun NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME build-app-task-run Unknown Pending 4s

查看構建日志:

$ kubectl -n tekton-pipelines get po NAME READY STATUS RESTARTS AGE build-app-task-run-pod-b8f890 3/5 Running 0 75s tekton-pipelines-controller-6bcd7ff5d6-vzmrh 1/1 Running 0 25h tekton-pipelines-webhook-6856cf9c47-l6nj6 1/1 Running 0 25h $ kubectl -n tekton-pipelines logs -f build-app-task-run-pod-b8f890 Error from server (BadRequest): a container name must be specified for pod build-app-task-run-pod-b8f890, choose one of: [build-step-git-source-git-pipeline-resource-77l5v build-step-build-mvn-package build-step-build-docker-image build-step-deploy-app nop] or one of the init containers: [build-step-credential-initializer-8dsnm build-step-place-tools]

mvn build的日志:

$ kubectl -n tekton-pipelines logs -f build-app-task-run-pod-b8f890 -c build-step-build-mvn-package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building jenkins-demo-web 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom [INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom (8 KB at 7.3 KB/sec) [INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom [INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom (9 KB at 26.7 KB/sec) [INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/22/maven-parent-22.pom [INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/22/maven-parent-22.pom (30 KB at 61.3 KB/sec) [INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/11/apache-11.pom [INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/11/apache-11.pom (15 KB at 45.3 KB/sec) ....

docker build的日志:

$ kubectl -n tekton-pipelines logs -f build-app-task-run-pod-b8f890 -c build-step-build-docker-image INFO[0000] Downloading base image tomcat 2019/05/06 11:58:46 No matching credentials were found, falling back on anonymous INFO[0003] Taking snapshot of full filesystem... INFO[0003] Skipping paths under /builder/home, as it is a whitelisted directory INFO[0003] Skipping paths under /builder/tools, as it is a whitelisted directory INFO[0003] Skipping paths under /dev, as it is a whitelisted directory INFO[0003] Skipping paths under /kaniko, as it is a whitelisted directory INFO[0003] Skipping paths under /proc, as it is a whitelisted directory INFO[0003] Skipping paths under /run/secrets/kubernetes.io/serviceaccount, as it is a whitelisted directory INFO[0003] Skipping paths under /sys, as it is a whitelisted directory INFO[0003] Skipping paths under /var/run, as it is a whitelisted directory INFO[0003] Skipping paths under /workspace, as it is a whitelisted directory INFO[0003] Using files from context: [/workspace/java-demo/target/demo.war] INFO[0003] ADD target/demo.war /usr/local/tomcat/webapps/demo.war INFO[0003] Taking snapshot of files... ...

app-deploy的日志:

$ kubectl -n tekton-pipelines logs -f build-app-task-run-pod-637855 -c build-step-deploy-app deployment.extensions/jenkins-java-demo created service/jenkins-java-demo created

taskrun的完成狀態為True則構建部署過程完成:

$ kubectl -n tekton-pipelines get taskrun NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME build-app-task-run True 4m 2m

8. 小結

Tekton Pipeline中任務模板可以拿來復用,而不需要重復定義,另外通過CRD重新定義CI/CD是一大亮點,初學者可能會覺得有些繞。

持續實驗持續更新中。


原文鏈接
本文為云棲社區原創內容,未經允許不得轉載。

總結

以上是生活随笔為你收集整理的阿里云Kubernetes服务上使用Tekton完成应用发布初体验的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 在线一区av | 九九热这里都是精品 | 国产一区精品无码 | 丨国产丨调教丨91丨 | 片黄在线观看 | 欧美高清hd19 | 就爱啪啪网 | 免费在线观看黄视频 | 中文字幕一区二区在线视频 | 波多野吉衣在线视频 | jizjiz中国少妇高潮水多 | av片观看 | 日韩视频免费播放 | 未满十八岁禁止进入 | 97在线播放免费观看 | 99国产精品国产免费观看 | zjzjzjzjzj亚洲女人 | 一本色道久久亚洲综合精品蜜桃 | 成年人黄色片网站 | 日韩国产一区二区三区 | 国产黄色片在线播放 | 麻豆传媒视频入口 | 一区二区日韩欧美 | 在线观看毛片网站 | 少妇高潮一区二区三区69 | 精品国产a线一区二区三区东京热 | 在线观看小视频 | 欧美三级三级三级爽爽爽 | 97性视频| 成人动漫免费观看 | 99热精品免费 | 丰满双乳秘书被老板狂揉捏 | 国产伦精品一区二区三区精品 | 深夜视频在线观看 | 免费欧美| 久久久久久黄色片 | 国产精品福利在线 | 一级性生活黄色片 | 99精品在线观看视频 | 久久久久久久女国产乱让韩 | 国产午夜精品福利 | 国产午夜精品福利视频 | 亚洲精品乱码久久久久久麻豆不卡 | 久久精工是国产品牌吗 | 人妻丝袜一区二区三区 | 简单av网| 色婷婷成人| 黄色动漫在线免费观看 | 国产亚洲精品成人av在线 | 欧美一区二区三区电影 | 99av国产精品欲麻豆 | 亚洲欧美在线综合 | 国产精品免费久久 | 99久久99久久精品国产片果冻 | 国产日韩欧美精品一区 | 在线免费看黄色 | 久久久久久免费视频 | 性爱视频日本 | www四虎精品视频免费网站 | 天堂av网在线 | 欧美日韩欧美 | 成人免费视频网站在线观看 | 久久亚洲av午夜福利精品一区 | 成人v精品蜜桃久一区 | 麻豆精品网站 | 久久久久无码国产精品不卡 | 麻豆专区 | 国产一级av毛片 | 欧美区国产区 | 国产精品又黄又爽又色无遮挡 | 岛国av噜噜噜久久久狠狠av | 国产欧美一区二区三区鸳鸯浴 | 国产麻豆午夜三级精品 | 99色图 | 亚洲第一成人网站 | 可以免费看的黄色 | 嫩草嫩草嫩草嫩草 | 成人夜晚看av | 日韩在线观看精品 | wwwxx在线| 国产精品久久久久久亚洲伦 | 一区二区三区 中文字幕 | 91在线观看免费高清完整版在线观看 | av观看网站 | 在线观看国产麻豆 | 草比视频在线观看 | 午夜在线一区二区三区 | 国产日韩中文字幕 | 欧美午夜精品久久久久久人妖 | 91在线观看喷潮 | 久久久久久亚洲精品中文字幕 | 男人深夜影院 | 91精品一区二区三区综合在线爱 | 国产av一区精品 | 国产精品黄色在线观看 | 黄色靠逼视频 | 国内福利视频 | av在线电影网站 | 男女av |