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
290
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
1.9k
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
14k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
9.9k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.2k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
23k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
4.9k
GolangCI を使ってコードの品質を保ちながら快適な Golang 生活を送る話 #gounco / GolangCI
daikurosawa
4
5.8k
Introduction gRPC
daikurosawa
1
240
Go Cloud を触ってみる / gopher-dojo-lt
daikurosawa
2
2.1k
Other Decks in Programming
See All in Programming
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
670
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Jakarta EE meets AI
ivargrimstad
0
610
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
170
CSC509 Lecture 09
javiergs
PRO
0
140
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
KATA
mclloyd
29
14k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Thoughts on Productivity
jonyablonski
67
4.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Adopting Sorbet at Scale
ufuk
73
9.1k
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