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
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Ethereum_.pdf
nekomatu
0
460
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
950
C++でシェーダを書く
fadis
6
4.1k
役立つログに取り組もう
irof
28
9.6k
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
630
Amazon Qを使ってIaCを触ろう!
maruto
0
410
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
690
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
32
1.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Producing Creativity
orderedlist
PRO
341
39k
Thoughts on Productivity
jonyablonski
67
4.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Building Your Own Lightsaber
phodgson
103
6.1k
Building Applications with DynamoDB
mza
90
6.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
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