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
7k
Other Decks in Technology
See All in Technology
Taming you application's environments
salaboy
0
200
OTelCol_TailSampling_and_SpanMetrics
gumamon
1
220
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
150
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
630
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
Lexical Analysis
shigashiyama
1
150
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Scaling GitHub
holman
458
140k
Happy Clients
brianwarren
98
6.7k
Designing Experiences People Love
moore
138
23k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Code Review Best Practice
trishagee
64
17k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
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