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
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
7
430
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
430
Outline View in SwiftUI
1024jp
1
110
qmuntal/stateless のススメ
sgash708
0
120
Macとオーディオ再生 2024/11/02
yusukeito
0
150
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.2k
Tuning GraphQL on Rails
pyama86
2
1k
C#/.NETのこれまでのふりかえり
tomokusaba
1
150
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
43
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Building Your Own Lightsaber
phodgson
102
6k
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.9k
What's new in Ruby 2.0
geeforr
342
31k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Scaling GitHub
holman
458
140k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Music & Morning Musume
bryan
46
6.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