Skip to content

Commit c5b4e93

Browse files
authored
Merge pull request #10883 from awprice/issue-10882
🐛 Also use tls options for metrics/diagnostics server
2 parents 0908bfc + f4db345 commit c5b4e93

File tree

11 files changed

+357
-229
lines changed

11 files changed

+357
-229
lines changed

bootstrap/kubeadm/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ var (
8080
webhookCertName string
8181
webhookKeyName string
8282
healthAddr string
83-
tlsOptions = flags.TLSOptions{}
84-
diagnosticsOptions = flags.DiagnosticsOptions{}
83+
managerOptions = flags.ManagerOptions{}
8584
logOptions = logs.NewOptions()
8685
// CABPK specific flags.
8786
clusterConcurrency int
@@ -170,8 +169,7 @@ func InitFlags(fs *pflag.FlagSet) {
170169
fs.StringVar(&healthAddr, "health-addr", ":9440",
171170
"The address the health endpoint binds to.")
172171

173-
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
174-
flags.AddTLSOptions(fs, &tlsOptions)
172+
flags.AddManagerOptions(fs, &managerOptions)
175173

176174
feature.MutableGates.AddFlag(fs)
177175
}
@@ -204,14 +202,12 @@ func main() {
204202
restConfig.Burst = restConfigBurst
205203
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)
206204

207-
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
205+
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)
208206
if err != nil {
209-
setupLog.Error(err, "unable to add TLS settings to the webhook server")
207+
setupLog.Error(err, "Unable to start manager: invalid flags")
210208
os.Exit(1)
211209
}
212210

