Knative - Tekton 部署及快速入门 【十五】

Knative三个组件:
    Serving
    Eventing
    Build --> Tekton
        CI Pipeline的基础设施

        Stage:
            Build
            Test
            Deliver


            Deploy --> 部署(风险)
                金丝雀部署
                滚动部署
                蓝绿部署
                ……

                与流量治理策略协同

                    v1: 10 pods
                    v2: 2 pods

                与监控系统协同
                    200 > 95%

                独立的解决方案:Kubernetes
                    ArgoCD, Argo Rollouts

                    FluxCD


    控制器模式:
        控制回路:control loop
            Controller
                Spec --> Status

            API Server
                .spec:用户定义
                .status:则控制器根据实际的运行结果生成填充

    Weave Cloud发明的新的DevOps方法:
        把CD Pipeline,而且要基于专用的COnfig Repo实现;

    OAM:

GitOPs:
    Push Pipeline
        触发点:代码仓库
        CI/CD/CD

    Pull Pipeline
        触发点:
            CI Pipeline代码仓库

        触发点:
            Config Repo更新
                Deploy OPerator:用户期望状态 

    可用选择和实现:
        Jenkins 
            + Flux + Flagger
            + ArgoCD + Argo Rollouts

        Tekton
             + Flux + Flagger
            + ArgoCD + Argo Rollouts

    脱胎于Knattive Build,Tekton(CRD+Controller)
        
        Kubernetes的Extension

        API接口:
            CRD:
                Pipelines 
                Tasks (Steps)

                    Parameters:
                        Input Resources: 
                        Output Resources:

                PipelineRuns
                TaskRuns

            kubectl apply -f ...

系统组件

#Tekton PipelinesTekton
    最核心的组件,由一组CRD和相关的Operator、 Webhook共同组成需要部署并运行于Kubernetes集群之上,作为Kubernetes的集群扩展
#Tekton Triggers
    触发器,可触发Pipeline的实例化;可选组件;
#Tekton CLI
    命令行客户端工具,用于与Tekton进行交百,可选组件;
#Tekton Dashboard
    Tekton Pipelines的基于Web的图形界面;可选组件;
#Tekton Catalog
    由社区贡献的Tekton构建块 (building blocks,例如Tasks和Pipelines等),用户可直接使用
#Tekton Hub
    用于访问Catalog的图形界面,基于WebTekton Operator

Tekton 部署

1.Getting started with Tasks

部署文档:https://tekton.dev/docs/getting-started/tasks/

#Create a Kubernetes cluster
[root@xianchaomaster1 ~]# kubectl cluster-info
Kubernetes control plane is running at https://192.168.40.180:6443
CoreDNS is running at https://192.168.40.180:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

#Install Tekton Pipelines
【release文件中源代码仓库地址】
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/events:v0.49.0@sha256:968999c9f4ba1003725a9455f9a3a2cba36766768e4f1ee40010fafa765f450d
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.49.0@sha256:cde0654aab99ea19e030eb269f28deba6cc550910586ee7a832cae3ee63ea565
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/resolvers:v0.49.0@sha256:78ddd51c8dda6e1e8aa0d3ee65f49f76c9f7bde8235320ae81db2d9ed0e6ce32
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook:v0.49.0@sha256:df3be59025cc59dbcc639710a77f922f07b778de49616b59bb5343fbf7cc8b79
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint:v0.49.0@sha256:0e43b6ae2d517df85aac356b411fe291057c2f12aef3a949be961cfc1d31c158
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/nop:v0.49.0@sha256:91eb79439e756e557259da3c0823f29483863ed6b8a409da664f879279c95d59
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/sidecarlogresults:v0.49.0@sha256:4055c213dbb60722432c87b80fb8e52ed6409e6cbb83e62ebb53f0c6d33056f6
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/workingdirinit:v0.49.0@sha256:643cf8dbc46fbbfb9f333628c33bbdfb76d11b5005c2aaed28abdc20f739d0b8
【替换release.yaml 域名】
#          image: gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook:v0.49.0@sha256:df3be59025cc59dbcc639710a77f922f07b778de49616b59bb5343fbf7cc8b79
k8s.gcr.io ---> lank8s.cn
gcr.io --> gcr.lank8s.cn 共八处
【下载镜像】
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/events:v0.49.0@sha256:968999c9f4ba1003725a9455f9a3a2cba36766768e4f1ee40010fafa765f450d && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.49.0@sha256:cde0654aab99ea19e030eb269f28deba6cc550910586ee7a832cae3ee63ea565 && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/resolvers:v0.49.0@sha256:78ddd51c8dda6e1e8aa0d3ee65f49f76c9f7bde8235320ae81db2d9ed0e6ce32 && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook:v0.49.0@sha256:df3be59025cc59dbcc639710a77f922f07b778de49616b59bb5343fbf7cc8b79 && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint:v0.49.0@sha256:0e43b6ae2d517df85aac356b411fe291057c2f12aef3a949be961cfc1d31c158 && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/nop:v0.49.0@sha256:91eb79439e756e557259da3c0823f29483863ed6b8a409da664f879279c95d59 && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/sidecarlogresults:v0.49.0@sha256:4055c213dbb60722432c87b80fb8e52ed6409e6cbb83e62ebb53f0c6d33056f6 && \
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/workingdirinit:v0.49.0@sha256:643cf8dbc46fbbfb9f333628c33bbdfb76d11b5005c2aaed28abdc20f739d0b8

