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
Bloxが切り開くECSの世界
Search
Koji Nakayama
August 26, 2017
Technology
1
1.1k
Bloxが切り開くECSの世界
第二回 合同勉強会 in 福岡 の発表資料です。
https://connpass.com/event/60964/
Koji Nakayama
August 26, 2017
Tweet
Share
More Decks by Koji Nakayama
See All by Koji Nakayama
Software Testing in AWS IoT with The Power of Python
knakayama
0
1.5k
The ~~Ten~~ Three Most Critical Security Risks in Serverless Architectures
knakayama
2
1.4k
サーバーレス x IoT 〜我々はどういった課題に直面してそれをどのように解決したのか〜
knakayama
0
1.3k
AWS Serverless Application Modelのデプロイ戦略
knakayama
4
2.3k
github-classmethod-study-20170426
knakayama
1
3.6k
サーバレスアーキテクチャはじめの一歩
knakayama
1
1.4k
Other Decks in Technology
See All in Technology
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
UI State設計とテスト方針
rmakiyama
2
690
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
190
なぜCodeceptJSを選んだか
goataka
0
170
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
170
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
990
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
260
AWS re:Invent 2024 ふりかえり勉強会
yhana
0
270
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
640
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
200
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
300
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
130
Featured
See All Featured
For a Future-Friendly Web
brad_frost
175
9.4k
Fireside Chat
paigeccino
34
3.1k
Making the Leap to Tech Lead
cromwellryan
133
9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
100
Producing Creativity
orderedlist
PRO
342
39k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
A designer walks into a library…
pauljervisheath
205
24k
Optimising Largest Contentful Paint
csswizardry
33
3k
GraphQLとの向き合い方2022年版
quramy
44
13k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Transcript
Blox͢ڔΠ樄ͥECS΄Ӯኴ ᒫԫࢧ ݳݶۣ䔶տ in ᐰ䍫 #gbfukuoka 2017/08/26 Ӿઊ ଛလ 1
ᛔ૩奧Օ • Ӿઊ ଛလ • μ϶φϮϊϐϖ ϯϝαϸίϤϷςЄϠφ᮱ AWSϊϷϲЄτϴЀίЄκϓμϕ • AWSΨڥአͭ͵αЀϢ϶΄戔懯/䯤塈
• GitHub: knakayama • 奺䵉 • ηЀϤϹςЄϝ΄晁አ3ଙ • AWSΚΠ͵͡͵΄ͽμ϶φϮϊϐϖ敢实 • ๋ᬪϯϝαϸίϤϷςЄϠφ᮱Ύ吖㵕 2
ίυδЀύ 1. ECS΄ͫ͠Ο͚ 2. Blox΄扖 3. Δ;Η 3
෭΄ρЄϸ • ECS/Bloxͺ͚ͼᎣΡ • Blox΄ਂࣁఽ͢ᡀ͚΄ͽ ECSΨֵ͜ӤͽBlox;͚͜晝䝑ᙏ͢ਂ ࣁͯΡͩ;ΨᎣΡ • ེ๗ϷϷЄφݻͧBlox΅嘦䋚昲۸ͭͼ͚Ρ΄ͽͳ΄๗இఽ ΨوํͯΡ
4
1. ECS΄ͫ͠Ο͚ 5
ͳ΄ڹ ͳΘͳΘΩͽECSֵ͜΄͡ 6
ςЄϝϹφͮΙͶΗΩͽͯ͡ ! 7
ςЄϝϹφ is • ϜϫΡ䦒΅๋ṛ ! • ͽΘݻͣӧݻͣ͘ΠΔͯΞ • ϢϹЄϭϼЄμֵ͚͵͚ΩͽͯͧͿ •
RDSֵ͚͵͚ΩͽͯͧͿ • Ϳͭ͜ͼΘګᴴ͢… • ϫϚЄυϖςЄϠφ΄ͽϳЄσ㯎ͽͽͣΡͩ;͢ᴴΟΡ • ق᮱Lambdaضኞ͠氎͚ͽͣ͵Ο๋ṛͶͧͿ柞΄䔺ԃ΅͚ 8
ECS΄͚ͭ͜;ͩΣ • ϳЄσͽᓕቘͽͣΡ᮱ړ;AWS͠Δ͡ͱͽͣΡ᮱ړ΄䂜͢Ξ͚ • Devፓ娄 • πЀϓϗͽ㵕֢ͫͱΡϊЄφπЄϖ;DockerfileΨᓕቘͯΆ͚͚ • Opsፓ娄 •
ϔϤϺα͢䮭 → αϮЄυ֢ͼϔϤϺαͯΆECS͢ΞͭΚͼͥΡ • CloudFormationͽᓕቘͽͣΡ;ͩΣΘΞ͚ • ٖ᮱ጱEC2ֵͼΡ΄ͽϳЄσ㯎ͽϷϊЄφ䃀ΚͱΡ • Lambda/API GatewayͶ͵ΟͿ͜ΡҘ • ECSᛔ֛΅僻ා 9
ECS༷ᥝ • AWSͽDockerπЀϓϗΨᓕቘͯΡ͵Η΄ϫϚЄυϖςЄϠφ • DockerπЀϓϗΨ֜㳌/Ϳ͜ΚͼᯈᗝͫͱΡ΄͡ • ՜AWSςЄϠφ;昧൭ͭͼπЀϓϗΨᓕቘͽͣΡ • Auto Scaling
Group/CloudFormation/CloudWatch/etc... • ECSᛔ֛΅僻ාͽڥአݢᚆ • ՜΄AWSςЄϠφ䌏ͯΡ抓ᰂ • ԆEC2/S3 10
ECS΄ͫ͠Ο͚(ͳ΄1) • πЀϓϗαЀφόЀφ • Amazon ECS container agent͢㵕֢ͯΡEC2αЀφόЀφ • πЀϓϗαЀφόЀφӤͽDockerπЀϓϗ͢㵕֢ͯΡ
• Ӟᛱጱ΅Amazon ECS container agent͢αЀφϕЄϸͫ͵ECS-optimized AMI͡Ο᩸㵕ͫͱΡ • चጱDockerπЀϓϗ͢ڥአͯΡϷϊЄφ΄ϤЄϸ;ͭͼᘍ͞ͼᜉ͚ • μ϶φό • 1ͺզӤ΄πЀϓϗαЀφόЀφᮭ • DockerπЀϓϗ΅μ϶φόٖ΄ϷϊЄφ(CPU/ϮϯϷͿ)Ψڥአͭͼ䋚ᤈͫΡ 11
ECS΄ͫ͠Ο͚(ͳ΄2) • όφμਧ嬝 • Ϳ͚͜͵戔ਧͽDockerπЀϓϗΨ᩸㵕ͫͱΡ͡΄ਧ嬝 • Ϳ΄αϮЄυ͡ΟDockerπЀϓϗΨ᩸㵕ͫͱΡ͡ • Ϳ΄ᑕଶμ϶φόٖ΄ϷϊЄφ(CPU/ϮϯϷ)Ψֵ͞Ρ͡ •
etc... • όφμ • όφμਧ嬝चͻͣ᩸㵕ͭ͵DockerπЀϓϗ 12
ECS΄ͫ͠Ο͚(ͳ΄3) • ECR(Elastic Container Registry) • IAMचͻͣίμψφګகݢᚆϫϚЄυϖϤ϶αϦЄϕϷ ϪυϕϷ • ӞᛱጱECSͽᇿᛔ΄αϮЄυΨڥአͯΡ䁰ݳ΅ECRΨֵ͜
• כਂͭ͵αϮЄυςαχ䖕ͮͼ抓ᰂͫΡ • ٖ᮱ጱS3͢ڥአͫͼ͚Ρ 13
㾩ͯΡ;ͩΩఽͮ 14
ECS΄Ԇᥝ༷ஷ(ͳ΄4) • ςЄϠφ • ECSͧ͠ΡφξυϲЄ϶(;ᘍ͞ͼΘय़ͣͥϜχϹͼ͚) • ςЄϠφΨ᭗ͭͼόφμΨ᩸㵕ͫͱΡͩ;ͽόφμΨ๗இͭ͵ᇫ䙪φξυϲЄϷЀνͭͼͥΡ • ͚ͥͺόφμΨ᩸㵕ͫͱΡ͡/Ϳ΄πЀϓϗαЀφόЀφόφμΨᯈᗝͯΡ͡Ϳ •
όφμᯈᗝ䜐ኼ/όφμᯈᗝګᴴ • ςЄϠφ͡Ο᩸㵕ͯΡόφμΨͿ͚͜͵ϸЄϸͽμ϶φόӤᯈᗝͯΡ͡ • μ϶φό΄ϷϊЄφၾ揲ᰁ๋͢ੜΡΞͭ͜͵͚(όφμᯈᗝ䜐ኼ) • ṛ͚αЀφόЀφόαϤ΄πЀϓϗαЀφόЀφ΄Εᯈᗝͫͱ͵͚(όφμᯈᗝګᴴ) • ՜Θ奞ͥ͡ਧݢᚆ 15
ECS΄Ԇᥝ༷ஷ(ͳ΄5) • όЄοϐϕνϸЄϤ(㷗ੂ΅ALB΄༷ஷ) • ALB͡Οόφμϕ϶ϢΰϐμΨϸЄϓΰЀνͯΡ͵Η΄㶨֖ • όЄοϐϕνϸЄϤ΅ςЄϠφ;樛昧՞ͧͫݱόφμϕ϶Ϣΰϐμ͢ၞΡ • ALB΅όЄοϐϕνϸЄϤΎ΄ϥϸφώδϐμΨ᭗ͭͼςЄϠφϔΰφθϝϷΨ䋚匍ͯΡ •
ύαϗϬϐμϨφϕϪЄϕϫϐϡЀν • πЀϓϗαЀφόЀφ;όφμͽڥአͯΡϪЄϕΨ㵕ጱϫϐϡЀνͭͼͥΡ䱛ᚆ • ͚ͩ͢;ݶͮϪЄϕΨڥአͯΡόφμ͢ݶӞπЀϓϗαЀφόЀφͽ᩸㵕ͽ͚ͣ • CLB΅䌏䖕ͭͼ͚ 16
㾩ͯΡ;ͩΩఽͮ 17
ECS΄Ԇᥝ༷ஷ(ͳ΄6) • ECS Events • ECSٖ΄ᇫ䙪䄜۸᩸ͣ͢͵䁰ݳCloudWatch EventsΎͫΔͬΔ αϦЀϕΨᭆͼͥΡ • πЀϓϗαЀφόЀφ/όφμ᩸͢㵕
or ؊ྊͭ͵/etc... • ՜΄AWSςЄϠφΨόЄοϐϕͯΡͩ;ͽαϦЀϕϖϷϣЀ㳌 ቘ͢ݢᚆ • Slack᭗ᎣͯΡ/ෛ͚ͭόφμΨ᩸㵕ͫͱΡ/etc... 18
2. Blox΄扖 19
Blox༷ᥝ • ECSͽ㵕֢ͯΡπЀϓϗ΄θφόϭφξυϲЄ϶ • ECS㶨֛ͽ΅櫞͚ͭφξυϲЄϷЀνΨ䋚匍ͽͣΡ • 2016ଙ΄re:Inventͽ咲ᤒͫ͵ • Apache2.0΄ηЄϤЀϊЄφϤϺυδμϕ •
v0.3.0;v1.0͢ਂࣁ • 匍ࣁv1.0Ύ妣搒ᑏᤈӾ • v1.0΅ΔͶྋୗϷϷЄφͫͼ͚ https://github.com/blox/blox 20
v0.3.0;v1.0΄晅͚ • v0.3.0΅ϊЄφπЄϖل樄ͭ͵͡ΟΕΩͽ樄咲ͭͼ͚ͩ͜Ͳ;͚͜ఽͮ • Go䋚ᤰ • Bloxአ΄厏हΨᛔړͽ֢Ρᥝ͘͢Ρ • Deprecated •
v1.0΅ϫϚЄυϖςЄϠφΨፓͭͼ͚Ρ • ͺΔΠ ECS΄䱛ᚆ;ͭͼ׀ͫΡ (Ԩਧ) • ϫϚυϮЀϕπЀϊЄϸ/CLI/SDKs͡Ο֢ݢᚆ(Ԩਧ) • Java䋚ᤰ https://github.com/blox/blox/blob/dev/FAQ.md 21
v0.3.0;v1.0ͽ΅Ͷ͚Ό晅͜΄ͽ ړͧͼ抍กͭΔͯ 22
ͳ΄ڹͲθφόϭφξυϲЄ϶ ͢ᥝ΄͡ ! 23
ECS΅ͯͽԆᥝφξυϲЄϷЀ νොୗΨςϪЄϕͭͼ͚Ρ 24
όφμᯈᗝ䜐ኼ 䜐ኼ ޱ binpack μ϶φό΄CPU/ϮϯϷၾ揲ᰁ๋͢ ੜ;ΡΞ͜όφμΨᯈᗝ random μ϶φόόφμΨ϶Ѐύϭͽᯈᗝ spread ਧͭ͵ં
/ instanceId / host ࣐͢ᒵΡΞ͜όφμΨᯈᗝ http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html 25
όφμᯈᗝګᴴ ګᴴ ޱ distinctInstance όφμ͢吖ΡπЀϓϗαЀφ όЀφᯈᗝͫΡΞ͜ګᴴ memberOf Cluster Query Languageͽᤒ匍
ͭ͵ୗΨ伋͵ͯΞ͜όφμ΄ ᯈᗝΨګᴴ http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html 26
ͳ΄՜ • ςЄϠφ΄Desired Countͽ๕ͯΡόφμහΨ姘೮ • ALB/CLB΄ϥϸφώδϐμΨڥአͭ͵ςЄϠφϔΰφθϝϷ • CloudWatch Metricsचͻ͚͵ςЄϠφ΄ηЄϕφξЄϷЀν •
RunTask or StartTask APIͽձ΄όαϬЀνͽόφμΨ᩸㵕 • cron୵ୗͽᇙਧ΄䦒樌όφμΨ᩸㵕 http://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduling_tasks.html 27
ϔϢζϸϕ΄φξυϲЄ϶ͽ΅ᥝկΨ伋͵ͭ ͚ͥ䁰ݳ • μ϶φό΄ᇫ䙪䖕ͮ͵αϦЀϕϖϷϣЀόφμ΄ᯈᗝ • πЀϓϗαЀφόЀφ᩸͢㵕/؊ྊͭ͵ΟόφμΘ᩸㵕/؊ྊͯΡ • ΞΠ愢櫏ϥϸφώδϐμचͻ͚͵όφμ΄ᯈᗝ • ALB΅HTTP(S)ϹϦϸ΄ϥϸφώδϐμͭ͡ͽ͚ͣ
• CLBͽ΅φξЄϸ͚ͭͥ(ύαϗϬϐμϨφϕϪЄϕϫϐϡЀν๚䌏䖕 ΄ͽ) 28
BloxΞͼ๗இͽͣΡͩ; • θφόϭφξυϲЄ϶Ψ樄咲ͭͼ͚ͥच哷;ΠΡ • ෬ਂAWSςЄϠφΨ奲ΕݳΥͱͼᇿᛔφξυϲЄ϶Ψ֢౮ͯΡͩ;΅ݢᚆ • ͚ͭͭ͡ͷ͚ͷᛔړͽ՛奲ΕΨ֢Π旿Ζᥝ͘͢Ρ • ηЄϤЀϊЄφͯΡͩ;ΞΠπϬϲϘϓΰϦЄφͽ樄咲ͽͣΡ •
՜΄Ո֢͢͵φξυϲЄ϶Ψ䌙فͯΡΕ͵͚ͩ;ΘͽͣΡ෭͢Ρ͡Θ • ECS΄䱛ᚆ΄ӾͽθφόϫαχͽͣΡ • KubernetesΘ͚͚ͧͿՈ(AWS)΄ᙒ㪥Π͵͚ 29
ྋፗ͚͜;ϔϢζϸϕφξυϲЄ ϶ͽᥝկ伋͵ͱ͚厏ह᭺᭬ͭ͵ ͩ;΅ΔͶ͚ ! 30
v0.3.0ͺ͚ͼ 31
v0.3.0΄༷ᥝ • μ϶φό΄ᇫ䙪ᓕቘ;ςЀϤϸ;ΡφξυϲЄ϶͢ݶ䬕 • cluster-state service → ᇫ䙪ᓕቘ • daemon-scheduler
→ φξυϲЄ϶ • ͩΟΨREST APIͽ֢ݢᚆ • ϺЄθϸPC/AWSϔϤϺαݢᚆ • DockerαϮЄυΘአͭͼͥͼ͚Ρ • ᛔړͽGoΨπЀϞαϸͯΡͩ;ΘݢᚆͶ͢πЀϓϗͽ㵕ͯ͡;͠ಋ敽 • 厏हΨ䯤塈ͯΡ͵Η΄ςЀϤϸCloudFormationϓЀϤϹЄϕΘ͘Ρ • DeprecatedͶ༷͢ஷᛔ֛΅v1.0;֒ͼ͚Ρ΄ͽ݇ᘍΡ 32
cluster-state service • μ϶φό΄ᇫ䙪ΨϷίϸόαϭᓕቘ • μ϶φόෛ͚ͭπЀϓϗαЀφόЀφ/όφμ᩸͢㵕 or ؊ྊͭ͵Ϳ • ͩΟ΄ఘ䁭Ψetcdכਂ
• cluster-state service΄ఘ䁭Ψڥአͭͼᛔړ΄厏हݳ͵φξυϲЄ϶͢䋚ᤰݢᚆ • 㶨֛ͽ΅μ϶φό΄ᇫ䙪ᓕቘ͚ͭͭ͡ • Ϸίϸόαϭ΄ఘ䁭㷧ᵞECS EventsΨڥአͭͼ͚Ρ • ECS Events΄όЄοϐϕਧͫ͵SQS͡ΟϮϐψЄυΨݐͭͼetcdכਂ • CloudWatch Events/SQS/etcd΅㳨᭔አͯΡᥝ͘Π https://github.com/blox/blox/tree/v0.3/cluster-state-service 33
deamon-scheduler • πЀϓϗαЀφόЀφ䶅1ͺ΄όφμΨᯈᗝͯΡφξυϲЄ϶ • 哶憙/Ϻν㷧ᵞᔮ΄όφμ(Datadog/FluentdͿ)ΨᓕቘͯΡ͵Ηֵ͞Ρ • ݱπЀϓϗαЀφόЀφ䶅όφμ᩸͢㵕ͭͼ͚Ρᥝ͘͢Ρ͵Η • ٖ᮱ጱcluster-state serviceΨڥአͭͼ͚Ρ
• ϷϢήϹЀφϯϔϸ;͚֖͜ᗝ՞ͧ • μ϶φόෛ͚ͭπЀϓϗαЀφόЀφ͢ጭ梍ͫ͵ΟόφμΨ᩸㵕ͫͱΡ • ᭋπЀϓϗαЀφόЀφ͢ڷᴻͫ͵ΟόφμΘڷᴻͯΡ https://github.com/blox/blox/tree/v0.3/daemon-scheduler 34
daemon-scheduler΄Ԇᥝ༷ஷ • Environment • όφμਧ嬝;μ϶φόΨΈΘ՞ͧ͵ఘ䁭 • Environment΄ᇫ䙪Ψdaemon-scheduler͢姘೮ͭΞ͜;ͭͼͥΡ • Environment΅ͥ͘Δͽఘ䁭ͽ͘Πզӥ΄DeploymentΨ䋚ෞͭͼতΗͼECSόφμ ᩸͢㵕ͯΡ
• Deployment • EnvironmentΨμ϶φόӤϔϤϺαͯΡ֢ • DeploymentΨ᭗ͭͼEnvironment͢μ϶φόӤ樄ͫΡ https://github.com/blox/blox/tree/v0.3/daemon-scheduler 35
v0.3.0΄ίЄκϓμώϰ(ϺЄθϸPC) ※ πЀϓϗͽ㵕֢ͫͱ͵䁰ݳ 36
v0.3.0΄ίЄκϓμώϰ(AWS) ※ πЀϓϗͽ㵕֢ͫͱ͵䁰ݳ 37
cluster-state service΄REST API Path(Base Path΅ /v1) Method 㳌ቘ /instances GET
قͼ΄πЀϓϗαЀφόЀφΨᤒᐏ /tasks GET قͼ΄όφμΨᤒᐏ /instances/{cluster}/{arn} GET {cluster} ٖ΄ {arn} ͽਧͫ͵πЀ ϓϗαЀφόЀφΨᤒᐏ /tasks/{cluster}/{arn} GET {cluster} ٖ΄ {arn} ͽਧͫ͵όφ μΨᤒᐏ /stream/instances GET ϞφϞ϶ϮЄόͽਧͫ͵αЀφό Ѐφ΄ఘ䁭ΨφϕϷЄϭͽᤒᐏ /stream/tasks GET ϞφϞ϶ϮЄόͽਧͫ͵όφμ΄ ఘ䁭ΨφϕϷЄϭͽᤒᐏ https://github.com/blox/blox/blob/v0.3/cluster-state-service/swagger/v1/swagger.json 38
deamon-scheduler΄REST API Path(Base Path΅ /v1) Method 㳌ቘ /ping GET HTTPφϓЄόφπЄϖ200Ψᬬᒼ
/environments GET قͼ΄EnvironmentΨᤒᐏ /environments POST EnvironmentΨ֢౮ /environments/{name} GET {name} ͽਧͫ͵EnvironmentΨᤒᐏ /environments/{name} DELETE {name} ͽਧͫ͵EnvironmentΨڷᴻ /environments/{name}/deployments GET {name} ͽਧͫ͵Environment戔ਧͫ ͼ͚Ρقͼ΄DeploymentΨᤒᐏ /environments/{name}/deployments POST {name} ͽਧͫ͵Environment䌏ͭͼ DeploymentΨ֢౮ /environments/{name}/deployments/{id} GET {name} ͽਧͫ͵Environment戔ਧͫ ͼ͚Ρ {id} ;͚͜挷㳨ৼ΄DeploymentΨᤒᐏ https://github.com/blox/blox/blob/v0.3/daemon-scheduler/swagger/v1/swagger.json 39
Environment΄ఘ䁭 $ curl -s 127.0.0.1:2000/v1/environments/test | jq { "deploymentToken": "c6f05550-0c2a-42b9-aa81-f66c3c60853e",
"health": "healthy", "instanceGroup": { "cluster": "arn:aws:ecs:ap-northeast-1:111122223333:cluster/blox2" }, "name": "test", "taskDefinition": "arn:aws:ecs:ap-northeast-1:111122223333:task-definition/nginx:37" } 40
Deployment΄ఘ䁭 $ curl -s 127.0.0.1:2000/v1/environments/test/deployments | jq { "items": [
{ "environmentName": "test", "failedInstances": [], "id": "95d3644f-3624-4324-81fe-35d50583f420", "status": "completed", "taskDefinition": "arn:aws:ecs:ap-northeast-1:111122223333:task-definition/nginx:37" } ] } 41
v1.0ͺ͚ͼ 42
զӥ΄ఘ䁭΅2017/08/26䦒ᅩ΄Θ ΄΄ͽՔ䄜ΥΡݢᚆ͘͢Ρᅩ ဳͭͼͥͶ͚ͫ 43
v1.0΄༷ᥝ • AWSӤͽ㵕֢ͯΡECS΄ϫϚЄυϖθφόϭφξυϲЄ϶ • ECS΄䱛ᚆ;ͭͼ׀ͫΡ΄ͽϳЄσ΅BloxΨԪڹ䯤塈ͯΡᥝ͚͢ • Ӟ䖕ϳЄσ΄AWS厏हͽΘ㵕͡ͱΡ΄ͽᇿᛔθφόϫαχͯΡͩ;Θݢᚆ • ΔͶ戔懯樛ͯΡϖκϲϮЀϕ͘͢ΡͶͧͽ䋚ᤰ΅Α;ΩͿͽͣͼ͚ •
v0.3.0;ݶͮΞ͜ΔͰ΅daemon-schedulerΨ䋚ᤰ • Ք՜΄φξυϲЄ϶Ψ᭄ےͭͼ͚ͥԨਧ • ECS΄ϊЄφπЄϖ΄Ӟ᮱ΨApache 2.0ͽل樄ͭͼ͚ΡҘ • v1.0΄֖ᗝ՞ͧ͢ྋፗΞͥړ͡Ο͚ ! https://github.com/blox/blox/blob/dev/FAQ.md 44
v1.0΄daemon schedulerίЄκϓμώϰ https://github.com/blox/blox/blob/dev/docs/daemon_infrastructure.md#architecture 45
v1.0΄daemon schedulerίЄκϓμώϰ 46
Blox frontend • BloxΨ֢ͯΡ͵Η΄HTTPεЀϖϪαЀϕ • API Gateway;Lambda͡Ο䯤౮ͫΡ • AWS Proxyͽጭ梍ͫ͵Lambda͢䋚檭΄㳌ቘΨ䋚ෞ
• Invokeͫ͵Lambda΅Data ServiceΨΉڊͭDynamoDBΎϔЄόΨכਂ • Ϯϊϐϖ䶅㳨΄LambdaͯΡ΄ͽ΅ͥق᮱1ͺ΄Lambdaͽ㳌ቘͫͱΡ • API Gateway;΅IAMͽ扯戣ͯΡ • ϳЄσ΅Blox frontendΨ᭗ͭͼREST APIͽ֢ͯΡ https://github.com/blox/blox/blob/dev/docs/frontend_design.md 47
Data Service • Environment/Deployment΄ఘ䁭Ψכਂ/ݐͯΡ檭Ήڊͫ ΡAPI • ݱπЀϪЄϚЀϕ΅DynamoDBΨፗള݇ᆙͯΡ΄ͽ΅ͥͩ΄ APIΨ᭗ͭͼϔЄόίμψφͯΡ https://github.com/blox/blox/blob/dev/docs/daemon_design.md#data-service 48
DynamoDB • v0.3.0;΅吖ΠϔЄόφϕί;ͭͼDynamoDBΨڥአͯΡ • Data ServiceአϓЄϣϸ • Environment;Deployment΄ᇫ䙪Ψכਂ • State
ServiceአϓЄϣϸ • ECS΄ᇫ䙪Ψכਂ • Data ServiceአϓЄϣϸ΄DynamoDB Streams奺ኧͽScheduling ManagerΨ ΉڊͭDeploymentΨ䋚ෞ 49
Scheduling Manager • DeploymentΨ䋚ෞͭͼόφμΨπЀϓϗαЀφόЀφӤᯈᗝ • Step Functions͡Ο᩸㵕ͫ͵Lambdaͽ䋚ෞͯΡ • ՔScheduler(Scheduling Controller)᮱ړ΅ڔΠڊͯԨਧ
• Data ServiceΨΉڊͭͼEnvironment/Deployment΄ᇫ䙪Ψݐ /כਂͯΡ • State ServiceΨΉڊͭͼECS΄ᇫ䙪Ψݐ/כਂͯΡ https://github.com/blox/blox/blob/dev/docs/daemon_design.md#scheduling-manager 50
State Service • ECS EventsͽჁͫ͵ఘ䁭ΨDynamoDBכਂͯΡLambda͡Ο䯤౮ͫΡ • ECS΄ᇫ䙪䄜۸᩸ͣ͢͵䁰ݳϷίϸόαϭͽ㳌ቘͯΡͩ;͢ݢᚆ • ݶ䦒Scheduled CloudWatch
Events͡ΟInvokeͫ͵Lambda奺ኧͽμ϶φό΄ᇫ䙪Ψݐ ͯΡΟ͚ͭ • ͵ͶECS Eventsͽ䱛ᚆ͢᪃ΠΡ΄͡䘁ΩͽΡΓ͚ • ECS Events΅ͯΏͼ΄ఘ䁭Ψ㬃晄ͭͼͥΡΥͧͽ΅͚ • αϦЀϕΨݐΠͩΒͯݢᚆ͘͢Ρ • ϳЄσ΄ECS͡ΟAWSίθγЀϕ㯎(ϫϚЄυϖBlox͢䯤塈ͫΡίθγЀϕ)ΎαϦЀϕΨͿ ͜ΚͼᭆΡ΄͡ https://github.com/blox/blox/blob/dev/docs/daemon_design.md#state-service 51
daemon scheduler΄API API 㳌ቘ CreateEnvironment ෛ͚ͭEnvironmentΨ֢౮ StartDeployment ෛ͚ͭDeploymentΨ֢౮ RollbackDeployment զڹ΄Deployment䜟ͯ
StopDeployment DeploymentΨ؊ྊͯΡ UpdateEnvironment EnvironmentΨๅෛ DeleteEnvironment EnvironmentΨڷᴻ GetEnvironment ᇙਧ΄EnvironmentΨᤒᐏ ListEnvironments قͼ΄EnvironmentΨᤒᐏ GetDeployment ᇙਧ΄DeploymentΨᤒᐏ ListDeployments قͼ΄DeploymentΨᤒᐏ https://github.com/blox/blox/blob/dev/docs/daemon_design.md#user-experience 52
v1.0΄Environment΅ͩΩఽͮͽֵ͞ΡҘ # EnvironmentΨ֢౮ $ aws ecs create-environment \ --name <name>
\ --task-definition <task-definition> \ --instance-group <instance-group> \ --role <role> \ --deployment-configuration <deployment-configuration> # قͼ΄EnvironmentΨᤒᐏ $ aws ecs list-environments \ --environment-type <environment-type> # ᇙਧ΄EnvironmentΨᤒᐏ $ aws ecs get-environment \ --environment-name <environment-name> https://github.com/blox/blox/blob/dev/docs/daemon_design.md#user-experience 53
v1.0΄Deployment΅ͩΩఽͮͽֵ͞ΡҘ # DeploymentΨ֢౮ $ aws ecs start-deployment \ --environment-name <environment-name>
\ --environment-version <environment-version> # قͼ΄DeploymentΨᤒᐏ $ aws ecs list-deployments \ --environment-name <environment-name> # ᇙਧ΄DeploymentΨᤒᐏ $ aws ecs get-deployment \ --environment-name <environment-name> \ --deployment-id <deployment-id> https://github.com/blox/blox/blob/dev/docs/daemon_design.md#user-experience 54
3. Δ;Η 55
3ᤈͽ • ςЄϝϹφͽ΅櫞͚ͭ;͵ΟECS΅ᜉ͚晝䝑ᙏ • ECSΨΞΠϞϼϢϸͯΡ䱛ᚆ;ͭͼBlox͘͢Ρ • Blox v1.0΅ϫϚЄυϖςЄϠφΨፓͭͼ͚Ρ 56
͠ΥΠ 57