213-
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
214-
215211
var watchNamespaces map[string]cache.Config
216212
if watchNamespace != "" {
217213
watchNamespaces = map[string]cache.Config{
@@ -236,7 +232,7 @@ func main() {
236232
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
237233
HealthProbeBindAddress: healthAddr,
238234
PprofBindAddress: profilerAddress,
239-
Metrics: diagnosticsOpts,
235+
Metrics: *metricsOptions,
240236
Cache: cache.Options{
241237
DefaultNamespaces: watchNamespaces,
242238
SyncPeriod: &syncPeriod,
@@ -265,7 +261,7 @@ func main() {
265261
CertDir: webhookCertDir,
266262
CertName: webhookCertName,
267263
KeyName: webhookKeyName,
268-
TLSOpts: tlsOptionOverrides,
264+
TLSOpts: tlsOptions,
269265
},
270266
),
271267
}

controlplane/kubeadm/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ var (
8484
webhookCertName string
8585
webhookKeyName string
8686
healthAddr string
87-
tlsOptions = flags.TLSOptions{}
88-
diagnosticsOptions = flags.DiagnosticsOptions{}
87+
managerOptions = flags.ManagerOptions{}
8988
logOptions = logs.NewOptions()
9089
// KCP specific flags.
9190
kubeadmControlPlaneConcurrency int
@@ -180,8 +179,7 @@ func InitFlags(fs *pflag.FlagSet) {
180179
"Use the deprecated naming convention for infra machines where they are named after the InfraMachineTemplate.")
181180
_ = fs.MarkDeprecated("use-deprecated-infra-machine-naming", "This flag will be removed in v1.9.")
182181

183-
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
184-
flags.AddTLSOptions(fs, &tlsOptions)
182+
flags.AddManagerOptions(fs, &managerOptions)
185183

186184
feature.MutableGates.AddFlag(fs)
187185
}
@@ -214,14 +212,12 @@ func main() {
214212
restConfig.Burst = restConfigBurst
215213
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)
216214

217-
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
215+
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)
218216
if err != nil {
219-
setupLog.Error(err, "unable to add TLS settings to the webhook server")
217+
setupLog.Error(err, "Unable to start manager: invalid flags")
220218
os.Exit(1)
221219
}
222220

223-
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
224-
225221
var watchNamespaces map[string]cache.Config
226222
if watchNamespace != "" {
227223
watchNamespaces = map[string]cache.Config{
@@ -246,7 +242,7 @@ func main() {
246242
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
247243
HealthProbeBindAddress: healthAddr,
248244
PprofBindAddress: profilerAddress,
249-
Metrics: diagnosticsOpts,
245+
Metrics: *metricsOptions,
250246
Cache: cache.Options{
251247
DefaultNamespaces: watchNamespaces,
252248
SyncPeriod: &syncPeriod,
@@ -278,7 +274,7 @@ func main() {
278274
CertDir: webhookCertDir,
279275
CertName: webhookCertName,
280276
KeyName: webhookKeyName,
281-
TLSOpts: tlsOptionOverrides,
277+
TLSOpts: tlsOptions,
282278
},
283279
),
284280
}

docs/book/src/developer/providers/migrations/v1.7-to-v1.8.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ maintainers of providers and consumers of our Go API.
2929
and [kubernetes-sigs/controller-runtime#2811](https://github.com/kubernetes-sigs/controller-runtime/pull/2811).
3030
- `remote.NewClusterCacheTracker` now has options to configure QPS & Burst. It's highly recommended to implement corresponding flags
3131
the same way as core Cluster API (see PR: https://github.com/kubernetes-sigs/cluster-api/pull/10880).
32+
- There were changes made to flags in core CAPI (https://github.com/kubernetes-sigs/cluster-api/pull/10883, https://github.com/kubernetes-sigs/cluster-api/pull/10880). It's recommended to adopt these changes in providers as well.

main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ var (
102102
webhookCertName string
103103
webhookKeyName string
104104
healthAddr string
105-
tlsOptions = flags.TLSOptions{}
106-
diagnosticsOptions = flags.DiagnosticsOptions{}
105+
managerOptions = flags.ManagerOptions{}
107106
logOptions = logs.NewOptions()
108107
// core Cluster API specific flags.
109108
clusterTopologyConcurrency int
@@ -243,8 +242,7 @@ func InitFlags(fs *pflag.FlagSet) {
243242
"Use deprecated infrastructure machine naming")
244243
_ = fs.MarkDeprecated("use-deprecated-infra-machine-naming", "This flag will be removed in v1.9.")
245244

246-
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
247-
flags.AddTLSOptions(fs, &tlsOptions)
245+
flags.AddManagerOptions(fs, &managerOptions)
248246

249247
feature.MutableGates.AddFlag(fs)
250248
}
@@ -292,14 +290,12 @@ func main() {
292290
os.Exit(1)
293291
}
294292

295-
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
293+
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)
296294
if err != nil {
297-
setupLog.Error(err, "Unable to add TLS settings to the webhook server")
295+
setupLog.Error(err, "Unable to start manager: invalid flags")
298296
os.Exit(1)
299297
}
300298

301-
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
302-
303299
var watchNamespaces map[string]cache.Config
304300
if watchNamespace != "" {
305301
watchNamespaces = map[string]cache.Config{
@@ -324,7 +320,7 @@ func main() {
324320
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
325321
HealthProbeBindAddress: healthAddr,
326322
PprofBindAddress: profilerAddress,
327-
Metrics: diagnosticsOpts,
323+
Metrics: *metricsOptions,
328324
Cache: cache.Options{
329325
DefaultNamespaces: watchNamespaces,
330326
SyncPeriod: &syncPeriod,
@@ -353,7 +349,7 @@ func main() {
353349
CertDir: webhookCertDir,
354350
CertName: webhookCertName,
355351
KeyName: webhookKeyName,
356-
TLSOpts: tlsOptionOverrides,
352+
TLSOpts: tlsOptions,
357353
},
358354
),
359355
}

test/extension/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ var (
8585
webhookCertName string
8686
webhookKeyName string
8787
healthAddr string
88-
tlsOptions = flags.TLSOptions{}
89-
diagnosticsOptions = flags.DiagnosticsOptions{}
88+
managerOptions = flags.ManagerOptions{}
9089
logOptions = logs.NewOptions()
9190
)
9291

@@ -153,8 +152,7 @@ func InitFlags(fs *pflag.FlagSet) {
153152
fs.StringVar(&healthAddr, "health-addr", ":9440",
154153
"The address the health endpoint binds to.")
155154

156-
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
157-
flags.AddTLSOptions(fs, &tlsOptions)
155+
flags.AddManagerOptions(fs, &managerOptions)
158156

159157
// Add test-extension specific flags
160158
// NOTE: it is not mandatory to use the same flag names in all RuntimeExtension, but it is recommended when
@@ -197,14 +195,12 @@ func main() {
197195
restConfig.Burst = restConfigBurst
198196
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)
199197

200-
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
198+
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)
201199
if err != nil {
202-
setupLog.Error(err, "Unable to add TLS settings to the webhook server")
200+
setupLog.Error(err, "Unable to start manager: invalid flags")
203201
os.Exit(1)
204202
}
205203

206-
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
207-
208204
if enableContentionProfiling {
209205
goruntime.SetBlockProfileRate(1)
210206
}
@@ -215,7 +211,7 @@ func main() {
215211
CertDir: webhookCertDir,
216212
CertName: webhookCertName,
217213
KeyName: webhookKeyName,
218-
TLSOpts: tlsOptionOverrides,
214+
TLSOpts: tlsOptions,
219215
Catalog: catalog,
220216
})
221217
if err != nil {
@@ -233,7 +229,7 @@ func main() {
233229
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
234230
HealthProbeBindAddress: healthAddr,
235231
PprofBindAddress: profilerAddress,
236-
Metrics: diagnosticsOpts,
232+
Metrics: *metricsOptions,
237233
Cache: cache.Options{
238234
SyncPeriod: &syncPeriod,
239235
},

test/infrastructure/docker/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ var (
8787
webhookCertName string
8888
webhookKeyName string
8989
healthAddr string
90-
tlsOptions = flags.TLSOptions{}
91-
diagnosticsOptions = flags.DiagnosticsOptions{}
90+
managerOptions = flags.ManagerOptions{}
9291
logOptions = logs.NewOptions()
9392
// CAPD specific flags.
9493
concurrency int
@@ -171,8 +170,7 @@ func InitFlags(fs *pflag.FlagSet) {
171170
fs.StringVar(&healthAddr, "health-addr", ":9440",
172171
"The address the health endpoint binds to.")
173172

174-
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
175-
flags.AddTLSOptions(fs, &tlsOptions)
173+
flags.AddManagerOptions(fs, &managerOptions)
176174

177175
feature.MutableGates.AddFlag(fs)
178176
}
@@ -210,14 +208,12 @@ func main() {
210208
restConfig.Burst = restConfigBurst
211209
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)
212210

213-
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
211+
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)
214212
if err != nil {
215-
setupLog.Error(err, "Unable to add TLS settings to the webhook server")
213+
setupLog.Error(err, "Unable to start manager: invalid flags")
216214
os.Exit(1)
217215
}
218216

219-
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
220-
221217
var watchNamespaces map[string]cache.Config
222218
if watchNamespace != "" {
223219
watchNamespaces = map[string]cache.Config{
@@ -242,7 +238,7 @@ func main() {
242238
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
243239
HealthProbeBindAddress: healthAddr,
244240
PprofBindAddress: profilerAddress,
245-
Metrics: diagnosticsOpts,
241+
Metrics: *metricsOptions,
246242
Cache: cache.Options{
247243
DefaultNamespaces: watchNamespaces,
248244
SyncPeriod: &syncPeriod,
@@ -271,7 +267,7 @@ func main() {
271267
CertDir: webhookCertDir,
272268
CertName: webhookCertName,
273269
KeyName: webhookKeyName,
274-
TLSOpts: tlsOptionOverrides,
270+
TLSOpts: tlsOptions,
275271
},
276272
),
277273
}

test/infrastructure/inmemory/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ var (
7979
webhookCertName string
8080
webhookKeyName string
8181
healthAddr string
82-
tlsOptions = flags.TLSOptions{}
83-
diagnosticsOptions = flags.DiagnosticsOptions{}
82+
managerOptions = flags.ManagerOptions{}
8483
logOptions = logs.NewOptions()
8584
// CAPIM specific flags.
8685
clusterConcurrency int
@@ -158,8 +157,7 @@ func InitFlags(fs *pflag.FlagSet) {
158157
fs.StringVar(&healthAddr, "health-addr", ":9440",
159158
"The address the health endpoint binds to.")
160159

161-
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
162-
flags.AddTLSOptions(fs, &tlsOptions)
160+
flags.AddManagerOptions(fs, &managerOptions)
163161

164162
feature.MutableGates.AddFlag(fs)
165163
}
@@ -192,14 +190,12 @@ func main() {
192190
restConfig.Burst = restConfigBurst
193191
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)
194192

195-
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
193+
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)
196194
if err != nil {
197-
setupLog.Error(err, "Unable to add TLS settings to the webhook server")
195+
setupLog.Error(err, "Unable to start manager: invalid flags")
198196
os.Exit(1)
199197
}
200198

201-
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
202-
203199
var watchNamespaces map[string]cache.Config
204200
if watchNamespace != "" {
205201
watchNamespaces = map[string]cache.Config{
@@ -221,7 +217,7 @@ func main() {
221217
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
222218
HealthProbeBindAddress: healthAddr,
223219
PprofBindAddress: profilerAddress,
224-
Metrics: diagnosticsOpts,
220+
Metrics: *metricsOptions,
225221
Cache: cache.Options{
226222
DefaultNamespaces: watchNamespaces,
227223
SyncPeriod: &syncPeriod,
@@ -242,7 +238,7 @@ func main() {
242238
CertDir: webhookCertDir,
243239
CertName: webhookCertName,
244240
KeyName: webhookKeyName,
245-
TLSOpts: tlsOptionOverrides,
241+
TLSOpts: tlsOptions,
246242
},
247243
),
248244
}

0 commit comments

Comments
 (0)