如果两台node 都要部署容器
[root@xksnode1 ~]# crictl images list | grep tekton
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/controller          <none>              38ff0fdda9b88       52.5MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint          <none>              9f18791c4ffbd       39.5MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/events              <none>              b4d4f14dcd74c       43MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/nop                 <none>              87c996dd92400       14.1MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/resolvers           <none>              649e1a0523be3       50.1MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/sidecarlogresults   <none>              8e11b6b15959e       27.2MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook             <none>              d20f98bebbfec       43MB
gcr.lank8s.cn/tekton-releases/github.com/tektoncd/pipeline/cmd/workingdirinit      <none>              22deeaf383c46       1.86MB

【应用文件】
[root@xksmaster1 Knative]# kubectl apply -f release.yaml
namespace/tekton-pipelines created
clusterrole.rbac.authorization.k8s.io/tekton-pipelines-controller-cluster-access created
clusterrole.rbac.authorization.k8s.io/tekton-pipelines-controller-tenant-access created
clusterrole.rbac.authorization.k8s.io/tekton-pipelines-webhook-cluster-access created
clusterrole.rbac.authorization.k8s.io/tekton-events-controller-cluster-access created
role.rbac.authorization.k8s.io/tekton-pipelines-controller created
role.rbac.authorization.k8s.io/tekton-pipelines-webhook created
role.rbac.authorization.k8s.io/tekton-pipelines-leader-election created
role.rbac.authorization.k8s.io/tekton-pipelines-info created
serviceaccount/tekton-pipelines-controller created
serviceaccount/tekton-pipelines-webhook created
serviceaccount/tekton-events-controller created
clusterrolebinding.rbac.authorization.k8s.io/tekton-pipelines-controller-cluster-access created
clusterrolebinding.rbac.authorization.k8s.io/tekton-pipelines-controller-tenant-access created
clusterrolebinding.rbac.authorization.k8s.io/tekton-pipelines-webhook-cluster-access created
clusterrolebinding.rbac.authorization.k8s.io/tekton-events-controller-cluster-access created
rolebinding.rbac.authorization.k8s.io/tekton-pipelines-controller created
rolebinding.rbac.authorization.k8s.io/tekton-pipelines-webhook created
rolebinding.rbac.authorization.k8s.io/tekton-pipelines-controller-leaderelection created
rolebinding.rbac.authorization.k8s.io/tekton-pipelines-webhook-leaderelection created
rolebinding.rbac.authorization.k8s.io/tekton-pipelines-info created
rolebinding.rbac.authorization.k8s.io/tekton-events-controller created
rolebinding.rbac.authorization.k8s.io/tekton-events-controller-leaderelection created
customresourcedefinition.apiextensions.k8s.io/clustertasks.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/customruns.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/pipelines.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/pipelineruns.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/resolutionrequests.resolution.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/tasks.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/taskruns.tekton.dev created
customresourcedefinition.apiextensions.k8s.io/verificationpolicies.tekton.dev created
secret/webhook-certs created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.pipeline.tekton.dev created
mutatingwebhookconfiguration.admissionregistration.k8s.io/webhook.pipeline.tekton.dev created
validatingwebhookconfiguration.admissionregistration.k8s.io/config.webhook.pipeline.tekton.dev created
clusterrole.rbac.authorization.k8s.io/tekton-aggregate-edit created
clusterrole.rbac.authorization.k8s.io/tekton-aggregate-view created
configmap/config-defaults created
configmap/feature-flags created
configmap/pipelines-info created
configmap/config-leader-election created
configmap/config-logging created
configmap/config-observability created
configmap/config-registry-cert created
configmap/config-spire created
deployment.apps/tekton-pipelines-controller created
service/tekton-pipelines-controller created
deployment.apps/tekton-events-controller created
service/tekton-events-controller created
namespace/tekton-pipelines-resolvers created
clusterrole.rbac.authorization.k8s.io/tekton-pipelines-resolvers-resolution-request-updates created
role.rbac.authorization.k8s.io/tekton-pipelines-resolvers-namespace-rbac created
serviceaccount/tekton-pipelines-resolvers created
clusterrolebinding.rbac.authorization.k8s.io/tekton-pipelines-resolvers created
rolebinding.rbac.authorization.k8s.io/tekton-pipelines-resolvers-namespace-rbac created
configmap/bundleresolver-config created
configmap/cluster-resolver-config created
configmap/resolvers-feature-flags created
configmap/config-leader-election created
configmap/config-logging created
configmap/config-observability created
configmap/git-resolver-config created
configmap/hubresolver-config created
deployment.apps/tekton-pipelines-remote-resolvers created
horizontalpodautoscaler.autoscaling/tekton-pipelines-webhook created
deployment.apps/tekton-pipelines-webhook created
service/tekton-pipelines-webhook created

