Tekton安装与入门


Tekton CI/CD 管道
#### 安装Tekton

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

监控安装:

kubectl get pods --namespace tekton-pipelines --watch

查看pod状态

[root@k8s-master1 tekton]# kubectl get pods -n tekton-pipelines
NAME                                           READY   STATUS    RESTARTS   AGE
tekton-pipelines-controller-54c7997dc7-nw4hp   1/1     Running   0          26s
tekton-pipelines-webhook-59987d7bfc-nrbvc      1/1     Running   0          26s

创建并运行基本任务

创建一个hello-world.yaml

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello
spec:
  steps:
    - name: echo
      image: alpine
      script:  |
        #!/bin/sh
        echo "Helllo World"

将更改应用到您的群集:

 $ kubectl apply  -f hello-world.yaml 
task.tekton.dev/hello created

要运行此任务,必须使用实例化它TaskRun。创建另一个名为hello-world-run.yaml包含以下内容:

cat  hello-world-run.yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: hello-task-run
spec:
  taskRef:
    name: hello

将更改应用到您的集群:

kubectl apply -f hello-world-run.yaml 
taskrun.tekton.dev/hello-task-run created

查看task状态

True下面的SUCCEEDED确认TaskRun已无错误地完成。

[root@k8s-master1 step1]# kubectl get taskrun hello-task-run
NAME             SUCCEEDED   REASON    STARTTIME   COMPLETIONTIME
hello-task-run   Unknown     Pending   13s         
[root@k8s-master1 step1]# kubectl get taskrun hello-task-run
NAME             SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
hello-task-run   True        Succeeded   26s         18m

查看日志

[root@k8s-master1 step1]# kubectl logs --selector=tekton.dev/taskRun=hello-task-run
Defaulted container "step-echo" out of: step-echo, prepare (init), place-scripts (init)
Helllo World

输出显示消息:

Hello World

Author: 千里之行
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source 千里之行 !
  TOC