@@ -18,7 +18,6 @@ package manager
18
18
19
19
import (
20
20
"context"
21
- "crypto/tls"
22
21
"fmt"
23
22
"net"
24
23
"net/http"
@@ -140,35 +139,6 @@ type Options struct {
140
139
// Only use a custom NewClient if you know what you are doing.
141
140
NewClient client.NewClientFunc
142
141
143
- // SyncPeriod determines the minimum frequency at which watched resources are
144
- // reconciled. A lower period will correct entropy more quickly, but reduce
145
- // responsiveness to change if there are many watched resources. Change this
146
- // value only if you know what you are doing. Defaults to 10 hours if unset.
147
- // there will a 10 percent jitter between the SyncPeriod of all controllers
148
- // so that all controllers will not send list requests simultaneously.
149
- //
150
- // This applies to all controllers.
151
- //
152
- // A period sync happens for two reasons:
153
- // 1. To insure against a bug in the controller that causes an object to not
154
- // be requeued, when it otherwise should be requeued.
155
- // 2. To insure against an unknown bug in controller-runtime, or its dependencies,
156
- // that causes an object to not be requeued, when it otherwise should be
157
- // requeued, or to be removed from the queue, when it otherwise should not
158
- // be removed.
159
- //
160
- // If you want
161
- // 1. to insure against missed watch events, or
162
- // 2. to poll services that cannot be watched,
163
- // then we recommend that, instead of changing the default period, the
164
- // controller requeue, with a constant duration `t`, whenever the controller
165
- // is "done" with an object, and would otherwise not requeue it, i.e., we
166
- // recommend the `Reconcile` function return `reconcile.Result{RequeueAfter: t}`,
167
- // instead of `reconcile.Result{}`.
168
- //
169
- // Deprecated: Use Cache.SyncPeriod instead.
170
- SyncPeriod * time.Duration
171
-
172
142
// Logger is the logger that should be used by this manager.
173
143
// If none is set, it defaults to log.Log global logger.
174
144
Logger logr.Logger
@@ -239,23 +209,15 @@ type Options struct {
239
209
// wait to force acquire leadership. This is measured against time of
240
210
// last observed ack. Default is 15 seconds.
241
211
LeaseDuration * time.Duration
212
+
242
213
// RenewDeadline is the duration that the acting controlplane will retry
243
214
// refreshing leadership before giving up. Default is 10 seconds.
244
215
RenewDeadline * time.Duration
216
+
245
217
// RetryPeriod is the duration the LeaderElector clients should wait
246
218
// between tries of actions. Default is 2 seconds.
247
219
RetryPeriod * time.Duration
248
220
249
- // Namespace, if specified, restricts the manager's cache to watch objects in
250
- // the desired namespace. Defaults to all namespaces.
251
- //
252
- // Note: If a namespace is specified, controllers can still Watch for a
253
- // cluster-scoped resource (e.g Node). For namespaced resources, the cache
254
- // will only hold objects from the desired namespace.
255
- //
256
- // Deprecated: Use Cache.Namespaces instead.
257
- Namespace string
258
-
259
221
// MetricsBindAddress is the TCP address that the controller should bind to
260
222
// for serving prometheus metrics.
261
223
// It can be set to "0" to disable the metrics serving.
@@ -279,31 +241,6 @@ type Options struct {
279
241
// before exposing it to public.
280
242
PprofBindAddress string
281
243
282
- // Port is the port that the webhook server serves at.
283
- // It is used to set webhook.Server.Port if WebhookServer is not set.
284
- //
285
- // Deprecated: Use WebhookServer instead. A WebhookServer can be created via webhook.NewServer.
286
- Port int
287
- // Host is the hostname that the webhook server binds to.
288
- // It is used to set webhook.Server.Host if WebhookServer is not set.
289
- //
290
- // Deprecated: Use WebhookServer instead. A WebhookServer can be created via webhook.NewServer.
291
- Host string
292
-
293
- // CertDir is the directory that contains the server key and certificate.
294
- // If not set, webhook server would look up the server key and certificate in
295
- // {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate
296
- // must be named tls.key and tls.crt, respectively.
297
- // It is used to set webhook.Server.CertDir if WebhookServer is not set.
298
- //
299
- // Deprecated: Use WebhookServer instead. A WebhookServer can be created via webhook.NewServer.
300
- CertDir string
301
-
302
- // TLSOpts is used to allow configuring the TLS config used for the webhook server.
303
- //
304
- // Deprecated: Use WebhookServer instead. A WebhookServer can be created via webhook.NewServer.
305
- TLSOpts []func (* tls.Config )
306
-
307
244
// WebhookServer is an externally configured webhook.Server. By default,
308
245
// a Manager will create a default server using Port, Host, and CertDir;
309
246
// if this is set, the Manager will use this server instead.
@@ -314,18 +251,6 @@ type Options struct {
314
251
// will receive a new Background Context instead.
315
252
BaseContext BaseContextFunc
316
253
317
- // ClientDisableCacheFor tells the client that, if any cache is used, to bypass it
318
- // for the given objects.
319
- //
320
- // Deprecated: Use Client.Cache.DisableCacheFor instead.
321
- ClientDisableCacheFor []client.Object
322
-
323
- // DryRunClient specifies whether the client should be configured to enforce
324
- // dryRun mode.
325
- //
326
- // Deprecated: Use Client.DryRun instead.
327
- DryRunClient bool
328
-
329
254
// EventBroadcaster records Events emitted by the manager and sends them to the Kubernetes API
330
255
// Use this to customize the event correlator and spam filter
331
256
//
@@ -401,15 +326,11 @@ func New(config *rest.Config, options Options) (Manager, error) {
401
326
clusterOptions .Scheme = options .Scheme
402
327
clusterOptions .MapperProvider = options .MapperProvider
403
328
clusterOptions .Logger = options .Logger
404
- clusterOptions .SyncPeriod = options .SyncPeriod
405
329
clusterOptions .NewCache = options .NewCache
406
330
clusterOptions .NewClient = options .NewClient
407
331
clusterOptions .Cache = options .Cache
408
332
clusterOptions .Client = options .Client
409
- clusterOptions .Namespace = options .Namespace //nolint:staticcheck
410
- clusterOptions .ClientDisableCacheFor = options .ClientDisableCacheFor //nolint:staticcheck
411
- clusterOptions .DryRunClient = options .DryRunClient //nolint:staticcheck
412
- clusterOptions .EventBroadcaster = options .EventBroadcaster //nolint:staticcheck
333
+ clusterOptions .EventBroadcaster = options .EventBroadcaster //nolint:staticcheck
413
334
})
414
335
if err != nil {
415
336
return nil , err
@@ -526,12 +447,12 @@ func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options,
526
447
527
448
o = o .setLeaderElectionConfig (newObj )
528
449
529
- if o .SyncPeriod == nil && newObj .SyncPeriod != nil {
530
- o .SyncPeriod = & newObj .SyncPeriod .Duration
450
+ if o .Cache . SyncPeriod == nil && newObj .SyncPeriod != nil {
451
+ o .Cache . SyncPeriod = & newObj .SyncPeriod .Duration
531
452
}
532
453
533
- if o . Namespace == "" && newObj .CacheNamespace != "" {
534
- o .Namespace = newObj .CacheNamespace
454
+ if len ( o . Cache . Namespaces ) == 0 && newObj .CacheNamespace != "" {
455
+ o .Cache . Namespaces = [] string { newObj .CacheNamespace }
535
456
}
536
457
537
458
if o .MetricsBindAddress == "" && newObj .Metrics .BindAddress != "" {
@@ -550,20 +471,15 @@ func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options,
550
471
o .LivenessEndpointName = newObj .Health .LivenessEndpointName
551
472
}
552
473
553
- if o .Port == 0 && newObj .Webhook .Port != nil {
554
- o .Port = * newObj .Webhook .Port
555
- }
556
- if o .Host == "" && newObj .Webhook .Host != "" {
557
- o .Host = newObj .Webhook .Host
558
- }
559
- if o .CertDir == "" && newObj .Webhook .CertDir != "" {
560
- o .CertDir = newObj .Webhook .CertDir
561
- }
562
474
if o .WebhookServer == nil {
475
+ port := 0
476
+ if newObj .Webhook .Port != nil {
477
+ port = * newObj .Webhook .Port
478
+ }
563
479
o .WebhookServer = webhook .NewServer (webhook.Options {
564
- Port : o . Port ,
565
- Host : o .Host ,
566
- CertDir : o .CertDir ,
480
+ Port : port ,
481
+ Host : newObj . Webhook .Host ,
482
+ CertDir : newObj . Webhook .CertDir ,
567
483
})
568
484
}
569
485
@@ -737,12 +653,7 @@ func setOptionsDefaults(options Options) Options {
737
653
}
738
654
739
655
if options .WebhookServer == nil {
740
- options .WebhookServer = webhook .NewServer (webhook.Options {
741
- Host : options .Host ,
742
- Port : options .Port ,
743
- CertDir : options .CertDir ,
744
- TLSOpts : options .TLSOpts ,
745
- })
656
+ options .WebhookServer = webhook .NewServer (webhook.Options {})
746
657
}
747
658
748
659
return options
0 commit comments