[root@xksmaster1 Knative]# kubectl get pods --namespace tekton-pipelines --watch
NAME                                           READY   STATUS    RESTARTS   AGE
tekton-events-controller-6c67c94bd8-fsrlk      1/1     Running   0          16s
tekton-pipelines-controller-67db69b899-7flkx   1/1     Running   0          16s
tekton-pipelines-webhook-7bc998659c-9gqvh      1/1     Running   0          15s

[root@xksmaster1 Knative]# kubectl api-versions
admissionregistration.k8s.io/v1
apiextensions.k8s.io/v1
apiregistration.k8s.io/v1
apps/v1
authentication.k8s.io/v1
authorization.k8s.io/v1
autoscaling.internal.knative.dev/v1alpha1
autoscaling/v1
autoscaling/v2
batch/v1
caching.internal.knative.dev/v1alpha1
certificates.k8s.io/v1
coordination.k8s.io/v1
crd.projectcalico.org/v1
discovery.k8s.io/v1
events.k8s.io/v1
extensions.istio.io/v1alpha1
flowcontrol.apiserver.k8s.io/v1beta2
flowcontrol.apiserver.k8s.io/v1beta3
install.istio.io/v1alpha1
kuboard.cn/v1
networking.internal.knative.dev/v1alpha1
networking.istio.io/v1alpha3
networking.istio.io/v1beta1
networking.k8s.io/v1
node.k8s.io/v1
policy/v1
rbac.authorization.k8s.io/v1
resolution.tekton.dev/v1alpha1
resolution.tekton.dev/v1beta1
scheduling.k8s.io/v1
security.istio.io/v1
security.istio.io/v1beta1
serving.knative.dev/v1
serving.knative.dev/v1alpha1
serving.knative.dev/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
tekton.dev/v1
tekton.dev/v1alpha1
tekton.dev/v1beta1
telemetry.istio.io/v1alpha1
v1

[root@xksmaster1 Knative]# kubectl api-resources --api-group=tekton.dev
NAME                   SHORTNAMES   APIVERSION            NAMESPACED   KIND
clustertasks                        tekton.dev/v1beta1    false        ClusterTask
customruns                          tekton.dev/v1beta1    true         CustomRun
pipelineruns           pr,prs       tekton.dev/v1         true         PipelineRun
pipelines                           tekton.dev/v1         true         Pipeline
taskruns               tr,trs       tekton.dev/v1         true         TaskRun
tasks                               tekton.dev/v1         true         Task
verificationpolicies                tekton.dev/v1alpha1   true         VerificationPolicy

#Create and run a basic Task
vim hello-world.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello
spec:
  steps:
    - name: echo
      image: alpine:3.16
      script: |
        #!/bin/sh
        echo "Hello World"  

