Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced GitLab Workshop - 談 pipeline 調教與進階 Git...

mouson(墨嗓)
November 24, 2021

Advanced GitLab Workshop - 談 pipeline 調教與進階 GitLab CI 語法

此為 DevOpsDays Taipei 2021 中的 Workshop Advanced GitLab CI 所使用的簡報,與簡報搭配的範例 GitLab Repo:
https://gitlab.com/mouson-gitlab-playground/gitlab-ci-workshop-2021-11-24

PS. 本次工作坊使用的範例及對應步驟,大部分都可以在對應的 GitLab 中找到對應的 Git 分支。可透過 GitLab pipeline editor 直接選擇分支進行查看及編輯。

mouson(墨嗓)

November 24, 2021
Tweet

More Decks by mouson(墨嗓)

Other Decks in Technology

Transcript

  1. 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates ├──

    common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml 08-extract-to-template-yaml
  2. 08-extract-to-template-yaml 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates

    ├── common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml
  3. 08-extract-to-template-yaml 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates

    ├── common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml
  4. 08-extract-to-template-yaml 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates

    ├── common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml
  5. 08-extract-to-template-yaml 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates

    ├── common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml
  6. 08-extract-to-template-yaml 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates

    ├── common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml
  7. 08-extract-to-template-yaml 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates

    ├── common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml
  8. 08. 拆分檔案利 ⽤ include 載入 ├── .gitlab-ci.yml └── templates ├──

    common.yml ├── de fi ne.yml ├── lint.yml ├── test.yml └── deploy.yml 08-extract-to-template-yaml
  9. include: - local: 同專案下的檔案 - remote: URL 連結 - template:

    GitLab 官⽅提供的模板 - fi le: 來⾃其他專案的檔案
  10. include: - local: 同專案下的檔案 - remote: URL 連結 - template:

    GitLab 官⽅提供的模板 - fi le: 來⾃其他專案的檔案 GitLab 13.11.
  11. include: fi le introduced in GitLab 11.7 include multi fi

    le from a project in GitLab 13.6 09. 建立共⽤流 程供其他專案 使⽤ 09-used-template-from-other-project
  12. Recap • 利⽤ default stage 整理所有 job 都共同的 • 利⽤

    .hidden 建立模板⼯作,並⽤ extends 繼承使⽤ • 利⽤ Anchors、Reference 整理可重複使⽤的 Script • 萃取出變數 • 利⽤ Parallel Matrix 功能 • 建立多專案共⽤流程
  13. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runners Runner Runner Runner Runner
  14. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runners Runner Runner Runner Runner Run Job ____________________________
  15. ⼯作花太久時間等待進 Queue? build test deploy build_a test_a deploy_a build_b test_b

    deploy_b build_c test_c deploy_c 分⽀:10-stage-without-dag-needs
  16. ⼯作花太久時間等待進 Queue? build test deploy build_a test_a deploy_a build_b test_b

    deploy_b build_c test_c deploy_c build_b 分⽀:10-stage-without-dag-needs
  17. ⼯作花太久時間等待進 Queue? build test deploy build_a test_a deploy_a build_b test_b

    deploy_b build_c test_c deploy_c build_b 分⽀:10-stage-without-dag-needs
  18. ⼯作花太久時間等待進 Queue? • 套⽤ DAG 機制 (GitLab 12.2) build test

    deploy build_a test_a deploy_a build_b test_b deploy_b build_c test_c deploy_c build_b 分⽀:10-1-stage-with-needs
  19. ⼯作花太久時間等待進 Queue? • 套⽤ DAG 機制 (GitLab 12.2) build test

    deploy build_a test_a deploy_a build_b test_b deploy_b build_c test_c deploy_c build_b 分⽀:10-1-stage-with-needs
  20. ⼯作花太久時間等待進 Queue? • 套⽤ DAG 機制 (GitLab 12.2) build test

    deploy build_a test_a deploy_a build_b test_b deploy_b build_c test_c deploy_c build_b 分⽀:10-1-stage-with-needs
  21. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runners Runner Runner Runner Runner
  22. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runners Runner Runner Runner Runner
  23. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runners Runner Runner Runner Runner •Runner 數量夠嗎?
  24. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runners Runner Runner Runner Runner •Runner 數量夠嗎? •能執⾏的 Runner 夠嗎?
  25. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runners Runner Runner Runner Runner
  26. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runners Runner Runner Runner Runner Run Job ____________________________
  27. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e
  28. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r
  29. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r * restore re s t o
  30. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r * restore re s t o * download do wnlo ad
  31. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r * restore re s t o * download do wnlo ad * script s c r i p t
  32. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r * restore re s t o * download do wnlo ad * script s c r i p t * package p ack a ge
  33. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r * restore re s t o * download do wnlo ad * script s c r i p t * package p ack a ge * saving s a vin
  34. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Run ____________________________ * prepare p r e pa r e p r e * git g i t gi t r * restore re s t o * download do wnlo ad * script s c r i p t * package p ack a ge * saving s a vin * uploading u p load i ng
  35. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  36. •Network Performance ? Runner Server Runner Server Runners Runner Runner

    Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  37. •Network Performance ? •Docker image size ? Runner Server Runner

    Server Runners Runner Runner Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  38. •Network Performance ? •Docker image size ? •Git Repo Size

    ? Runner Server Runner Server Runners Runner Runner Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  39. •Network Performance ? •Docker image size ? •Git Repo Size

    ? •Programming Language Dependence Package Size ? Runner Server Runner Server Runners Runner Runner Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  40. •Network Performance ? •Docker image size ? •Git Repo Size

    ? •Programming Language Dependence Package Size ? •Artifacts Size ? Runner Server Runner Server Runners Runner Runner Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  41. •Network Performance ? •Docker image size ? •Git Repo Size

    ? •Programming Language Dependence Package Size ? •Artifacts Size ? •Script Performance ? Runner Server Runner Server Runners Runner Runner Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  42. Runner Server Runner Server Runners Runner Runner Runner Runner Run

    Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  43. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runners Runner Runner Runner Runner Run Job ____________________________ * prepare execute env * git repo fetch * restore cache * download artifacts * script execute * package install * saving cache * uploading artifacts * cleaning up fi le base var
  44. Q&A