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
Kubernetes (EKS) で構築する スケーラブルなジョブ実行基盤
Search
Kenta Suzuki
August 28, 2019
Technology
7
6.1k
Kubernetes (EKS) で構築する スケーラブルなジョブ実行基盤
Kenta Suzuki
August 28, 2019
Tweet
Share
More Decks by Kenta Suzuki
See All by Kenta Suzuki
trocco®での インシデント重大度表(SEVレベル表)運用
kekekenta
0
2.2k
Ruby はじめての型 Gotanda.rb 2023/04/20
kekekenta
0
250
trocco® の品質を守る、とても普通な取り組み
kekekenta
0
4.4k
Embulkを利用したデータ統合SaaSの構築と運用
kekekenta
2
4.5k
Other Decks in Technology
See All in Technology
AGIについてChatGPTに聞いてみた
blueb
0
130
Engineer Career Talk
lycorp_recruit_jp
0
190
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.2k
強いチームと開発生産性
onk
PRO
35
11k
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
Lexical Analysis
shigashiyama
1
150
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
390
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
4
230
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
180
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
GraphQLとの向き合い方2022年版
quramy
43
13k
Fireside Chat
paigeccino
34
3k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Into the Great Unknown - MozCon
thekraken
32
1.5k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
The Language of Interfaces
destraynor
154
24k
4 Signs Your Business is Dying
shpigford
180
21k
KATA
mclloyd
29
14k
Docker and Python
trallard
40
3.1k
Making Projects Easy
brettharned
115
5.9k
What's new in Ruby 2.0
geeforr
343
31k
Transcript
Kubernetes (EKS) Ͱߏங͢Δ εέʔϥϒϧͳδϣϒ࣮ߦج൫ Kenta Suzuki (twitter: @kekekenta) CTO, primeNumber
inc 2019/8/28 Kubernetes Meetup Tokyo #22
ࣗݾհ • Kenta Suzuki • twitter: @kekekenta • CTO, primeNumber
inc. εϥΠυͷ࠷ޙʹձࣾհࡌͤ·ͨ͠ͷͰɺ͝ڵຯ͋Γ·ͨ͠Βޚཡ͍ͩ͘͞ •ੳج൫ߏஙɾӡ༻ࢧԉSaaSʮtrocco®ʯ
.Z42- 4 4BMFTGPSDF #JH2VFSZ ੳج൫ߏஙɾӡ༻ σʔλసૹ αϚϦʔςʔϒϧ࡞ σʔλࢹ ֎෦࿈ܞ
.Z42- 4 4BMFTGPSDF #JH2VFSZ σʔλసૹ αϚϦʔςʔϒϧ࡞ σʔλࢹ ֎෦࿈ܞ ੳج൫ͷߏஙɾӡ༻Λ·ͱΊͯΧόʔ
troccoͷσʔλసૹδϣϒ • σʔλιʔε • MySQLɺPostgreSQLɺSQLServerͳͲ • εέδϡʔϧ࣮ߦ • ࠷1ִؒ ҙͷσʔλιʔεͷςʔϒϧͷ༰ΛDWHʹసૹ
troccoͷσʔλసૹ෦OSSͷembulkΛଟ༻͍ͯ͠·͢ɻ ͜ͷΛआΓͯɺίϛολʔͷํʑɺembulkίϛϡχςΟͷํʑʹײँਃ্͛͠·͢ɻ ࠓޙembulkͷpluginެ։Ͱߩݙ͍ͯ͘͠༧ఆͰ͢ʂ
troccoͷసૹδϣϒ • δϣϒ࣮ߦ • ʙ10,000/ • δϣϒ͝ͱͷ࣮ߦ࣌ؒ • min: 5s
ʙ max: 5h • ࣮ߦ࣌ؒଳ • ࣌ؒʹ1ͷεύΠΫ
Fan out on ECS چΞʔΩςΫνϟ
Fan out on ECSαʔϏε SQS εέδϡʔϥʔ 8PSLFS &$4UBTL 8PSLFS &$4UBTL
8PSLFS &$4UBTL ECS ECS NODE δϣϒ polling
λεΫεέʔϧΞτͷλΠϛϯά͍͠ • SQSͷΩϡʔͷαΠζΛࢹ • CloudwatchϝτϦΫε͕࠷1͝ͱ • εέʔϧ·Ͱɺ1ͨͳ͍ͱߦ͚ͳ͍
ϗετεέʔϧΞτͷλΠϛϯά͍͠ • λεΫ͕͏ՃͰ্ཱ͕ͪΔϦιʔε͕ ͳ͘ͳͬͨΒεέʔϧ • ىಈͪͷλεΫ͕ग़དྷͨλΠϛϯάͰϗ ετεέʔϧͯ͠΄͍͠ɻɻ
λεΫεέʔϧΠϯ͍͠ • ECSλεΫΛ҆શʹऴྃͤ͞Δඞཁ͕͋Δ • సૹδϣϒ5hʹٴͿ߹͋Δ • TERMγάφϧͷτϥοϓͯ͠graceful shutdownΛ ࣮ •
ͨͩ͠ɺECSͷίϯιʔϧ্ͷ࣮ߦதλεΫҰཡ͔ΒɺTERMΛૹͬͯ͠Β͘͢Δ ͱফ͑ͯ͠·͏
ϗετͷεέʔϧΠϯ͍͠ • Auto Scaling Group ͷ Life cycle hook ΛͬͯɺΠϯ
ελϯεఀࢭલʹDRAININGΛ࣮ࢪ • ىಈதͷλεΫ͕ͳΔ·Ͱࢹ͠ɺͳ͘ͳͬͨΒΠϯε λϯεఀࢭΛ͢͢ΊΔ • લड़ͷ௨ΓɺىಈதͷλεΫҰཡ͔Βফ͑ΔͨΊ͝ʹΐ ͝ʹΐͬͯͨ
Ϧιʔεׂ • సૹߴԽΦϓγϣϯͱͯ͠ɺCPU/ϝϞϦ্ݶΛઃఆ Ͱ͖ΔΑ͏ʹ͍ͨ͠ • ECSͰλεΫ͝ͱʹϦιʔε্ݶΛઃఆͰ͖Δ͕ɺى ಈ࣌ͷΈ • Ϧιʔε্ݶ͝ͱʹαʔϏεΛ͚Δඞཁ͕͋Γ
͍͠
ͦ͜Ͱɺk8s
k8sͷpodεέδϡʔϥʔʹͭ ͍ͯ
k8sͷpodεέδϡʔϥʔʹͭ ͍ͯ
k8sͷpodεέδϡʔϥʔʹͭ ͍ͯ statusͷભҠ "Pending" -> "Running" -> "Succeeded"
k8sͷpodεέδϡʔϥʔ • nodeϦιʔεͷۭ͖ঢ়گʹԠͯ͡ɺεέδϡʔϥʔ͕ॱ࣍podΛ nodeʹׂΓͯͯ͘ΕΔ • podΛ࡞͓͚ͯ͠ɺ͋ͱ࣮ߦ͞ΕΔͷΛ͚ͭͩ ,VCFSOFUFT QPE /0%& QPE
QPE pod্ཱͪ͛ ࣮ߦͪpod create pod
ͱΓ͋͑ͣࡶʹpodΛcreate͢Ε ɺ͋ͱk8s͕࣮ߦ·Ͱ໘ݟ ͯ͘ΕΔ
ϊʔυͷεέʔϧΞτ/Πϯ • EKSͷ߹ɺcluster autoscalerΛ͏ͷ͕σϑΝΫτʢͱ ࢥΘΕΔʣ https://github.com/kubernetes/autoscaler/tree/master/ cluster-autoscaler/cloudprovider/aws • podεέδϡʔϦϯάͷঢ়گʹԠͯ͡ɺEC2ϊʔυͷASG ܦ༝ͰεέʔϧΠϯɾΞτΛͬͯ͘ΕΔ
ϊʔυͷεέʔϧΞτ QPE &$/0%& QPE QPE 1FOEJOH ࠓͷnodeϦιʔεͰɺ podΛ্ཱͪ͛Δ͜ͱ͕ग़དྷͳ͍
ϊʔυͷεέʔϧΞτ QPE &$/0%& QPE &$/0%& QPE ClusterAutoscaler͕ASGܦ༝ͰnodeΛεέʔϧΞτ
ϊʔυεέʔϧΠϯ QPE &$/0%& QPE &$/0%& QPE
ϊʔυεέʔϧΠϯ QPE &$/0%& QPE &$/0%& Ϧιʔεʹ༨༟͕͋Δ
ϊʔυεέʔϧΠϯ QPE &$4/0%& QPE εέʔϧΠϯ
1. create pod ࣮ͯ͠ߦΛͭ 2. ඞཁʹԠͯ͡ɺnode͕εέʔϧΞ τ͢ΔͷΛͭ εέʔϥϒϧδϣϒج൫ര
k8sʹΑΔδϣϒج൫
ݱࡏͷΞʔΩςΫνϟ SQS εέδϡʔϥʔ 8PSLFS 1PE +PC %JTQBUDIFS Kubernetes δϣϒ create
pod schuedule pod &,4/0%& 8PSLFS 1PE $MVTUFS "VUPTDBMFS Scale in/out
Job Dispatcher SQS εέδϡʔϥʔ 8PSLFS 1PE Kubernetes δϣϒ create pod
schuedule pod &,4/0%& 8PSLFS 1PE $MVTUFS "VUPTDBMFS Scale in/out +PC %JTQBUDIFS
Job Dispatcher ˞ίʔυΠϝʔδͰ͢ • SQS Λ polling • k8s API
ʹϦΫΤετΛ͛ɺ pod Λ࡞
Job Dispatcher ˞ίʔυΠϝʔδͰ͢ LT"1*ʹϦΫΤετ • SQS Λ polling • k8s
API ʹϦΫΤετΛ͛ɺ pod Λ࡞
Job Dispatcher ˞ίʔυΠϝʔδͰ͢ EPDLFSΠϝʔ δͷλάࢦఆ • SQS Λ polling •
k8s API ʹϦΫΤετΛ͛ɺ pod Λ࡞
Job Dispatcher ˞ίʔυΠϝʔδͰ͢ QPEͰ࣮ߦ͢Δ ίϚϯυΛࢦఆ • SQS Λ polling •
k8s API ʹϦΫΤετΛ͛ɺ pod Λ࡞
Job Dispatcher • SQS Λ polling • k8s API ʹϦΫΤετΛ͛ɺ
pod Λ࡞ ˞ίʔυΠϝʔδͰ͢ $16ϝϞϦࢦఆ
Worker pod SQS εέδϡʔϥʔ +PC %JTQBUDIFS Kubernetes δϣϒ create pod
schuedule pod &,4/0%& $MVTUFS "VUPTDBMFS Scale in/out 8PSLFS 1PE 8PSLFS 1PE
Worker pod • ࣮ࡍͷసૹΛ࣮ߦ • సૹ։࢝Ͱ্ཱ͕ͪΓɺసૹ͕ऴྃͨ͠Βpodऴྃ ˞ίʔυΠϝʔδͰ͢
Cluster autoscaler SQS εέδϡʔϥʔ +PC %JTQBUDIFS Kubernetes δϣϒ create pod
schuedule pod &,4/0%& Scale in/out 8PSLFS 1PE 8PSLFS 1PE $MVTUFS "VUPTDBMFS
Cluster autoscaler ˞ίʔυΠϝʔδͰ͢
k8sδϣϒج൫ಋೖͷՌ • ѹతίετݮʹޭ • εέʔϧͷλΠϛϯά͕͍͕͍͍͠ ײ͡ʹղܾͰ͖ͨ • cluster autoscaler༷༷ •
։ൃڥͱຊ൪ڥͷಉҰԽ
ࢹʹ͍ͭͯ • create podͰ͖ͳ͍ • pod͕pendingͷ··্ཱ͕ͪΒͳ͍ • pod͕runningதʹಥવࢮ ຊ൪ӡ༻࣮͕ແ͍ͷͰɺຊʹظ௨Γʹ ಈ͔͘ͱ͍͏ҙຯͰࢹΛ࣮ࢪ
troccoͷδϣϒεςʔλεભҠ • DB্ʹδϣϒ͝ͱͷεςʔλεΛอ࣋ • dispatcherpodͳͲ͕ͦΕͧΕߋ৽͢Δ RVFVFE TFUUJOH@VQ FYFDVUJOH TVDDFFEFE SQSʹΩϡʔΠϯά
create pod ྃ pod্ཱ͕ͪΓ·Γ pod͕࣮ߦத సૹྃ
redashͰͷࢹ RVFVFE TFUUJOH@VQ FYFDVUJOH TVDDFFEFE ֤εςʔλεͰཹ͍ͯͨ͠ΒΞϥʔτ
·ͱΊ • γϯϓϧ • k8sͷݞʹΕɺεέʔϥϒϧͳδϣϒج൫ߏஙγϯϓ ϧʹͳΔ • ࢹ • ӡ༻࣮͕ແ͍ͷͰɺͱΓ͋͑ͣऔΕΔσʔλͱ͓ͬͯ͘
• k8sͷҠߦΛৼΓฦͬͯ • όον͔Βk8sಋೖ͢ΔͷׂͱΓ͍͢ͷͰ͓͢͢Ί • কདྷతʹ • কདྷతʹɺϗετͷཧͱ͔Βͳͯ͘ྑ͘ͳΔͱخ͍͠
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠ :bow Α͚Εձࣾհޚཡ͍ͩ͘͞
גࣜձࣾ primeNumber • 201511݄ ઃཱ • ࣾһ9໊ʢ͏ͪΤϯδχΞ8໊ʣ ύʔτφʔΤϯδχΞ30໊Ҏ্ • 201811݄
trocco®ϦϦʔε • 20197݄ γϦʔζAࢿۚௐୡʢ1.3ԯԁʣ࣮ࢪ https://primenumber.co.jp
ಇ͘ڥ • @தࠇͷԊ͍ • ίΞλΠϜ੍ • 11ʙ15࣌ • िதɺ2·ͰϦϞʔτՄ ※ࢼ༻த
• δϜશֹิॿ
We are hiring • ιϑτΣΞΤϯδχΞ • ΠϯϑϥΤϯδχΞ • ͳͲͳͲɺଟํ໘ઈࢍืूத