[root@xksnode1 ~]# crictl pull alpine:3.16
[root@xksnode2 ~]# crictl pull alpine:3.16

[root@xksmaster1 yaml]# kubectl apply --filename hello-world.yaml
task.tekton.dev/hello created
[root@xksmaster1 yaml]# kubectl get tasks
NAME    AGE
hello   10s
#此时hello还不会运行 需要创建taskrun
[root@xksmaster1 yaml]# kubectl get pods | grep hello

[root@xksmaster1 yaml]# vim hello-world-run.yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: hello-task-run
spec:
  taskRef:
    name: hello

[root@xksmaster1 yaml]# kubectl apply --filename hello-world-run.yaml
taskrun.tekton.dev/hello-task-run created

[root@xksmaster1 yaml]# kubectl get pods | grep hello
hello-task-run-pod                  0/2     Completed          1                  81s

[root@xksmaster1 yaml]# kubectl logs hello-task-run-pod
Hello World

2.Getting Started with Pipelines

#1.安装tkn 工具
https://tekton.dev/docs/cli/#tabs-1-2
https://github.com/tektoncd/cli/releases
https://github.com/tektoncd/cli/releases/download/v0.31.1/tektoncd-cli-0.31.1_Linux-64bit.rpm

[root@xksmaster1 Knative]# rpm -Uvh tektoncd-cli-0.31.1_Linux-64bit.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:cli-0:0.31.1-1                   ################################# [100%]
   
[root@xksmaster1 Knative]# tkn version
Client version: 0.31.1
Pipeline version: v0.49.0

#2.Create and run a second Task

[root@xksnode1 yaml]# crictl pull ubuntu
[root@xksnode2 yaml]# crictl pull ubuntu

[root@xksmaster1 yaml]# cat goodbye-world1.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: goodbye-xks
spec:
  params:
  - name: username
    type: string
  steps:
    - name: goodbye-xks
      image: ubuntu
      script: |
        #!/bin/bash
        echo "Goodbye $(params.username)!"

[root@xksmaster1 yaml]# kubectl apply -f goodbye-world1.yaml
task.tekton.dev/goodbye-xks created
[root@xksmaster1 yaml]# kubectl get tasks
NAME          AGE
goodbye-xks   5m57s
hello         7m51s

 #3.Create and run a Pipeline
[root@xksmaster1 yaml]# cat hello-goodbye-pipeline1.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: hello-goodbye-xks
spec:
  params:
  - name: username
    type: string
  tasks:
    - name: hello
      taskRef:
        name: hello
    - name: goodbye-xks
      runAfter:
        - hello
      taskRef:
        name: goodbye-xks
      params:
      - name: username
        value: $(params.username)

[root@xksmaster1 yaml]# kubectl apply --filename hello-goodbye-pipeline1.yaml
pipeline.tekton.dev/hello-goodbye-xks created
[root@xksmaster1 yaml]# kubectl get pipelines
NAME                AGE
hello-goodbye-xks   5m36s

#4.PipelineRun
[root@xksmaster1 yaml]# cat hello-goodbye-pipeline-run1.yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: hello-goodbye-run-ubuntu-xks
spec:
  pipelineRef:
    name: hello-goodbye-xks
  params:
  - name: username
    value: "BIRKHOFFWinnie"
    
[root@xksmaster1 yaml]# kubectl apply -f hello-goodbye-pipeline-run1.yaml
pipelinerun.tekton.dev/hello-goodbye-run-ubuntu-xks created

[root@xksmaster1 yaml]# kubectl get pipelinerun
NAME                           SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
hello-goodbye-run-ubuntu-xks   True        Succeeded   6m12s       5m26s

[root@xksmaster1 yaml]# kubectl get taskrun
NAME                                       SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
hello-goodbye-run-ubuntu-xks-goodbye-xks   True        Succeeded   6m31s       5m59s
hello-goodbye-run-ubuntu-xks-hello         True        Succeeded   6m45s       6m31s

[root@xksmaster1 yaml]# kubectl get pods | grep goodbye
hello-goodbye-run-ubuntu-xks-goodbye-xks-pod   0/2     Completed          1                2m54s
hello-goodbye-run-ubuntu-xks-hello-pod         0/2     Completed          1                3m8s


[root@xksmaster1 yaml]# tkn pipelinerun logs hello-goodbye-run-ubuntu-xks -f -n default
[hello : echo] Hello World

