Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CI/CD Pipeline for Minimalist
Search
pannpers
October 24, 2019
Programming
4
2.6k
CI/CD Pipeline for Minimalist
『Kubernetes Meetup Tokyo #24』でのLT。
https://k8sjp.connpass.com/event/149872/
pannpers
October 24, 2019
Tweet
Share
Other Decks in Programming
See All in Programming
SIMD Parallel Programming with the Vector API
josepaumard
0
180
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
260
Rethinking UI building strategies @ SFI 2024
letelete
0
270
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
430
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
110
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
0
250
Snowflakeで眠ったデータを起こそう!
estie
0
120
Ruby GitHub Packages
bkuhlmann
0
630
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
790
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
140
Ruby Function Composition
bkuhlmann
1
330
Featured
See All Featured
A Tale of Four Properties
chriscoyier
151
22k
Build The Right Thing And Hit Your Dates
maggiecrowley
24
2k
Debugging Ruby Performance
tmm1
70
11k
Typedesign – Prime Four
hannesfritz
36
2.1k
Making the Leap to Tech Lead
cromwellryan
124
8.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
274
13k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
78
43k
In The Pink: A Labor of Love
frogandcode
138
21k
Code Review Best Practice
trishagee
55
15k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
Designing Experiences People Love
moore
136
23k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
7
1k
Transcript
CI/CD Pipeline for Minimalist
hello! I am Yoshimasa Hamada I am Web Developer and
work for Zeals. You can find me at @panchan9 or @pannpers. 2
実際に、Kubernetes 導入してますか? (or 直近に導入予定) 3 1.
CD専用ツール使ってますか? 4 2. • Spinnaker • Jenkins X • Argo
CD • Flux by Weaveworks • Tekton • GoCD
Hard Way to introduce CD Tool in Initial Phase ✘
CDツールの選択肢が多過ぎる ✘ そして、どれも多機能なので比較検討のコストが高い ✘ というかKubernetesだけでも、導入コスト高い
とはいえ、 CD Pipelineを構築していないと・・・
Problems ✘ k8s Contextを間違って、意図した環境とは異なる Manifestsをデプロイしてしまう ✘ Gitでコード管理されていない変更が行われている (しかも意図が分からない) ✘ デプロイ作業が属人化してしまい、新規メンバーの学習
コストが高くなる
Don’t use kubectl by hand 8
どうすればよいか?
GitOps is current Best Practices https://www.weave.works/technologies/ci-cd-for-kubernetes/
GitOps is just Principles. How implement GitOps approach?
Summary of Problems ✘ k8s導入初期で最適なCD Pipeline構築は難しい ✘ 一方、マニュアルオペレーションはリスク大・・・ ✘ 理想はGitOps。あとはどう実現するか?
◦ できればラーニングコストが低く ◦ 複雑性をできるだけ排除した方法で
CI/CD Pipeline for Minimalist
まずは前提とゴールを整理 ✘ Git Branch Model どうする? ✘ Project Layout は?(GCPを例にします)
✘ いきなりGitOpsとかできるん?
GitHub Flow 1. Git Branch Model Master Feature PipelineのTriggerを変えれば、Git FlowやGitLab
Flowでも同じことができます
• zeals-dev • zeals-stg • zeals-prd • zeals-cr (container registry)
Docker Imageを一元管理するProject 2. GCP Project Layout
CI Ops like GitOps !! 3. Workflow For more details
about GitOps, Kubernetes anti-patterns: Let's do GitOps, not CIOps!
どういうことだってばよ!?
GitOpsが提唱する以下の原則には従う ✘ ApplicationやMiddlewareの設定は、Gitレポジトリで管 理しているものが絶対的な正であり、差異が発生しない ようにする (HPAによるPod数の際などは除く) ✘ kubectl を直接使用してデプロイを行わない
その一方で 『アンチパターン』とされている CI Opsを部分的に採用
具体的には・・・ ✘ デプロイに必要なCredentialsをCIツールに渡すことを許容 する ✘ GCPであれば、CIツール用に作成したService Accountの JSONファイル ✘ これにはKubernetesマスターのAPIへ命令を送ることがで
きる、とても強力な権限が付与されている
要するに GitOpsの恩恵を受けつつ 使い慣れたCIツールを使うことで (あと、デプロイ用のちょっとした Shell Script) ラーニングコストも最小限に!! 以下はCircleCIを例としています
それではここで Zealsの実際のCI/CD Pipelineを紹介
None
None
Point 1 ✘ PushされたFeatureブランチ専用のNamespaceを 作成し、デプロイする ✘ ローカルからport-forwardし、動作検証を行う ◦ cert-managerでTLS証明書を自動作成し、 外部からのエンドポイントも自動で用意したい
✘ CircleCIでは『ブランチの削除』をHookできないため、 毎回のジョブ実行時に存在するブランチと k8sのNamespaceを照合し、無ければ削除している
None
Point 2 ✘ masterブランチへのMergeコミットIDをDocker Imageのタ グとしてPushする e.g. zeals/hoge:98sie82 ✘ このへんはSkaffoldがやってくれるので、雑に
skaffold run -p ${ENV} と実行するだけでOK
None
Point 3 ✘ StagingのジョブでPushしたDocker ImageをPull ✘ masterブランチへのGitタグ(v0.1.2)を Docker Imageのタグに付与してPushする ◦
docker tag zeals/hoge:98sie82 zeals/hoge:v0.1.2 ◦ docker push zeals/hoge:v0.1.2 ✘ ImageのビルドはSkipするために、Skaffoldは run ではなく、 deploy コマンドを使う ◦ skaffold deploy -p ${ENV} --images=zeals/hoge:v0.1.2
これらを実行するための CircleCIのコンフィグや Shell Scriptは・・・
Tech Blogで公開します!! (Comming Soon) https://tech.zeals.co.jp
Conclusion ✘ k8s導入の初期フェーズは使い慣れたCIツールでも、 わりといい感じのCI/CD Pipelineを作れる ✘ ただ、本格運用に必要な機能は不足 ◦ カナリアリリース ◦
障害時のロールバック ◦ Git上のk8s Manifestと実際の値の変更検知 ✘ ある程度、k8s運用に慣れたタイミングで より高機能なCD専用ツールを導入しよう
thanks! Any questions? You can find me at @panchan9