You are on page 1of 46

From DevOps to GitOps

with GitLab

Photo by Abele Gigante on Unsplash Cheng Wei Chen @ Cloud Edge Sumit 2020
Cheng Wei Chen 陳 正瑋

DevOps Engineer @ 得寬科技


《Effective DevOps 中⽂版》譯者、GitLab Hero

http://chengweichen.com
https://devopstw.club
Agenda
• 什麼是 GitOps

• 範例分享

• 如何開始實踐 GitOps

• 結語
STORY
Photo by Timothy Meinberg on Unsplash
Commit

Code OK!

Dev 啊~我忘了說有⼀個新的 Config ~

Code


炸炸
Deploy

Ops
Commit

Code OK Again !

Dev
啊!我昨天有⼿動改了 Ops
⼀個 Config,應該不是
這個原因吧?
Code

炸 Again
Again
炸炸 Again
Deploy

Ops
Commit Infra 有⼀些調整,忘了
跟你說~ Infra

Code OK Again x2

Dev



炸炸炸炸炸 炸

Code

炸 炸 炸 炸 炸
Agai

炸炸Again
Again
炸炸 炸AgainAga
Aga

Deploy

Ops
炸炸 炸
炸炸 炸炸
炸炸 炸
炸炸
什麼是 GitOps

Photo by Fancycrave on Unsplash


⼀條龍
⼯程師

Provision

Configuration

Code Artifacts Deploy Production


⼀條龍
⼯程團隊

Provision

Configuration

Code CI / CD Deploy Production

Automation
Ops / Infra
⼀條龍
團隊
⼯程團隊

Configuration Provision

Code CI / CD Deploy Production

Automation
圖片來源 https://youtu.be/Usb9iUphT6Y
GitOps = IaC + MRs + CI/CD

GitLab 說的~
GitOps = IaC + MRs + CI/CD

Infrastructure as Code
Infrastructure System Configuration Application Configuration
GitOps = IaC + MRs + CI/CD

Merge Requests
GitOps = IaC + MRs + CI/CD

Continuous Integration
Continuous Delivery
And Automation
GitOps = IaC + MRs + CI/CD

DevOps
範例分享

Photo by Fancycrave on Unsplash


Production branch
Prod Pipeline Monitor

Merge Feedback

Master branch
新 Issue CI/CD Pipeline 新 Issue

Merge

建立 Feature branch

Code Review

測試驗收
Coding

Feature branch
Commit CI/CD Pipeline
Commit

檢查 .gitlab-ci.yml

GitLab 產⽣ CI/CD Pipeline


Server

回傳 Logs
CI Job 顯⽰於 Pipeline

執⾏ Job
GitLab
Cloud
Runner Terraform Ansible
Cloud
Vault Repository Cloud
App 1. App 有更新嗎?

Build Test Release

2. infra 有更新嗎?
GitLab
Infra Runner

Worker
Validate Plan

3.有!執⾏異動!

Validate Plan Approve


圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
圖片來源 https://gitlab.com/gitops-demo/readme
如何開始實踐 GitOps

Photo by Fancycrave on Unsplash


1. IaC
2. Automation DevOps
3. Code Review & Approve
4. Multi environment
5. CI/CD
6. Use Repository
7. Agile & Iteration
1. IaC

讓⼀切都成為 Code
2. Automation
盡可能⾃動化
如果不成,就紀錄它!
3. Code Review & Approve

審查、複閱、檢查、稽核
4. Multi environment

運⽤在所有的環境!
5. CI/CD

⾃動化的唯⼀觸發點!
6. Use Repository

分⽀策略、Flow、Workflow
7. Agile & Iteration

⼩粒度、多迭代
Tools
VCS Yes
CI Yes
CD Yes
Container Registry Yes
CM 透過 Runner 間接運⽤
IaC 透過 Runner 間接運⽤
Container orchestration 可整合
結語

Photo by Fancycrave on Unsplash


GitOps = IaC + MRs + CI/CD
GitOps is IaC done right !
DevOps, then GitOps !
現 階 段

GitOps is not for everyone !


(with K8S)

You might also like