[hello : istio-proxy] 2023/06/26 03:08:42 Exiting...

[goodbye-xks : goodbye-xks] Goodbye BIRKHOFFWinnie!

[goodbye-xks : istio-proxy] 2023/06/26 03:09:14 Exiting...

 3.tkn命令

[root@xksmaster1 yaml]# tkn --help
CLI for tekton pipelines

Usage:
tkn [flags]
tkn [command]


Available Commands:
  bundle*               Manage Tekton Bundles (experimental)
  chain                 Manage Chains
  clustertask           Manage ClusterTasks
  clustertriggerbinding Manage ClusterTriggerBindings
  eventlistener         Manage EventListeners
  hub                   Interact with tekton hub
  pipeline              Manage pipelines
  pipelinerun           Manage PipelineRuns
  task                  Manage Tasks
  taskrun               Manage TaskRuns
  triggerbinding        Manage TriggerBindings
  triggertemplate       Manage TriggerTemplates

Other Commands:
  completion            Prints shell completion scripts
  version               Prints version information

Flags:
  -h, --help   help for tkn

Use "tkn [command] --help" for more information about a command.

[root@xksmaster1 yaml]# tkn task list
NAME          DESCRIPTION   AGE
goodbye-xks                 33 minutes ago
hello                       35 minutes ago

[root@xksmaster1 yaml]# tkn taskrun list
NAME                                       STARTED          DURATION   STATUS
hello-goodbye-run-ubuntu-xks-goodbye-xks   31 minutes ago   32s        Succeeded
hello-goodbye-run-ubuntu-xks-hello         31 minutes ago   14s        Succeeded
hello-task-run                             35 minutes ago   13s        Succeeded
hello-goodbye-run-goodbye                  58 minutes ago   16s        Failed
hello-goodbye-run-hello                    59 minutes ago   16s        Succeeded

[root@xksmaster1 yaml]# tkn pipeline list
NAME                AGE              LAST RUN                       STARTED          DURATION   STATUS
hello-goodbye-xks   32 minutes ago   hello-goodbye-run-ubuntu-xks   32 minutes ago   46s        Succeeded

[root@xksmaster1 yaml]# tkn pipelinerun list
NAME                           STARTED          DURATION   STATUS
hello-goodbye-run-ubuntu-xks   32 minutes ago   46s        Succeeded

[root@xksmaster1 yaml]# tkn taskrun logs hello-goodbye-run-ubuntu-xks-goodbye-xks
[goodbye-xks] Goodbye BIRKHOFFWinnie!

[istio-proxy] 2023/06/26 03:09:14 Exiting...

#使用tkn 命令行启动task
[root@xksmaster1 yaml]# tkn task start hello --showlog
TaskRun started: hello-run-n2hww
Waiting for logs to be available...
[echo] Hello World

【回复参数】
[root@xksmaster1 yaml]# tkn task start goodbye-xks --showlog
? Value for param `username` of type `string`? XKS
TaskRun started: goodbye-xks-run-w89nt
Waiting for logs to be available...
[goodbye-xks] Goodbye XKS!
【直接加参数】 -p username='xksbirkhoff'
[root@xksmaster1 yaml]# tkn task start goodbye-xks --showlog -p username='xksbirkhoff'
TaskRun started: goodbye-xks-run-9plqm
Waiting for logs to be available...
[goodbye-xks] Goodbye xksbirkhoff!

4.Installing Tekton Dashboard

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

release.yaml替换镜像配置
          image: gcr.io/tekton-releases/github.com/tektoncd/dashboard/cmd/dashboard:v0.37.0@sha256:2f38f99b6eafc18e67d013da84265ab61b5525a1a6c37005aaf86152b586427b
          image: gcr.lank8s.cn/tekton-releases/github.com/tektoncd/dashboard/cmd/dashboard:v0.37.0@sha256:2f38f99b6eafc18e67d013da84265ab61b5525a1a6c37005aaf86152b586427b

#下载镜像
crictl pull gcr.lank8s.cn/tekton-releases/github.com/tektoncd/dashboard/cmd/dashboard:v0.37.0@sha256:2f38f99b6eafc18e67d013da84265ab61b5525a1a6c37005aaf86152b586427b

