-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add /metrics and profiling handlers to kube-proxy #45889
Add /metrics and profiling handlers to kube-proxy #45889
Conversation
5923712
to
bae51ca
Compare
5ff14ad
to
1157d1a
Compare
@@ -146,6 +146,7 @@ func AddFlags(options *Options, fs *pflag.FlagSet) { | |||
&options.config.Conntrack.TCPCloseWaitTimeout.Duration, "conntrack-tcp-timeout-close-wait", | |||
options.config.Conntrack.TCPCloseWaitTimeout.Duration, | |||
"NAT timeout for TCP connections in the CLOSE_WAIT state") | |||
fs.BoolVar(&options.config.EnableProfiling, "profiling", options.config.EnableProfiling, "If true enables profiling via web interface on /debug/pprof handler.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comment in codes: All flags below here are deprecated and will eventually be removed
, do we really need to add a new flag? Maybe letting user configure this through componentconfig :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that all our setups are still using flags (test clusters, kubemark). I wouldn't like to block using this flag on migration to component config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thnk it's appropriate to have a flag like this - I am assuming it is not generally going to be on, and it's not a "knob" but a very fundamental operating mode, not something users would change except to debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - that was also my way of thinking.
pkg/proxy/iptables/proxier.go
Outdated
@@ -518,6 +518,7 @@ func (proxier *Proxier) SyncLoop() { | |||
defer t.Stop() | |||
// Update healthz timestamp at beginning in case Sync() never succeeds. | |||
if proxier.healthzServer != nil { | |||
registerMetrics() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the metrics handleFuncs are added to metrics server but not healthz server, I think we shouldn't put it in this condition block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the approach in the meantime, so obviously you're right.
Done.
1157d1a
to
354c2c9
Compare
@MrHohn - thanks for review. PTAL |
354c2c9
to
50705c5
Compare
pkg/proxy/iptables/proxier.go
Outdated
@@ -516,6 +516,7 @@ func (proxier *Proxier) Sync() { | |||
func (proxier *Proxier) SyncLoop() { | |||
t := time.NewTicker(proxier.syncPeriod) | |||
defer t.Stop() | |||
registerMetrics() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in SyncLoop, rather than in app-level init (cmd) or NewProxier or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to register those if not in iptables mode. But we have if there anyway.
Will move.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -146,6 +146,7 @@ func AddFlags(options *Options, fs *pflag.FlagSet) { | |||
&options.config.Conntrack.TCPCloseWaitTimeout.Duration, "conntrack-tcp-timeout-close-wait", | |||
options.config.Conntrack.TCPCloseWaitTimeout.Duration, | |||
"NAT timeout for TCP connections in the CLOSE_WAIT state") | |||
fs.BoolVar(&options.config.EnableProfiling, "profiling", options.config.EnableProfiling, "If true enables profiling via web interface on /debug/pprof handler.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thnk it's appropriate to have a flag like this - I am assuming it is not generally going to be on, and it's not a "knob" but a very fundamental operating mode, not something users would change except to debug?
@@ -101,6 +101,8 @@ type KubeProxyConfiguration struct { | |||
// metricsBindAddress is the IP address and port for the metrics server to serve on, | |||
// defaulting to 127.0.0.1:10249 (set to 0.0.0.0 for all interfaces) | |||
MetricsBindAddress string | |||
// enableProfiling enables profiling via web interface on /debug/pprof handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to indicate the profiling will be served by the metrics server, as it may not be obvious to user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
50705c5
to
45ed99c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MrHohn - PTAL
pkg/proxy/iptables/proxier.go
Outdated
@@ -516,6 +516,7 @@ func (proxier *Proxier) Sync() { | |||
func (proxier *Proxier) SyncLoop() { | |||
t := time.NewTicker(proxier.syncPeriod) | |||
defer t.Stop() | |||
registerMetrics() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -101,6 +101,8 @@ type KubeProxyConfiguration struct { | |||
// metricsBindAddress is the IP address and port for the metrics server to serve on, | |||
// defaulting to 127.0.0.1:10249 (set to 0.0.0.0 for all interfaces) | |||
MetricsBindAddress string | |||
// enableProfiling enables profiling via web interface on /debug/pprof handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Cool! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, wojtek-t
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 45953, 45889) |
Also expose "syncProxyRules latency" as a prometheus metrics.
Fix #45876