日韩性视频-久久久蜜桃-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完成应用发布初体验的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 少妇精品无码一区二区 | 日日操天天操夜夜操 | 九九热伊人 | 欧美黄片一区 | 成为性瘾网黄的yy对象后 | 7x7x7x人成影视 | 国产一区二区日韩 | 丰满人妻熟女aⅴ一区 | 欧美激情一区二区三区p站 欧美mv日韩mv国产网站app | 一区二区中文字幕 | 国产黄色一级网站 | 亚州欧美在线 | 久热精品免费视频 | 色婷婷激情av | 免费毛片一区二区三区 | 天天操天天插天天射 | 国产精品美女久久久久久 | 欧美丰满美乳xxⅹ高潮www | 欧美色欧美| 可以看黄色的网站 | 亚洲专区中文字幕 | 欧美在线国产 | 双性人妖互交localhost | 欧美3p在线观看 | 黑人毛片网站 | 黄色一级大片在线免费看产 | 中国黄色一级视频 | 中文字幕视频二区 | 男插女视频在线观看 | 久久艹国产精品 | 免费看的黄色 | 日韩国产在线播放 | 中文字幕久久一区 | 亚洲国产精品尤物yw在线观看 | 五级毛片| www.欧美一区二区三区 | 欧美激情免费视频 | 午夜写真片福利电影网 | 玖玖综合网 | 精品人妻久久久久久888不卡 | 欧美一区二区在线看 | 中文字幕在线视频不卡 | 香蕉视频免费看 | 白丝动漫美女 | 玉女心经是什么意思 | 激情中文网 | 国产成人精品二区三区亚瑟 | 超碰网站在线 | 天天操天天干天天爽 | 最新欧美日韩 | 精品视频导航 | 国产第一福利影院 | 夜夜欢视频 | 麻豆网站在线播放 | 熟妇高潮喷沈阳45熟妇高潮喷 | 日本激情久久 | www毛片com | 亚洲无吗在线观看 | 在线理论视频 | 亚洲av成人片色在线观看高潮 | 国产精品扒开做爽爽爽的视频 | 熟女少妇精品一区二区 | 亚洲日本韩国在线 | 久久色资源网 | 久久国产精彩视频 | 欧美午夜精品久久久久久人妖 | 日韩午夜在线视频 | 粗大挺进潘金莲身体在线播放 | 国产精品永久免费视频 | 日本黄大片在线观看 | 亚洲日本色图 | sese久久| 久久亚洲AV成人无码国产野外 | 看片一区 | 97久久人澡人人添人人爽 | 日韩欧美精品在线观看 | 嫩草视频一区二区三区 | 老司机福利院 | 曰韩一级片 | 波多野结衣在线 | 开心激情亚洲 | 麻豆视频网页 | 加勒比色综合 | 婷婷激情成人 | 潘金莲性xxxxhd | 51自拍视频 | 久久久精品麻豆 | 久久av不卡 | 欧美日韩亚洲国产综合 | 日本不卡免费 | 成人学院中文字幕 | 黄色在线免费播放 | 日韩中文字幕第一页 | 国产专区在线视频 | 精品久久久久久久久久久久久久久久久 | 女同vk | 日韩欧美综合久久 | 国产成人短视频在线观看 | 色88久久久久高潮综合影院 |