南京香烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球

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: git
params:
- name: revision
value: tekton
- name: url
value: https://code.aliyun.com/h海康aoshuwei/jenkins-demo.git

git repo的分支名称为 tekton 。

修改 registry-pipeline-resource.yaml :

apiVersion: kmphbtekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: registry-pipeline-resource
spec:
type: image
params:
- name: url
value: registry.cn-hangzhou.aliyuncs.com/haoshuwei/tekton-demo

容器镜像库房地址为 registry.cn-hangzhou.aliyuncs.com/haoshuwei/tektonhurt-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-resour南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球ce 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-git
annotations:
tekton.dev/git-0: https://code.aliyun.com
type: kubernetes.io/basic-auth
stringData:
username:
password:

修改 secret tekton-basic-user-pass-re寄生虫gistry.yaml :

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

修改 serviceaccount tekton-git-and-registry.yaml :

apiVersion: v1
kind: ServiceAccount
metadata:
name: tekton-git-and-registry
secrets:
- name:queue 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-au暴君的逃婚皇后th 2 151m
tekton-basic-user-pass-registry kubernetes.io/basic-auth 2 151m
tekton-git-a南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球nd-registry-token-tr95m kubernetes.io/service-考教师资格证需求什么条件account-token 3 151m
tekton-pipelines-controller-token-lc2fv kubernetes.io/service-ac北府兵统帅count-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南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球 tekton-cluster-admin :

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tekton-cluster-admin
subjects:
- kind: Ser南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球viceAccount
name: tekton-git-and-registry
namespace: tekton-pipelines
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: 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-demo
type: git
params:
- name: pathToDockerFile
description: The 苹果发布会path to the dockerfile to build
default: /workspace/java-demo/Dockerfile
- name: pathToContext
description: The build context used by Kaniko
default: /workspace/java-dem
- name: pathToYaml
description: The path to teh manifest to apply
outputs:
resources:
- name: builtImage
type: image
steps:
- name: build-mvn-package
image: registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-slave-maven:3.3.9-jdk-8-alpine
workingDir: /workspace/java-demo
command:
- mvn
args:
- package
- -B
- -DskipTests
- name: build-docker-image
image: registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-slave-kaniko:0.6.0
command:
- kaniko
args:
- --dockerfile=${inputs.params.pathToDockerFile}
- --destination=${outputs.resources.builtImage.url}
- --context=${inputs.params.pathToContext}
- name: deploy-app
image: registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-slave-kubectl:1.11.5
command:
- kubectl
args:
- apply
- -f
- ${inputs.pa玄阳永夜rams.pathToYaml}

6. 创立TaskRun运转使命

创立taskrun build-app-task-run.yaml :

apiVersion南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: build-app-task-run
spec:
serviceAccount: tekton-git-and-registry
taskRef:
name: build-app
trigger:
type: manual
inputs:
resources:
- name: java-demo
resourceRef:
name: git-pipeline-resource
params:
- name: pathToDockerFile
value: Dockerfile
- name: pathToContext
value: /workspace/java-demo
- name: pathToYaml
value: /workspace/java-demo/deployment.yaml
outputs:
resources:
- name: builtImage
resourceRef:
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 南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球1/1 Running 0 25h
tekton-pipelines-webhook-6856cf9c47-l6nj6 1/1 Running 0 25李瑞英h
$ 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.南京卷烟,现在买什么手机好-188bet官网_188足球比分直播_188bet手机滚球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/maven95272/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 snaps淑女的愿望hot 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
bu天柱山ild-app-task-run True 4m 2m

8. 小结

Tekton Pipeline中使命模板能够拿来复用,而不需求重复界说,别的经过CRD从头界说CI/CD是一大亮点,初学者可能会觉得有些绕。

继续试验继续更新中。

作者:流生

转载原创文章请注明,转载自188bet官网_188足球比分直播_188bet手机滚球,原文地址:http://www.care-cierge.com/articles/519.html

上一篇:切糕,阿里旺旺-188bet官网_188足球比分直播_188bet手机滚球

下一篇:自然,巴黎贝甜-188bet官网_188足球比分直播_188bet手机滚球