[root@xksmaster1 Knative]# kubectl apply -f release.yaml
customresourcedefinition.apiextensions.k8s.io/extensions.dashboard.tekton.dev created
serviceaccount/tekton-dashboard created
role.rbac.authorization.k8s.io/tekton-dashboard-info created
clusterrole.rbac.authorization.k8s.io/tekton-dashboard-backend created
clusterrole.rbac.authorization.k8s.io/tekton-dashboard-tenant created
rolebinding.rbac.authorization.k8s.io/tekton-dashboard-info created
clusterrolebinding.rbac.authorization.k8s.io/tekton-dashboard-backend created
configmap/dashboard-info created
service/tekton-dashboard created
deployment.apps/tekton-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/tekton-dashboard-tenant created


[root@xksmaster1 Knative]# kubectl get pods --namespace tekton-pipelines --watch
NAME                                           READY   STATUS    RESTARTS   AGE
tekton-dashboard-57b975849b-st44n              1/1     Running   0          26s
tekton-events-controller-6c67c94bd8-fsrlk      1/1     Running   0          103m
tekton-pipelines-controller-67db69b899-7flkx   1/1     Running   0          103m
tekton-pipelines-webhook-7bc998659c-9gqvh      1/1     Running   0          103m

#tekton-dashboard              ClusterIP   10.105.253.243   <none>        9097/TCP                             67s
[root@xksmaster1 Knative]# kubectl get svc --namespace tekton-pipelines --watch
NAME                          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                              AGE
tekton-dashboard              ClusterIP   10.105.253.243   <none>        9097/TCP                             67s
tekton-events-controller      ClusterIP   10.96.74.134     <none>        9090/TCP,8008/TCP,8080/TCP           104m
tekton-pipelines-controller   ClusterIP   10.103.109.130   <none>        9090/TCP,8008/TCP,8080/TCP           104m
tekton-pipelines-webhook      ClusterIP   10.97.164.236    <none>        9090/TCP,8008/TCP,443/TCP,8080/TCP   104m

#查看istio-system 入向网关 外部ip192.168.40.190
[root@xianchaomaster1 KnativeSrc]# kubectl get svc -n istio-system
NAME                    TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                                      AGE
istio-ingressgateway    LoadBalancer   10.96.196.211   192.168.40.190   15021:30508/TCP,80:30590/TCP,443:30796/TCP   4d22h
istiod                  ClusterIP      10.96.53.240    <none>           15010/TCP,15012/TCP,443/TCP,15014/TCP        4d22h
knative-local-gateway   ClusterIP      10.96.27.221    <none>           80/TCP                                       4d21h


#将dashboard通过VS 暴露出去
#!!!前提需要配置 EXTERNAL—IP 这里实验使用的keepalived 配置的IP 192.168.19.190 VIP
#!!!或者自己加一个 子接口 也可以
[root@xksmaster1 01-deploy-tekton]# cat 03-virtualservice-tekton-dashboard.yaml
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: tekton-dashboard
  namespace: tekton-pipelines
spec:
  host: tekton-dashboard
  trafficPolicy:
    tls:
      mode: DISABLE
---
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: tekton-dashboard-gateway
  namespace: istio-system
spec:
  selector:
    app: istio-ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "tekton.magedu.com"
    - "ci.magedu.com"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: tekton-dashboard-virtualservice
  namespace: tekton-pipelines
spec:
  hosts:
  - "tekton.magedu.com"
  - "ci.magedu.com"
  gateways:
  - istio-system/tekton-dashboard-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: tekton-dashboard
        port:
          number: 9097
---

[root@xksmaster1 01-deploy-tekton]# kubectl apply -f 03-virtualservice-tekton-dashboard.yaml
destinationrule.networking.istio.io/tekton-dashboard created
gateway.networking.istio.io/tekton-dashboard-gateway created
virtualservice.networking.istio.io/tekton-dashboard-virtualservice created

[root@xksmaster1 01-deploy-tekton]# kubectl get vs -n tekton-pipelines
NAME                              GATEWAYS                                    HOSTS                                   AGE
tekton-dashboard-virtualservice   ["istio-system/tekton-dashboard-gateway"]   ["tekton.magedu.com","ci.magedu.com"]   29

#主机配置域名解析
192.168.40.190 kiali.magedu.com bookinfo.magedu.com tekton.magedu.com

#本地浏览器打开
http://tekton.magedu.com/#/about

Parameters

posted @ 2023-06-26 12:31  しみずよしだ  阅读(224)  评论(0)    收藏  举报