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
Kubernetesコントローラーのパフォーマンスチューニング
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Akihiro Ikezoe
March 16, 2023
Programming
2.3k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kubernetesコントローラーのパフォーマンスチューニング
Kubernetes Meetup Tokyo #56
2023/03/16
https://k8sjp.connpass.com/event/275280/
Akihiro Ikezoe
March 16, 2023
More Decks by Akihiro Ikezoe
See All by Akihiro Ikezoe
Kubernetes Admission Webhook Deep Dive
zoetrope
8
1.6k
Kubernetesオペレータのアンチパターン&ベストプラクティス
zoetrope
11
4.9k
Production-Ready Kubernetesに至るまでの3年間とこれから
zoetrope
4
950
オンプレKubernetesでMySQLクラスタの運用を自動化するためにOperatorを自作している話
zoetrope
5
2.5k
サイボウズを支える技術~インフラ刷新プロジェクトNecoを中心に紹介~
zoetrope
1
1.3k
Kuebernetesクラスタのマルチテナンシーベストプラクティス
zoetrope
8
6.9k
クラウドネイティブなチームづくり
zoetrope
7
4k
Open Policy Agent / Gatekeeper 勉強会
zoetrope
5
3k
Kubernetesクラスタの自動管理システムのつくりかた
zoetrope
3
19k
Other Decks in Programming
See All in Programming
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
360
【やさしく解説 設計編 #1】「ドメイン駆動」と「実装駆動」ってなに? 〜設計の考え方を、たとえ話で学ぼう〜
panda728
PRO
1
110
霧の中の代数的エフェクト
funnyycat
1
340
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
840
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
140
AIエージェントで 変わるAndroid開発環境
takahirom
2
490
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.3k
共通化で考えるべきは、実装より公開する型だった
codeegg
0
210
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
3.9k
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
KATA
mclloyd
PRO
35
15k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.1k
Statistics for Hackers
jakevdp
799
230k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
320
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
Everyday Curiosity
cassininazir
0
250
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
260
Discover your Explorer Soul
emna__ayadi
2
1.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Transcript
None
◆ ◆ ◆ ◼ ◼ ◼ ◼ ◼ ◼ ◼
◆ ◼ ◆ ◼ ◆ ◼ ⚫ ⚫ ◼
None
◆ ◆ ◼ ◆ ◼ ◼ ◼
✓ ✓ ✓ ✓ ✓ ✓
◆ ◆ ◼ ◼ ◆ ◼ ◼
Controller Workers Workers Workers Workers Reconciler Informer
Controller Workers Workers Workers Workers Reconciler Informer
◆ ◼ ◆ ◼ ◼ ◆ ◼ ◼
◆ ◼ ◼ ◆ ◼ ◼ ◆ ◼ ◼
◆ ◼ ◼ ◆
◆ ◼ https://github.com/kubernetes/enhancements/issues/1602 ◆ ◼ https://kubernetes.io/docs/reference/instrumentation/metrics/ ◆ ◼ https://kubernetes.io/docs/concepts/cluster-administration/system-traces/
◆ ◼ ◼ ◼ ⚫ ⚫ https://cybozu-go.github.io/moco/metrics.html ⚫
◆ ◼ ◼ ⚫ ⚫ ⚫ ◼
◆ ◼ ◼ ◼ ◆ ◼ ◼ ◼ https://github.com/cybozu-go/moco/pull/500
◆ ◼ ◼ ◼ ◼ ◼ ◆
◆ ◼ ◼ ⚫ ◆ ◼
◆ ◆ ◼ ◼ ◼ ◼ ◼ ◼
◆ ◼ ◆ ◆ ◼ ◆
None
◆ ◼ ◼ ◆ ◼ ◼ ◆ ◼
Kubernetes Cluster Application Controller ArgoCD Server Repo Server Application Resource
Application Resource
application-controller Workers Workers Workers Workers Status Processors Workers Workers Operation
Processors Application Resource Informer Informer watch Events Application Resource
◆ ◆ ◼ ◼ ◼
◆ ◼ ◆ ◼ ◆ ◼ ◆ ◼
◆ ◼ ◼ ◆
◆ ◼ ◼
application-controller Workers Workers Workers Workers Status Processors Workers Workers Operation
Processors Application Resource Informer Informer watch Events
◆ ◼ ◼ ◆ ◼ ◆ ◼
◆ ◆
◆ ◼ ◼ ◼ ◆
workqueue_depth{job="kube-controller-manager",name="volumes"}
histogram_quantile(0.99, sum(rate( rest_client_rate_limiter_duration_seconds_bucket{ job="kube-controller-manager" }[1m] )) by (le))
kube-controller-manager PersistentVolume Controller
◆ ◼ --kube-api-qps ◆ ◼ ◆ ◼ ◼
None
◆ ◆ ◆
None
◆ ◼ https://github.com/zoetrope/kubbernecker ◼ ◼ ⚫ ◼ ⚫ ⚫
None
# Reconcile 99 histogram_quantile(0.99, sum( rate(controller_runtime_reconcile_time_seconds_bucket[1m]) ) by(job, controller, le)
) # Reconcile sum(rate(controller_runtime_reconcile_total[1m]))by(job, controller, result)
# 99 histogram_quantile(0.99, sum(rate(workqueue_queue_duration_seconds_bucket[1m])) by(job, name, le)) # sum(workqueue_depth) by
(job, name)
◆ ◆ import ( "context" "net/url" "time" "github.com/prometheus/client_golang/prometheus" clmetrics "k8s.io/client-go/tools/metrics"
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics" ) var ( rateLimiterDelay = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "rest_client_rate_limiter_duration_seconds", Help: "client-go rate limiter delay in seconds. Broken down by verb, and host.", Buckets: []float64{0.005, 0.025, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 15.0, 30.0, 60.0}, }, []string{"verb", "host"}, ) _ clmetrics.LatencyMetric = &latencyAdapter{} ) func init() { crmetrics.Registry.MustRegister(rateLimiterDelay) adapter := latencyAdapter{ metric: rateLimiterDelay, } clmetrics.RateLimiterLatency = &adapter } type latencyAdapter struct { metric *prometheus.HistogramVec } func (c *latencyAdapter) Observe(_ context.Context, verb string, u url.URL, latency time.Duration) { c.metric.WithLabelValues(verb, u.Host).Observe(latency.Seconds()) }
# Rate Limiter 99 histogram_quantile(0.99, sum( rate(rest_client_rate_limiter_duration_seconds_bucket[1m]) ) by(job, verb,
le) )
# Application Reconcile Status Processor {job=~"argocd/argocd-application-controller"} | logfmt | msg
="Reconciliation completed" | line_format "{{.application}}: {{.time_ms}}" # Application Reconcile Operation Processor {job=~"argocd/argocd-application-controller"} | logfmt | msg = "sync/terminate complete" | line_format "{{.application}}: {{.duration}}"
# {job=~"argocd/argocd-application-controller"} | logfmt | level = "debug" msg =~
"Refreshing app .*" apiVersion: v1 kind: ConfigMap metadata: name: argocd-cmd-params-cm data: # Application Controller debug default "info" controller.log.level: "debug"
◆
◆ $ kubectl port-forward svc/argocd-application-controller-metrics -n argocd 8082:8082 # 30
$ curl localhost:8082/debug/pprof/profile > cpu.pprof # goroutine $ curl localhost:8082/debug/pprof/goroutine?debug=1
◆ ◆ --otlp-address ◆
apiVersion: v1 kind: ConfigMap metadata: name: argocd-cmd-params-cm data: # Number
of application status processors (default 20) controller.status.processors: "20" # Number of application operation processors (default 10) controller.operation.processors: "10" ◆ ◆
import ctrl "sigs.k8s.io/controller-runtime" // ・・・途中省略・・・ cfg, err := ctrl.GetConfig() if
err != nil { return err } cfg.QPS = 50 cfg.Burst = int(cfg.QPS * 1.5) mgr, err := ctrl.NewManager(cfg, ctrl.Options{ ... })