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
kube-state-metrics Sharding
Search
d-kuro
November 02, 2022
Programming
0
310
kube-state-metrics Sharding
https://techfeed.io/events/techfeed-experts-night-7
で発表した資料です。
d-kuro
November 02, 2022
Tweet
Share
More Decks by d-kuro
See All by d-kuro
Helm Chart を Unit Test する / Unit Testing Helm Chart
daikurosawa
0
2k
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
15k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
10k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.3k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
23k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
5k
GolangCI を使ってコードの品質を保ちながら快適な Golang 生活を送る話 #gounco / GolangCI
daikurosawa
4
5.8k
Introduction gRPC
daikurosawa
1
250
Go Cloud を触ってみる / gopher-dojo-lt
daikurosawa
2
2.1k
Other Decks in Programming
See All in Programming
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
190
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
410
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
410
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
280
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
Spatial Rendering for Apple Vision Pro
warrenm
0
110
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
Refactor your code - refactor yourself
xosofox
1
260
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
360
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Building an army of robots
kneath
302
44k
A Philosophy of Restraint
colly
203
16k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
Six Lessons from altMBA
skipperchong
27
3.5k
GitHub's CSS Performance
jonrohan
1030
460k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Transcript
kube-state-metrics Sharding TechFeed Experts Night#7 ʙ ίϯςφٕज़ΛޠΔ
I work for @ponde_m @d-kuro
kube-state-metrics ͱ • Kubernetes ͷ api-server Λࢹ֤ͯ͠छΦϒδΣΫτͷঢ়ଶͷ ϝτϦΫεΛఏڙͯ͘͠ΕΔͭ
• γϟʔυͱݺΕΔখ͞ͳνϟϯΫʹσʔλΛׂ • ෳͷϚγϯͳͲʹ͚ͯอଘ͢Δ͜ͱͰ େنͳσʔληοτΛཧ • Ԡͷ্ͳͲʹ༻͍ΒΕΔ Sharding
• Α͋͘Δσʔλϕʔεͷ Sharding ͷҰྫ Sharding https://aws.amazon.com/jp/blogs/news/sharding-with-amazon-relational-database-service/
Kubernetes controller ͷ Sharding • controller ௨ৗɺϦʔμʔબग़ͰϦʔμʔͱͳͬͨ Pod ͷΈ͕
reconcile Λߦ͏ͱ͍͏Ξϓϩʔνʹͳ͍ͬͯΔ https://speakerdeck.com/daikurosawa/leader-election-in-kubernetes-number-k8sjp
• ͪΐͬͱલʹʹͳͬͨͭ • Sharder ͕ϥϕϧΛׂΓৼͬͯ ͲͷγϟʔυͰॲཧ͢Δ͔Λ ܾఆ͢Δ •
ͬͪ͜ͷࠓ͠·ͤΜ Kubernetes controller ͷ Sharding https://github.com/timebertt/thesis-controller-sharding/blob/master/assets/design-overview.pdf
kube-state-metrics ͷ Sharding • ࠓճͷςʔϚ controller Ͱͳ͍͚Ͳ kube-state-metrics ͕
controller Ͱ༻Ͱ͖ΔΞϓϩʔνͰ Sharding Λߦ͏ػೳ͕࣮͞Ε͍ͯΔͨΊɺͦͷհΛ͠·͢
kube-state-metrics ͷ Sharding Pod1 Pod2 1. CM1 Metrics 2. CM3
Metrics Export Metrics api-server 1. CM1 2. CM2 3. CM3 4. CM4 Con fi gMap List 1. CM2 Metrics 2. CM4 Metrics Export Metrics
kube-state-metrics ͷ Sharding https://github.com/kubernetes/kube-state-metrics/pull/613
kube-state-metrics ͷ Sharding https://github.com/kubernetes/kube-state-metrics/pull/613 γϟʔυʹׂ͢Δ͜ͱͰ ॲཧ͢ΔΦϒδΣΫτ͕ݮΓ ϨΠςϯγ͕গͳ͘ͳΔ
࣮ • kube-state-metrics Λ StatefulSet Ͱಈ͔͢ • ϨϓϦΧͱ Pod ͷඌͷ൪߸͔Β
Կ൪ͷγϟʔυͳͷ͔ݕग़͢Δ • Kubernetes ͷΦϒδΣΫτͷ UID Λ༻͍ͯ Consistent Hash ͠ɺॲཧ͢ΔγϟʔυΛܾఆ͢Δ
࣮ • kube-state-metrics Λ StatefulSet Ͱಈ͔͢ • ϨϓϦΧͱ Pod ͷඌͷ൪߸͔Β
Կ൪ͷγϟʔυͳͷ͔ݕग़͢Δ • Kubernetes ͷΦϒδΣΫτͷ UID Λ༻͍ͯ Consistent Hash ͠ɺॲཧ͢ΔγϟʔυΛܾఆ͢Δ
Pod ໊ͳͲΛҾʹऔΔ
Pod ͷ ownerReferences ͔Β StatefulSet Λऔಘ
StatefulSet ͷϨϓϦΧΛ τʔλϧͷγϟʔυ Pod ໊ͷඌ͔Βγϟʔυͷ ൪߸Λऔಘ
StatefulSet Λ informer Ͱ watch EventHandler Ͱγϟʔυͷઃఆͱ metrics ͷϦηοτΛߦ͏
͜͏͢Δ͜ͱͰ HPA ͳͲͰ StatefulSet ͕εέʔϧͨ͠ࡍʹ γϟʔυͷ࠶ׂͯΛ ࣗಈͰߦ͏͜ͱ͕Ͱ͖Δ
࣮ • kube-state-metrics Λ StatefulSet Ͱಈ͔͢ • ϨϓϦΧͱ Pod ͷඌͷ൪߸͔Β
Կ൪ͷγϟʔυͳͷ͔ݕग़͢Δ • Kubernetes ͷΦϒδΣΫτͷ UID Λ༻͍ͯ Consistent Hash ͠ɺॲཧ͢ΔγϟʔυΛܾఆ͢Δ
client-go ͷΞʔΩςΫνϟ
kube-state-metrics ͷΞʔΩςΫνϟ kube-state-metrics Ͱ Re fl ector Λ༻ ਤͷΑ͏ʹ Delta
FIFO Queue ʹ ΦϒδΣΫτΛ֨ೲ͢ΔͷͰͳ͘ ϝτϦΫεΛ֨ೲ͢Δ MetricStore Λ࣮͍ͯ͠Δ
List & Watch ͷ࣮ͷதͰ ͲͷγϟʔυͰॲཧ͢Δ͔ͷ ఆΛߦ͍ͬͯΔ
List & Watch ͷ࣮ͷதͰ ͲͷγϟʔυͰॲཧ͢Δ͔ͷ ఆΛߦ͍ͬͯΔ
Consistent Hash Ͱॲཧ͢ΔγϟʔυΛܾఆ͠ɺ ࣗγϟʔυͱҰக͢Δ߹ͷΈॲཧΛߦ͏
͜ͷ ListerWatcher Λ༻͍ͯ informer ͳΓΛੜ͢Ε controller ͕࡞ΕΔ
σϝϦοτ • StatefulSet ͷϩʔϧΞτʹىҼ͢ΔσϝϦοτ • ϩʔϧΞτ͕ 1 ͣͭߦΘΕΔͨΊ͍ • Pod
ͷআ͕ઌʹ࣮ࢪ͞ΕΔ • ͜ͷλΠϛϯάͰ Prometheus ͷεΫϨΠϓ͕ൃੜ͢Δͱ ϝτϦΫεͷܽଛʹܨ͕ΔՄೳੑ͕͋Δ • List & Watch ͷ෦γϟʔσΟϯάͰ͖ͳ͍ͨΊɺ ରͱͳΔશΦϒδΣΫτΛਫ਼ࠪ͢ΔͷϦιʔε͕ඞཁͱͳΔ
·ͱΊ • controller ͷγϟʔσΟϯάʹ͑ͦ͏ͳ kube-state-metrics Ͱ༻͍ΒΕ͍ͯΔγϟʔσΟϯάख๏Λհ • StatefulSet ͷಛੑΛ্ख͍ͬͯ͘Δ
• ΦϒδΣΫτͷ UID Ͱ Consistent Hash
We are hiring Ͱ Yahoo! JAPAN ͚ʹϓϥοτϑΥʔϜΛ࡞Γ͍ͨΤϯδχΞઈࢍืूதͰ͢ʂ
Thank You for Listening