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
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
Zoneless Testing
rainerhahnekamp
0
120
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
170
CSC305 Lecture 26
javiergs
PRO
0
140
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
3
1.1k
MCP with Cloudflare Workers
yusukebe
2
220
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
testcontainers のススメ
sgash708
1
120
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
Jakarta EE meets AI
ivargrimstad
0
230
Featured
See All Featured
The Language of Interfaces
destraynor
154
24k
KATA
mclloyd
29
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Agile that works and the tools we love
rasmusluckow
328
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Automating Front-end Workflow
addyosmani
1366
200k
The Invisible Side of Design
smashingmag
298
50k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Docker and Python
trallard
42
3.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