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
CircleCI & Argo CD による GitOps / GitOps with Cir...
Search
pm11 (Shinichiro Todaka)
August 05, 2019
Programming
3
740
CircleCI & Argo CD による GitOps / GitOps with CircleCI and Argo CD
2019/08/05 デプロイしNight in 福岡の LT 発表内容です
pm11 (Shinichiro Todaka)
August 05, 2019
Tweet
Share
Other Decks in Programming
See All in Programming
新世界の理解
koriym
0
140
TDD 実践ミニトーク
contour_gara
0
150
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
20250808_AIAgent勉強会_ClaudeCodeデータ分析の実運用〜競馬を題材に回収率100%の先を目指すメソッドとは〜
kkakeru
0
210
私の後悔をAWS DMSで解決した話
hiramax
4
140
AIコーディングAgentとの向き合い方
eycjur
0
230
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
600
技術的負債で信頼性が限界だったWordPress運用をShifterで完全復活させた話
rvirus0817
1
2.1k
書き捨てではなく継続開発可能なコードをAIコーディングエージェントで書くために意識していること
shuyakinjo
1
310
🔨 小さなビルドシステムを作る
momeemt
1
520
学習を成果に繋げるための個人開発の考え方 〜 「学習のための個人開発」のすすめ / personal project for leaning
panda_program
1
110
Namespace and Its Future
tagomoris
3
250
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
431
65k
Site-Speed That Sticks
csswizardry
10
790
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
The Cost Of JavaScript in 2023
addyosmani
53
8.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
The World Runs on Bad Software
bkeepers
PRO
70
11k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
YesSQL, Process and Tooling at Scale
rocio
173
14k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
The Art of Programming - Codeland 2020
erikaheidi
55
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Transcript
$JSDMF$*"SHP$%ʹΑΔ(JU0QT !QN σϓϩΠ͠/JHIUJOԬ
͡Ίʹ w ࠓ(JU0QTΛ$JSDMF$*ͱ"SHP$%Λ༻͍࣮ͯݱ͠ ͯΈ͍ͨͱࢥ͍·͢ w LVCFSOFUFTͷ֓೦͕ଟʑग़ͯ·͍Γ·͕͢ɺ͋·Γਂ͍ Ͱ͍͟͝·ͤΜ !2
ࣗݾհ w !QNʢ4IJOJDIJSP5PEBLBʣ w גࣜձࣾ"QSFOEFS w ϑϩϯτΤϯυΠϯϑϥΤϯδχΞ w ࡢɺؔ౦ԬҠॅ✈ w
ಘҙδϟϯϧϑϩϯτΤϯυʢ3FBDUʣٴͼɺ"84 ߏ ཧपΓͰ͢ w ࠷ۙLTपΓΛ͔͚͍ͬͯ·͢ w ͱ♨͕͖ !3
(JU0QT
(JU0QTͱ w 8FBWFXPSLT͕ఏএͨ͠$MPVE/BUJWF࣌ʹ͓͚Δ $%ͷ͋Γํ w IUUQTXXXXFBWFXPSLTUFDIOPMPHJFTHJUPQT w (JU3FQP͕ݱঢ়ΠϯϑϥΛө͍ͯ͠Δʢ4JOHMF4PVSDFPG5SVUIʣ w 1VMM3FRVFTUϕʔεͰөΛߦ͏
!5
(JU0QTͱ !6 https://www.slideshare.net/weaveworks/gitops-modern-best-practices-for-high-velocity-app-dev-using-cloud-native-tools
"SHP$%
"SHP$%ͱ w (JU0QTΛ࣮ݱ͢ΔͨΊͷπʔϧ w ,VCFSOFUFTͷͨΊͷએݴతͳ(JU0QTͷͨΊͷσϦόϦʔπʔϧ w ϦϙδτϦΛϙʔϦϯάͯ͠มԽΛݕग़͠·͢ w ଟػೳͰ͢ɻ·͍ͩ͜ͳ͍ͤͯ·ͤΜ !8
https://github.com/cncf/landscape
None
σϞߏங
࡞Δͷ w ߏ w ,VCFSOFUFTΫϥελ w &,4Ͱ࡞ w /HJOYͷJOEFYIUNMΛදࣔ͢ΔΞϓϦέʔγϣϯ w
"SHP$%ͷίϯϙʔωϯτ w (JU)VC w $JSDMF$* w ࢦఆͷλάͰΠϝʔδͷϏϧυ w ͦͷΠϝʔδλάͰNBOJGFTUΛஔ͖͑ɺ13Λ࡞ w 13࡞ʹIVCΛ༻ w ͪͳΈʹ(JU0QTͷຊ࣭Ͱ͋Γ·ͤΜ !12
ߏΠϝʔδ !13 https://www.slideshare.net/weaveworks/gitops-modern-best-practices-for-high-velocity-app-dev-using-cloud-native-tools
ΫϥελΛཱͯΔ $ brew install weaveworks/tap/eksctl $ eksctl version [ℹ] version.Info{BuiltAt:"",
GitCommit:"", GitTag:"0.2.1"} $ eksctl create cluster \ --name sample-cluster \ --region us-west-2 \ --nodes 2 \ --nodes-min 1 \ --nodes-max 2 \ --node-type t2.medium \ --version=1.13 \ --tags environment=test !14
ΞϓϦέʔγϣϯʢ/HJOYʣͷ࡞ $ cat Dockerfile FROM nginx:1.17.2 ADD index.html /usr/share/nginx/html/ EXPOSE
80 CMD nginx -g "daemon off;" $ cat index.html <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> </head> <body> Hello GitOps!! </body> </html> !15
ίϯςφϨδετϦͷ४උ $ aws ecr create-repository \ --repository-name gitops-sample \ --region
us-west-2 !16
$JSDMF$*ͷηοτΞοϓ $ cat .circleci/config.yml orbs: aws-ecr: circleci/
[email protected]
version: 2.1
workflows: build_and_push_image: jobs: - aws-ecr/build-and-push-image: repo: gitops-sample tag: 1.0.0 filters: branches: only: - master !17
$JSDMF$*ͷηοτΞοϓ create_pull_request: docker: - image: circleci/golang:1.11-stretch steps: - checkout
- run: name: Install hub command command: | curl -sSLf https://github.com/github/hub/releases/download/v2.12.3/hub-linux-amd64-2.12.3.tgz | \ tar zxf - --strip-components=1 -C /tmp/ && \ sudo mv /tmp/bin/hub /usr/local/bin/hub - run: name: Replace definition & create a pull request command: | cd /home/circleci/project sed -i -e 's/\(gitops-sample:\)[0-9\.]\+.*$/\11.0.0/g' infra/default/application.yaml export BRANCH=`date "+%Y%m%d-%H%M%S"` git config --global user.email "
[email protected]
" git config --global user.name "CIBot" git checkout --no-track -b ${BRANCH} git commit -am '[ci skip] bump version' hub push origin ${BRANCH} hub pull-request \ --message="Update Image" \ --base=${CIRCLE_PROJECT_USERNAME}:master \ --head=${CIRCLE_PROJECT_USERNAME}:${BRANCH} !18
$JSDMF$*ͷηοτΞοϓ $ cat .circleci/config.yml ... jobs: create_pull_request: ... workflows:
build_and_push_image: jobs: - aws-ecr/build-and-push-image: ... - create_pull_request: requires: - aws-ecr/build-and-push-image filters: branches: only: - master !19
$JSDMF$*ͷηοτΞοϓ AWS_ECR_ACCOUNT_URL=<<YOUR AWS_ACCOUNT_ID>>.dkr.ecr.us- west-2.amazonaws.com AWS_ACCESS_KEY_ID=<<YOUR ACCESS_KEY_ID>> AWS_SECRET_ACCESS_KEY=<<YOUR SECRET_ACCESS_KEY>> AWS_REGION=us-west-2
GITHUB_TOKEN=<<YOUR PERSONAL_ACCESS_KEY>> w ҎԼΛ$JSDMF$*ͷ&OWJSPONFOUఆ͓͖ٛͯ͠·͢ w ·ͨ8SJUFՄೳͳ伴ͷηοτΛ࡞͠ɺެ։伴Λ (JU)VCൿີ伴Λ$JSDMF$*ొ͓͖ͯ͠ɺ1FSTPOBM "DDFTT5PLFOొ͠·͢ !20
ΞϓϦέʔγϣϯͷNBOJGFTU࡞ $ cat infra/default/application.yaml apiVersion: apps/v1 kind: Deployment metadata: name:
nginx-deployment namespace: default labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: XXXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com/gitops-sample: 1.0.0 ports: - containerPort: 80 ... snip ... !21
ΞϓϦέʔγϣϯʢ/HJOYʣͷల։ # ద༻ʢk = kubectlʣ $ k apply -f infra/default/application.yaml
$ k get pods -n default NAME READY STATUS RESTARTS AGE nginx-deployment-76cfc87d8c-4jwsh 1/1 Running 0 4h23m nginx-deployment-76cfc87d8c-6fxp2 1/1 Running 0 4h23m $ curl <<Service Endpoint>> <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> </head> <body> Hello GitOps!! </body> </html> !22
"SHP$%ͷల։ʢʣ # Ϋϥελల։ʢk = kubectlʣ $ k create namespace argocd
$ k apply -n argocd -f https://raw.githubusercontent.com/ argoproj/argo-cd/stable/manifests/install.yaml # LB Λ͚ͭͯΞΫηεͰ͖ΔΑ͏ʹ $ k patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}' # CLI ͷΠϯετʔϧ $ brew tap argoproj/tap $ brew install argoproj/tap/argocd # ϩάΠϯʢadmin:{argocd-serverͷPod໊} ͰϩάΠϯՄೳʣ $ argocd login <<Service Endpoint>> !23
"SHP$%ͷల։ʢʣ # ΞϓϦέʔγϣϯΛ࡞ $ argocd app create gitops-sample \ --repo
https://github.com/pm11/argo-cd-example.git \ --path infra/default \ --dest-server https://kubernetes.default.svc \ --dest-namespace default # ϦϙδτϦΛඥ͚ͮΔ $ argocd repo add https://github.com/pm11/argo-cd- example.git !24
"SHP$%ϩάΠϯ w 4FSWJDFʹ$-#ͷ%/4ͰΞΫηε͢ΔͱҎԼͷը໘ʹ w $-*ͱಉ͡Ϣʔβ໊ύεϫʔυΛ͏ !25
"SHP$%μογϡϘʔυ !26
5SZ(JU0QT
ΞϓϦέʔγϣϯʢ/HJOYʣΛมߋ $ git diff index.html ... @@ -4,6 +4,6 @@
<title>Welcome to nginx!</title> </head> <body> -Hello GitOps!! +Hello GitOps with CircleCI!! </body> </html> !28
ΞϓϦέʔγϣϯʢ/HJOYʣΛมߋ $ git diff .circleci/config.yml ... @@ -17,7 +17,7 @@
jobs: cd /home/circleci/project - sed -i -e 's/\(gitops-sample:\)[0-9\.]\+.*$/\11.0.0/g' infra/ default/application.yaml + sed -i -e 's/\(gitops-sample:\)[0-9\.]\+.*$/\11.0.1/g' infra/ default/application.yaml export BRANCH=`date "+%Y%m%d-%H%M%S"` ... @@ -34,7 +34,7 @@ workflows: jobs: - aws-ecr/build-and-push-image: repo: gitops-sample - tag: 1.0.0 + tag: 1.0.1 filters: !29
$JSDMF$* !30
(JU)VCͰ13Λ֬ೝ w $JSDMF$*͔Β13͕ग़͞ΕΔͷͰ༰Λ֬ೝ͠ɺϚʔδ͠·͢ w ʢࠓݸਓͷ1FSTPOBM"DDFTT5PLFOΛར༻͍ͯ͠·͕͢ઐ༻ͷ ͷ͕ྑ͍Ͱ͢ʣ !31
"SHP$%Ͱ4ZODΛߦ͏ w "SHP$%ଆ͕0VU0G4ZODͱͳΔͷͰɺ4ZODΛߦ͍·͢ !32
"SHP$%ͰσϓϩΠத w ผͰ3FQMJDB4FU͕࡞͞Εͯͷ1PE͕ىಈ͠·͢ !33
ΞϓϦέʔγϣϯʢ/HJOYʣΛมߋ $ curl <<Service Endpoint>> <!DOCTYPE html> <html> <head> <title>Welcome
to nginx!</title> </head> <body> Hello GitOps with CircleCI!! </body> </html> !34
None
·ͱΊ w ؆୯Ͱ͋Γ·͕͢$JSDMF$*ͱ"SHP$%ΛΈ߹Θͤͨ (JU0QTΛ࣮ݱͯ͠Έ·ͨ͠ w (JU)VCͷ13ૢ࡞ͰΠϯϑϥΛཧͰ͖ΔࣄʹΑΓɺݖݶཧ ϫʔΫϑϩʔΛ៉ྷʹग़དྷͦ͏Ͱ͢ w σϓϩΠΛτϦΨʔ͍ͯͨ͠$*0QTͱൺΔͱ(JU0QTͰɺ $*ͱ$%͕໌֬ʹ͔ΕΔ࣮ͱͳΓͦ͏Ͱ͢
w ࠓճͰ͖ͳ͔ͬͨࣗಈద༻ΑΓྑ͍UBHཧͳͲҾ͖ଓ͖ ͬͯ·͍Γ·͢ !36
͋Γ͕ͱ͏͍͟͝·ͨ͠