GitLab + Jenkins + Harbor 工具鏈快速落地指南( 四 )

假如日志不夠和諧 , 那就,那就, , ,debug 吧 。
4.2、網絡配置前面 GitLab + Jenkins + Harbor 三個工具的配置文件里我們都設置了域名,如果是 kubeadm 直接部署的 k8s 集群,你可以直接將這些域名與 IP 的映射關系配置到 DNS 服務器里 。
如果沒有 DNS 服務器,你也可以直接將域名與 IP 的映射關系配置到 /etc/hosts 以及 CoreDNS 的 ConfigMap kube-system/coredns 里讓域名生效 。比如:

  1. 修改 /etc/hosts 文件,添加這條記錄(記得替換成你自己的 IP):
    44.33.22.11 gitlab.example.com jenkins.example.com harbor.example.com
  2. 修改 CoreDNS 的配置,在 ConfigMap kube-system/coredns 中添加靜態解析記錄:
    1. 執行命令:kubectl edit cm coredns -n kube-system;
    2. 在 hosts(第20行左右) 部分添加和 /etc/hosts 一樣的記錄 。
這樣 Jenkins 才能通過域名訪問到 GitLab 。
4.3、驗證工具鏈部署結果來 , 看下新部署的 GitLab、Jenkins、Harbor 是不是都能訪問到 。
4.3.1、GitLab不出意外的話,你可以在自己的 PC 里配置 44.33.22.11 gitlab.example.com 靜態域名解析記錄,然后在瀏覽器里通過 http://gitlab.example.com:30080 訪問到 GitLab:
GitLab + Jenkins + Harbor 工具鏈快速落地指南

文章插圖
然后通過執行如下命令,你就能獲得 GitLab 的初始 root 密碼了:
docker exec gitlab cat /etc/gitlab/initial_root_password | grep Password:拿到 root 密碼后,你可以嘗試用 root/YOUR_PASSWORD 來登錄 GitLab 。因為后面我們需要用到 GitLab 的 token,所以這時候可以順手創建一個 token:
GitLab + Jenkins + Harbor 工具鏈快速落地指南

文章插圖
4.3.2、Jenkins在瀏覽器里通過 http://jenkins.example.com:32000 就可以訪問到 Jenkins 了:
GitLab + Jenkins + Harbor 工具鏈快速落地指南

文章插圖
Jenkins 的 admin 用戶初始登錄密碼是 changeme,如果你仔細看了前面 dtm 使用的配置文件,可以發現這是在配置文件里指定的 。我們嘗試用 admin/changeme 登錄 Jenkins 檢查功能是否正常,不過這時不需要在 Jenkins 上進行任何額外的操作 。
GitLab + Jenkins + Harbor 工具鏈快速落地指南

文章插圖
4.3.3、Harbor我們可以通過 docker login harbor.example.com:80 命令來嘗試登錄 Harbor,也可以直接通過 http://harbor.example.com:30180 訪問 Dashboard:
GitLab + Jenkins + Harbor 工具鏈快速落地指南

文章插圖
Harbor 的 admin 用戶初始登錄密碼是 Harbor12345,我們嘗試用 admin/Harbor12345 登錄 Harbor:
GitLab + Jenkins + Harbor 工具鏈快速落地指南

文章插圖
4.4、流水線配置工具有了,下一步就是配置流水線了,咱繼續準備第二個配置文件(config-pipeline.yaml):
---varFile: "" # If not empty, use the specified external variables config filetoolFile: "" # If not empty, use the specified external tools config filepluginDir: "" # If empty, use the default value: ~/.devstream/plugins, or use -d flag to specify a directorystate: # state config, backend can be local, s3 or k8s  backend: local  options:    stateFile: devstream-2.state---tools:- name: repo-scaffolding  instanceID: springboot  dependsOn: [ ]  options:    destinationRepo:      owner: root      repo: spring-demo      branch: master      repoType: gitlab      baseURL: http://gitlab.example.com:30080    sourceRepo:      owner:  devstream-io      repo: dtm-repo-scaffolding-java-springboot      repoType: github- name: jenkins-pipeline  instanceID: default  dependsOn: [repo-scaffolding.springboot]  options:    jenkins:      url: http://44.33.22.11:32000      user: admin      enableRestart: true    scm:      cloneURL: http://gitlab.example.com:30080/root/spring-demo      branch: master    pipeline:      jobName: test-job      jenkinsfilePath: https://raw.githubusercontent.com/devstream-io/dtm-jenkins-pipeline-example/main/springboot/Jenkinsfile      imageRepo:        url: http://harbor.example.com:80        user: admin

推薦閱讀