Skip to content

Commit 76e321a

Browse files
committed
Add ListenerConfig for metrics
1 parent c93e2ab commit 76e321a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/metrics/server/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ type Options struct {
101101
// TLSOpts is used to allow configuring the TLS config used for the server.
102102
// This also allows providing a certificate via GetCertificate.
103103
TLSOpts []func(*tls.Config)
104+
105+
// ListenConfig contains options for listening to an address on the metric server.
106+
// Note: This does not work with SecureServing=true
107+
ListenConfig net.ListenConfig
104108
}
105109

106110
// Filter is a func that is added around metrics and extra handlers on the metrics server.
@@ -249,7 +253,7 @@ func (s *defaultServer) Start(ctx context.Context) error {
249253

250254
func (s *defaultServer) createListener(ctx context.Context, log logr.Logger) (net.Listener, error) {
251255
if !s.options.SecureServing {
252-
return net.Listen("tcp", s.options.BindAddress)
256+
return s.options.ListenConfig.Listen(context.Background(), "tcp", s.options.BindAddress)
253257
}
254258

255259
cfg := &tls.Config{ //nolint:gosec

0 commit comments

Comments
 (0)