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.3k
Other Decks in Technology
See All in Technology
スプリントゴールにチームの状態も設定する背景とその効果 / Team state in sprint goals why and impact
kakehashi
2
100
Vueで Webコンポーネントを作って Reactで使う / 20241030-cloudsign-vuefes_after_night
bengo4com
4
2.5k
一休.comレストランにおけるRustの活用
kymmt90
3
580
pandasはPolarsに性能面で追いつき追い越せるのか
vaaaaanquish
4
4.5k
「視座」の上げ方が成人発達理論にわかりやすくまとまってた / think_ perspective_hidden_dimensions
shuzon
2
1.5k
事業者間調整の行間を読む 調整の具体事例
sugiim
0
1.4k
新卒1年目が向き合う生成AI事業の開発を加速させる技術選定 / ai-web-launcher
cyberagentdevelopers
PRO
7
1.5k
最速最小からはじめるデータプロダクト / Data Product MVP
amaotone
5
730
バクラクにおける可観測性向上の取り組み
yuu26
3
410
CyberAgent 生成AI Deep Dive with Amazon Web Services / genai-aws
cyberagentdevelopers
PRO
1
480
フルカイテン株式会社 採用資料
fullkaiten
0
36k
ユーザーの購買行動モデリングとその分析 / dsc-purchase-analysis
cyberagentdevelopers
PRO
2
100
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
327
21k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Become a Pro
speakerdeck
PRO
24
5k
Rails Girls Zürich Keynote
gr2m
93
13k
Faster Mobile Websites
deanohume
304
30k
GraphQLとの向き合い方2022年版
quramy
43
13k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
BBQ
matthewcrist
85
9.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
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