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
GitLab CI/CDとECS Fargateでリリース作業が楽になった話
Search
orfx
April 24, 2019
Technology
2
4.8k
GitLab CI/CDとECS Fargateでリリース作業が楽になった話
2019/04/24(水)
GitLab Meetup Tokyo #16: 新年度応援
https://gitlab-jp.connpass.com/event/126533/
orfx
April 24, 2019
Tweet
Share
More Decks by orfx
See All by orfx
Datadog Logs に ログを集約しようと してる話
orfx
0
6.9k
Other Decks in Technology
See All in Technology
2024-10-30-reInventStandby_StudyGroup_Intro
shinichirokawano
1
630
顧客が本当に必要だったもの - パフォーマンス改善編 / Make what is needed
soudai
24
6.8k
[JAWS-UG金沢支部×コンテナ支部合同企画]コンテナとは何か
furuton
3
260
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
330
とあるユーザー企業におけるリスクベースで考えるセキュリティ業務のお話し
4su_para
3
320
「最高のチューニング」をしないために / hack@delta 24.10
fujiwara3
21
3.4k
20241031_AWS_生成AIハッカソン_GenMuck
tsumita
0
110
新卒1年目が挑む!生成AI × マルチエージェントで実現する次世代オンボーディング / operation-ai-onboarding
cyberagentdevelopers
PRO
1
170
生成AIの強みと弱みを理解して、生成AIがもたらすパワーをプロダクトの価値へ繋げるために実践したこと / advance-ai-generating
cyberagentdevelopers
PRO
1
180
【技術書典17】OpenFOAM(自宅で極める流体解析)2次元円柱まわりの流れ
kamakiri1225
0
210
LeSSに潜む「隠れWF病」とその処方箋
lycorptech_jp
PRO
2
120
グローバル展開を見据えたサービスにおける機械翻訳プラクティス / dp-ai-translating
cyberagentdevelopers
PRO
1
150
Featured
See All Featured
Six Lessons from altMBA
skipperchong
26
3.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Navigating Team Friction
lara
183
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
Designing for humans not robots
tammielis
249
25k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
The Language of Interfaces
destraynor
154
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Transcript
GitLab CI/CD ͱ ECS Fargate Ͱ ϦϦʔε࡞ۀָ͕ʹͳͬͨ GitLab Meetup Tokyo
#16 גࣜձࣾΞΠϦοδ ޱ
Kawaguchi So • ࣗࣾαʔϏεͷӡ༻νʔϜॴଐ • αʔόαΠυΤϯδχΞ • GitLab ྺ1 •
Suzuki V-Strom250 2018.04 ~
ͱ͜ΖͰ օ͞ΜͷपΓʹ͜Μͳ ΦϖϨʔγϣϯ͋Γ·ͤΜ͔ʁ
Before ౿Έαʔό ΞϓϦέʔγϣϯαʔό • ͱ͋ΔίϯϙʔωϯτͷϦϦʔεखॱॻʹه ࡌ͞Ε͍ͯͨίϚϯυܭ 88 ݸͰɺ࡞ۀऀͱ ֬ೝऀ͕ҰͭҰͭ݁ՌΛμϒϧνΣοΫ͠ͳ ͕Β࣮ߦ͍ͯͨ͠
(࣮) ϦϦʔε࡞ۀऀ ϦϙδτϦ 44) BOTJCMF QMBZCPPL HJUDMPOF
ͭΒ͍ ɺɺɺͰ͕͢
ͦΜͳͭΒ͍ӡ༻पΓ GitLab CI/CD Λ ׆༻͢ΔνϟϯεͰ͢
After GitLab 1ͷࢲͰ GitLab CI/CD Λ͑ ϘλϯΛԡ͚ͩ͢ ͷϦϦʔε͕࣮ݱͰ͖·ͨ͠ʂ
ͲΜͳύΠϓϥΠϯΛ ߏஙͨ͠ͷ͔
Build Stage build: stage: build script: - docker build -t
image_name:ci . - docker save image_name:ci -o ${ARTIFACT_PATH} artifacts: paths: - ${ARTIFACT_PATH} expire_in: 1h • docker build ͰϏϧυͨ͠ΠϝʔδΛ docker save ͰϑΝΠϧʹॻ͖ग़͢ɻ • ॻ͖ग़ͨ͠ϑΝΠϧ GitLab ͷ artifacts ػೳͰ δϣϒྃޙʹ GitLab ࣗಈΞοϓϩʔυͤ͞Δɻ
Test Stage unittest: stage: test script: - docker load -i
${ARTIFACT_PATH} - docker-compose up --exit-code-from service_name • artifacts ͰΞοϓϩʔυ͞ΕͨϑΝΠϧ࣍ͷδϣϒ։࢝࣌ ʹࣗಈμϯϩʔυ͞ΕΔͷͰ docker load ͰಡΈࠐΉɻ • ͦͷΠϝʔδΛ༻͍ͯ docker-compose Ͱ UnitTest ʹඞཁ ͳίϯςφҰࣜΛཱͪ͛ͯςετΛ࣮ߦ͢Δɻ
Push Stage push: stage: push script: - docker load -i
${ARTIFACT_PATH} - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker tag image_name:ci $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG • ಉ༷ʹࣗಈμϯϩʔυ͞ΕͨϏϧυΠϝʔδΛಡΈࠐΉɻ • docker login Ͱ GitLab Container Registry ʹϩάΠϯͯ͠ɺ docker push ͰϨδετϦʹΠϝʔδΛΞοϓϩʔυ͢Δɻ
Deploy Stage deploy: stage: deploy variables: RELEASE_TAG: $CI_COMMIT_REF_SLUG script: -
ecs-cli compose -p ${SERVICE_NAME} -f ${CLUSTER_NAME} service up தུ environment: name: ${ENVIRONMENT} when: manual • ECS CLI Ͱ docker-compose ϑΝΠϧΛ༻ͯ͠αʔϏεΞοϓ ͢Δɻ͜Ε͚ͩͰ ECS ͕͍͍ײ͡ʹσϓϩΠͯ͘͠ΕΔ (ࡶ) • σϓϩΠδϣϒ when: manual Λࢦఆͯࣗ͠ಈ࣮ߦ͞Εͳ͍Α ͏ʹ͢Δɻ -> ͜Ε͕ઌ΄Ͳͷԡ͚ͩ͢ͷϘλϯ
δϣϒ࣮ߦ݅Λઃఆͯ͠ޡരࢭ ௨ৗ࣌ ςετলུͯ࣌ؒ͠ॖ ϦϦʔε࣌ͷΈ ຊ൪ڥσϓϩΠ͕ දࣔ͞ΕΔ ϦϦʔε࣌ (λάϓογϡͰύΠϓϥΠϯΛੜ͢Δӡ༻)
ศརͰخ͍͠ػೳ
Artifacts ػೳ • Runner ͕ෳ͋ΔڥͰɺύΠϓϥΠϯதʹผͷ Runner Ͱॲཧ͕࣮ߦ͞Εͯ͠·ͬͯɺδϣϒ࣮ߦʹඞ ཁͳϑΝΠϧΛ؆୯ʹڞ༗͢Δ͜ͱ͕Ͱ͖Δɻ • expire_in
Ͱ༗ޮظݶΛઃఆ͢ΔͱࣗಈͰআͯ͘͠Ε Δɻ • Ξοϓϩʔυͨ͠ϑΝΠϧΣϒαΠτ্͔Βμ ϯϩʔυͰ͖Δɻ
Environment ػೳ deploy: stage: deploy variables: RELEASE_TAG: $CI_COMMIT_REF_SLUG script: -
ecs-cli compose -f compose.yml தུ environment: name: ${ENVIRONMENT} when: manual δϣϒʹڥ໊Λఆ͓͚ٛͯͩ͘͠Ͱ…
Environment ػೳ GitLab ্ʹڥҰཡΛউखʹ࡞ͬͯ͘ΕΔʂ
Environment ػೳ • ڥຖʹσϓϩΠཤྺ͕࣌λά͖ͰݟΕΔʂ • ͔͜͜ΒϘλϯҰͭͰҙ࣌ʹϩʔϧόοΫͰ͖Δʂ
Container Registry ػೳ • Լهਤͷ༷ʹύεΛ۠Δͱผݸʹදࣔ͞ΕΔͷͰ nginx ͳͲαΠυΧʔతͳίϯςφΛಉҰϓϩδΣΫτ ͰҰݩཧ͢Δࡍʹศརɻ
Container Registry ͱ Fargate Fargate Secrets Manager Container Registry ᶃ
ᶄ ᶅ ᶆ 1. CI/CD ͕ Registry ʹΠϝʔδΛϓογϡ 2. CI/CD ͕λεΫఆٛͱαʔϏεΛߋ৽ AWS७ਖ਼ͷ Container Registry (ECR) ͡Όͳͯ͘ Deploy Token ͱ Secrets Manager Ͱ Fargate ʹσϓϩΠͰ͖·͢ʂ 3. Fargate ͕ SM ͔Β Deploy Token Λೖख 4. Fargate ͕ Deploy Token ΛͬͯΠϝʔδΛऔಘ
ຊͷ·ͱΊ • GitLab ʹӡ༻୲ऀʹخ͍͠ศརͳػೳ͕ Γͩ͘͞Μʂ • ͳΜͱ͜ΕΒͷػೳΛࡌͨ͠ GitLab ແྉ Ͱ͍࢝ΊΔ͜ͱ͕Ͱ͖·͢ʂ
• ͳ͓ɺແঈ൛ʹҰ෦ػೳ੍ݶ͕͍͟͝·͢ɻ ࠓ͙͢ొ
ຊൃද͖͠Εͳ͔ͬͨ ECS Fargate पΓͷҠߦ ΞΠϦοδ։ൃऀϒϩά ʹͯ ެ։தʂ EC2 ͰՔಇ͍ͯ͠ΔγεςϜΛ ECS
Fargate ʹҠߦͤ͞Δ https://iridge-tech.hatenablog.com/entry/2019/04/24/162758