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
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
960
オンプレ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
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
160
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
180
What's New in Android 2026
veronikapj
0
210
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
550
霧の中の代数的エフェクト
funnyycat
1
430
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
180
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
410
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
5.5k
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
230
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
130
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
1
250
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
390
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.6k
The Cult of Friendly URLs
andyhume
79
7k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
520
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
New Earth Scene 8
popppiees
3
2.4k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.7k
Building Adaptive Systems
keathley
44
3.1k
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{ ... })