Skip to content

Commit 5269d40

Browse files
committed
Remove deprecated code
Removes MetricsBindAddr flag Signed-off-by: Sunnatillo <[email protected]>
1 parent 2eb52f0 commit 5269d40

File tree

3 files changed

+23
-57
lines changed

3 files changed

+23
-57
lines changed

docs/book/src/reference/ports.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Name | Port Number | Description |
44
--- | --- | ---
5-
`metrics` | | Port that exposes the metrics. This can be customized by setting the `--metrics-bind-addr` flag when starting the manager. The default is to only listen on `localhost:8080`
5+
`diagnostics-address` | | Port that exposes the metrics, the pprof endpoint and an endpoint to change the log level. This can be customized by setting the `--diagnostics-address` flag when starting the manager. The default port is `8443`. When `insecure-diagnostics` flag is used it is defaulted to port `8080`
66
`webhook` | `9443` | Webhook server port. To disable this set `--webhook-port` flag to `0`.
77
`health` | `9440` | Port that exposes the health endpoint. CThis can be customized by setting the `--health-addr` flag when starting the manager.
88
`profiler`| | Expose the pprof profiler. By default is not configured. Can set the `--profiler-address` flag. e.g. `--profiler-address 6060`

util/flags/manager.go

+22-40
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ type ManagerOptions struct {
4747
// Metrics Options
4848
// These are used to configure the metrics server
4949

50-
// MetricsBindAddr is the field that stores the value of the --metrics-bind-addr flag.
51-
// For further details, please see the description of the flag.
52-
//
53-
// Deprecated: This field will be removed in an upcoming release.
54-
MetricsBindAddr string
5550
// DiagnosticsAddress is the field that stores the value of the --diagnostics-address flag.
5651
// For further details, please see the description of the flag.
5752
DiagnosticsAddress string
@@ -75,11 +70,6 @@ func AddManagerOptions(fs *pflag.FlagSet, options *ManagerOptions) {
7570
"Preferred values: "+strings.Join(tlsCipherPreferredValues, ", ")+". \n"+
7671
"Insecure values: "+strings.Join(tlsCipherInsecureValues, ", ")+".")
7772

78-
fs.StringVar(&options.MetricsBindAddr, "metrics-bind-addr", "",
79-
"The address the metrics endpoint binds to.")
80-
_ = fs.MarkDeprecated("metrics-bind-addr", "Please use --diagnostics-address instead. To continue to serve "+
81-
"metrics via http and without authentication/authorization set --insecure-diagnostics as well.")
82-
8373
fs.StringVar(&options.DiagnosticsAddress, "diagnostics-address", ":8443",
8474
"The address the diagnostics endpoint binds to. Per default metrics are served via https and with"+
8575
"authentication/authorization. To serve via http and without authentication/authorization set --insecure-diagnostics. "+
@@ -113,40 +103,32 @@ func GetManagerOptions(options ManagerOptions) ([]func(config *tls.Config), *met
113103
})
114104
}
115105

116-
// If the deprecated "--metrics-bind-addr" flag is set, continue to serve metrics via http
106+
// If "--insecure-diagnostics" is set, serve metrics via http
117107
// and without authentication/authorization.
118-
if options.MetricsBindAddr != "" {
108+
if options.InsecureDiagnostics {
119109
metricsOptions = &metricsserver.Options{
120-
BindAddress: options.MetricsBindAddr,
110+
BindAddress: options.DiagnosticsAddress,
111+
SecureServing: false,
121112
}
122113
} else {
123-
// If "--insecure-diagnostics" is set, serve metrics via http
124-
// and without authentication/authorization.
125-
if options.InsecureDiagnostics {
126-
metricsOptions = &metricsserver.Options{
127-
BindAddress: options.DiagnosticsAddress,
128-
SecureServing: false,
129-
}
130-
} else {
131-
// If "--insecure-diagnostics" is not set, serve metrics via https
132-
// and with authentication/authorization. As the endpoint is protected,
133-
// we also serve pprof endpoints and an endpoint to change the log level.
134-
metricsOptions = &metricsserver.Options{
135-
BindAddress: options.DiagnosticsAddress,
136-
SecureServing: true,
137-
FilterProvider: filters.WithAuthenticationAndAuthorization,
138-
ExtraHandlers: map[string]http.Handler{
139-
// Add handler to dynamically change log level.
140-
"/debug/flags/v": routes.StringFlagPutHandler(logs.GlogSetter),
141-
// Add pprof handler.
142-
"/debug/pprof/": http.HandlerFunc(pprof.Index),
143-
"/debug/pprof/cmdline": http.HandlerFunc(pprof.Cmdline),
144-
"/debug/pprof/profile": http.HandlerFunc(pprof.Profile),
145-
"/debug/pprof/symbol": http.HandlerFunc(pprof.Symbol),
146-
"/debug/pprof/trace": http.HandlerFunc(pprof.Trace),
147-
},
148-
TLSOpts: tlsOptions,
149-
}
114+
// If "--insecure-diagnostics" is not set, serve metrics via https
115+
// and with authentication/authorization. As the endpoint is protected,
116+
// we also serve pprof endpoints and an endpoint to change the log level.
117+
metricsOptions = &metricsserver.Options{
118+
BindAddress: options.DiagnosticsAddress,
119+
SecureServing: true,
120+
FilterProvider: filters.WithAuthenticationAndAuthorization,
121+
ExtraHandlers: map[string]http.Handler{
122+
// Add handler to dynamically change log level.
123+
"/debug/flags/v": routes.StringFlagPutHandler(logs.GlogSetter),
124+
// Add pprof handler.
125+
"/debug/pprof/": http.HandlerFunc(pprof.Index),
126+
"/debug/pprof/cmdline": http.HandlerFunc(pprof.Cmdline),
127+
"/debug/pprof/profile": http.HandlerFunc(pprof.Profile),
128+
"/debug/pprof/symbol": http.HandlerFunc(pprof.Symbol),
129+
"/debug/pprof/trace": http.HandlerFunc(pprof.Trace),
130+
},
131+
TLSOpts: tlsOptions,
150132
}
151133
}
152134

util/flags/manager_test.go

-16
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,6 @@ func TestGetManagerOptions(t *testing.T) {
5252
},
5353
wantErr: true,
5454
},
55-
{
56-
name: "valid tls + metrics bind addr",
57-
managerOptions: ManagerOptions{
58-
TLSMinVersion: "VersionTLS13",
59-
TLSCipherSuites: []string{"TLS_AES_256_GCM_SHA384"},
60-
MetricsBindAddr: ":8080",
61-
},
62-
wantTLSConfig: &tls.Config{
63-
MinVersion: tls.VersionTLS13,
64-
CipherSuites: []uint16{tls.TLS_AES_256_GCM_SHA384},
65-
},
66-
wantMetricsOptions: &metricsserver.Options{
67-
BindAddress: ":8080",
68-
},
69-
wantErr: false,
70-
},
7155
{
7256
name: "valid tls + insecure diagnostics + diagnostics address",
7357
managerOptions: ManagerOptions{

0 commit comments

Comments
 (0)