天天看點

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

《OpenShift 4.x HOL教程彙總》

本文是siamaksade在其github上的一個Tekton Pipeline示範示例,它是《OpenShift 4之實作一個基于Gogs+Nexus+Sonarqube的Jenkins CI/CD Pipeline》的Tekton更新版本。示例示範了Dev和Stage的CI/CD過程。在這個Tekton Pipeline中內建了Gogs、SonaQube、Nexus、Report等DevOps工具。

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

主要的配置過程如下:

  1. 在OpenShift上安裝OpenShift Pipeline Operator。
  2. 在客戶機安裝Tekon環境。
$ curl -L https://github.com/tektoncd/cli/releases/download/v0.8.0/tkn_0.8.0_Linux_x86_64.tar.gz | tar -xzf -
$ sudo mv tkn /usr/local/bin/
           
  1. 下載下傳github項目,然後運作安裝。
$ git clone https://github.com/siamaksade/tekton-cd-demo 
$ cd tekton-cd-demo 
$ demo.sh install --project-prefix <PREFIX>
 
。。。。
############################################################################
############################################################################
  Demo is installed! Give it a few minutes to finish deployments and then:
 
  1) Go to spring-petclinic Git repository in Gogs:
     http://gogs-tkn-cicd.apps.cluster-beijing-0f11.beijing-0f11.example.opentlc.com/gogs/spring-petclinic.git
  2) Log into Gogs with username/password: gogs/gogs
  3) Edit a file in the repository and commit to trigger the pipeline
  4) Check the pipeline run logs in Dev Console or Tekton CLI:
    $ tkn pipeline logs petclinic-deploy-dev -f -n tkn-cicd
 
  You can find further details at:
  PipelineRun Reports: http://reports-repo-tkn-cicd.apps.cluster-beijing-0f11.beijing-0f11.example.opentlc.com
  SonarQube: http://sonarqube-tkn-cicd.apps.cluster-beijing-0f11.beijing-0f11.example.opentlc.com
  Sonatype Nexus: http://nexus-tkn-cicd.apps.cluster-beijing-0f11.beijing-0f11.example.opentlc.com
############################################################################
############################################################################
           
  1. 在安裝完後,在OpenShift控制台的Develoer視圖中檢視PREFIX-cicd項目的Topology包括以下部署對象。
    OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline
    說明:在我安裝的時候曾出現gogs部署找不到gogs-config的情況,可以無需删除資源再次執行一次安裝。
  2. 根據以上提示用對應使用者通路Gogs、Nexue、SonaQube、Reports位址。

    其中Gogs上有兩個Repo,其中一個是petclinic應用的源碼,另一個是OpenShift的部署YAML檔案。

    OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline
    并且spring-petclinic的Repo已經自動配置好了Webhook。
    OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline
  3. 運作pipeline,然後在OpenShift控制台的PREFIX-cicd項目中檢視Pipeline運作情況。
$ demo.sh start
           

Pipeline 運作清單

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

Pipeline 運作的Task

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

Pipeline 運作日志

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

7. 在Pipeline完成後檢視Gogs、Nexue、SonaQube、Reports結果。

Report中的性能報告

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline
OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

8. 在PREFIX-dev項目中通路petclinic應用。

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

9. 在Gogs中修改下圖路徑中的messages.properties檔案内容,将welcome設為“Welcome Pet Clinic”,然後點選“Commit Changes”。

OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

10. 确認OpenShift啟動新的Pipeline Run。在運作結束後檢視應用已經被更新。

  1. 在PREFIX-cicd項目中手動Strat名為petclinic-deploy-stage的Pipeline,然後在彈出視窗提供以下配置參數。
    OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline
  2. 在Pipeline完成執行。
    OpenShift 4 Tekton (4) - Tekton實作包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline
  3. 在PREFIX-stage項目檢視部署的應用。

繼續閱讀