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
670
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
RubyLSPのマルチバイト文字対応
notfounds
0
120
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Jakarta EE meets AI
ivargrimstad
0
660
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
ヤプリ新卒SREの オンボーディング
masaki12
0
130
CSC509 Lecture 13
javiergs
PRO
0
110
距離関数を極める! / SESSIONS 2024
gam0022
0
290
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
140
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Embracing the Ebb and Flow
colly
84
4.5k
Designing for Performance
lara
604
68k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
What's new in Ruby 2.0
geeforr
343
31k
Statistics for Hackers
jakevdp
796
220k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
A better future with KSS
kneath
238
17k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
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
͋Γ͕ͱ͏͍͟͝·ͨ͠