@@ -18,7 +18,6 @@ package manager
1818
1919import (
2020 "context"
21- "crypto/tls"
2221 "fmt"
2322 "net"
2423 "net/http"
@@ -140,35 +139,6 @@ type Options struct {
140139 // Only use a custom NewClient if you know what you are doing.
141140 NewClient client.NewClientFunc
142141
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-
172142 // Logger is the logger that should be used by this manager.
173143 // If none is set, it defaults to log.Log global logger.
174144 Logger logr.Logger
@@ -239,23 +209,15 @@ type Options struct {
239209 // wait to force acquire leadership. This is measured against time of
240210 // last observed ack. Default is 15 seconds.
241211 LeaseDuration * time.Duration
212+
242213 // RenewDeadline is the duration that the acting controlplane will retry
243214 // refreshing leadership before giving up. Default is 10 seconds.
244215 RenewDeadline * time.Duration
216+
245217 // RetryPeriod is the duration the LeaderElector clients should wait
246218 // between tries of actions. Default is 2 seconds.
247219 RetryPeriod * time.Duration
248220
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-
259221 // MetricsBindAddress is the TCP address that the controller should bind to
260222 // for serving prometheus metrics.
261223 // It can be set to "0" to disable the metrics serving.
@@ -279,31 +241,6 @@ type Options struct {
279241 // before exposing it to public.
280242 PprofBindAddress string
281243
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-
307244 // WebhookServer is an externally configured webhook.Server. By default,
308245 // a Manager will create a default server using Port, Host, and CertDir;
309246 // if this is set, the Manager will use this server instead.
@@ -314,18 +251,6 @@ type Options struct {
314251 // will receive a new Background Context instead.
315252 BaseContext BaseContextFunc
316253
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-
329254 // EventBroadcaster records Events emitted by the manager and sends them to the Kubernetes API
330255 // Use this to customize the event correlator and spam filter
331256 //
@@ -401,15 +326,11 @@ func New(config *rest.Config, options Options) (Manager, error) {
401326 clusterOptions .Scheme = options .Scheme
402327 clusterOptions .MapperProvider = options .MapperProvider
403328 clusterOptions .Logger = options .Logger
404- clusterOptions .SyncPeriod = options .SyncPeriod
405329 clusterOptions .NewCache = options .NewCache
406330 clusterOptions .NewClient = options .NewClient
407331 clusterOptions .Cache = options .Cache
408332 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
413334 })
414335 if err != nil {
415336 return nil , err
@@ -526,12 +447,12 @@ func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options,
526447
527448 o = o .setLeaderElectionConfig (newObj )
528449
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
531452 }
532453
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 }
535456 }
536457
537458 if o .MetricsBindAddress == "" && newObj .Metrics .BindAddress != "" {
@@ -550,20 +471,15 @@ func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options,
550471 o .LivenessEndpointName = newObj .Health .LivenessEndpointName
551472 }
552473
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- }
562474 if o .WebhookServer == nil {
475+ port := 0
476+ if newObj .Webhook .Port != nil {
477+ port = * newObj .Webhook .Port
478+ }
563479 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 ,
567483 })
568484 }
569485
@@ -737,12 +653,7 @@ func setOptionsDefaults(options Options) Options {
737653 }
738654
739655 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 {})
746657 }
747658
748659 return options
0 commit comments