core: Allow disabling node-lister via flag
This commit is contained in:
parent
cda42f93c7
commit
adc2a7d74c
2 changed files with 21 additions and 9 deletions
|
@ -39,6 +39,7 @@ import (
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
|
fcache "k8s.io/client-go/tools/cache/testing"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
"k8s.io/client-go/util/flowcontrol"
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
|
@ -130,6 +131,7 @@ type Configuration struct {
|
||||||
ConfigMapName string
|
ConfigMapName string
|
||||||
|
|
||||||
ForceNamespaceIsolation bool
|
ForceNamespaceIsolation bool
|
||||||
|
DisableNodeList bool
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
TCPConfigMapName string
|
TCPConfigMapName string
|
||||||
|
@ -324,8 +326,14 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "services", ic.cfg.Namespace, fields.Everything()),
|
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "services", ic.cfg.Namespace, fields.Everything()),
|
||||||
&api.Service{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
&api.Service{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
||||||
|
|
||||||
|
var nodeListerWatcher cache.ListerWatcher
|
||||||
|
if config.DisableNodeList {
|
||||||
|
nodeListerWatcher = fcache.NewFakeControllerSource()
|
||||||
|
} else {
|
||||||
|
nodeListerWatcher = cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "nodes", api.NamespaceAll, fields.Everything())
|
||||||
|
}
|
||||||
ic.nodeLister.Store, ic.nodeController = cache.NewInformer(
|
ic.nodeLister.Store, ic.nodeController = cache.NewInformer(
|
||||||
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "nodes", api.NamespaceAll, fields.Everything()),
|
nodeListerWatcher,
|
||||||
&api.Node{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
&api.Node{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
||||||
|
|
||||||
if config.UpdateStatus {
|
if config.UpdateStatus {
|
||||||
|
|
|
@ -91,6 +91,9 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
`Force namespace isolation. This flag is required to avoid the reference of secrets or
|
`Force namespace isolation. This flag is required to avoid the reference of secrets or
|
||||||
configmaps located in a different namespace than the specified in the flag --watch-namespace.`)
|
configmaps located in a different namespace than the specified in the flag --watch-namespace.`)
|
||||||
|
|
||||||
|
disableNodeList = flags.Bool("disable-node-list", false,
|
||||||
|
`Disable querying nodes. If --force-namespace-isolation is true, this should also be set.`)
|
||||||
|
|
||||||
updateStatusOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
|
updateStatusOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
|
||||||
ingress controller should update the Ingress status IP/hostname when the controller
|
ingress controller should update the Ingress status IP/hostname when the controller
|
||||||
is being stopped. Default is true`)
|
is being stopped. Default is true`)
|
||||||
|
@ -183,6 +186,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
PublishService: *publishSvc,
|
PublishService: *publishSvc,
|
||||||
Backend: backend,
|
Backend: backend,
|
||||||
ForceNamespaceIsolation: *forceIsolation,
|
ForceNamespaceIsolation: *forceIsolation,
|
||||||
|
DisableNodeList: *disableNodeList,
|
||||||
UpdateStatusOnShutdown: *updateStatusOnShutdown,
|
UpdateStatusOnShutdown: *updateStatusOnShutdown,
|
||||||
SortBackends: *sortBackends,
|
SortBackends: *sortBackends,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue