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.9k
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
7.2k
Other Decks in Technology
See All in Technology
AWS re:Invent 2024 recap in 20min / JAWSUG 千葉 2025.1.14
shimy
1
100
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!事例のご紹介+座学②
siyuanzh09
0
110
Reactフレームワークプロダクトを モバイルアプリにして、もっと便利に。 ユーザに価値を届けよう。/React Framework with Capacitor
rdlabo
0
130
新卒1年目、はじめてのアプリケーションサーバー【IBM WebSphere Liberty】
ktgrryt
0
120
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
120
Kotlin Multiplatformのポテンシャル
recruitengineers
PRO
2
150
なぜfreeeはハブ・アンド・スポーク型の データメッシュアーキテクチャにチャレンジするのか?
shinichiro_joya
2
470
JAWS-UG20250116_iOSアプリエンジニアがAWSreInventに行ってきた(真面目編)
totokit4
0
140
カップ麺の待ち時間(3分)でわかるPartyRockアップデート
ryutakondo
0
140
GoogleのAIエージェント論 Authors: Julia Wiesinger, Patrick Marlow and Vladimir Vuskovic
customercloud
PRO
0
150
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
I could be Wrong!! - Learning from Agile Experts
kawaguti
PRO
8
3.4k
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
50
11k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
19
2.3k
Side Projects
sachag
452
42k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Rails Girls Zürich Keynote
gr2m
94
13k
Automating Front-end Workflow
addyosmani
1366
200k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
It's Worth the Effort
3n
183
28k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
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