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 {
|
||||||
|
|
|
@ -56,14 +56,14 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
tcpConfigMapName = flags.String("tcp-services-configmap", "",
|
tcpConfigMapName = flags.String("tcp-services-configmap", "",
|
||||||
`Name of the ConfigMap that contains the definition of the TCP services to expose.
|
`Name of the ConfigMap that contains the definition of the TCP services to expose.
|
||||||
The key in the map indicates the external port to be used. The value is the name of the
|
The key in the map indicates the external port to be used. The value is the name of the
|
||||||
service with the format namespace/serviceName and the port of the service could be a
|
service with the format namespace/serviceName and the port of the service could be a
|
||||||
number of the name of the port.
|
number of the name of the port.
|
||||||
The ports 80 and 443 are not allowed as external ports. This ports are reserved for the backend`)
|
The ports 80 and 443 are not allowed as external ports. This ports are reserved for the backend`)
|
||||||
|
|
||||||
udpConfigMapName = flags.String("udp-services-configmap", "",
|
udpConfigMapName = flags.String("udp-services-configmap", "",
|
||||||
`Name of the ConfigMap that contains the definition of the UDP services to expose.
|
`Name of the ConfigMap that contains the definition of the UDP services to expose.
|
||||||
The key in the map indicates the external port to be used. The value is the name of the
|
The key in the map indicates the external port to be used. The value is the name of the
|
||||||
service with the format namespace/serviceName and the port of the service could be a
|
service with the format namespace/serviceName and the port of the service could be a
|
||||||
number of the name of the port.`)
|
number of the name of the port.`)
|
||||||
|
|
||||||
resyncPeriod = flags.Duration("sync-period", 600*time.Second,
|
resyncPeriod = flags.Duration("sync-period", 600*time.Second,
|
||||||
|
@ -76,23 +76,26 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
|
|
||||||
profiling = flags.Bool("profiling", true, `Enable profiling via web interface host:port/debug/pprof/`)
|
profiling = flags.Bool("profiling", true, `Enable profiling via web interface host:port/debug/pprof/`)
|
||||||
|
|
||||||
defSSLCertificate = flags.String("default-ssl-certificate", "", `Name of the secret
|
defSSLCertificate = flags.String("default-ssl-certificate", "", `Name of the secret
|
||||||
that contains a SSL certificate to be used as default for a HTTPS catch-all server`)
|
that contains a SSL certificate to be used as default for a HTTPS catch-all server`)
|
||||||
|
|
||||||
defHealthzURL = flags.String("health-check-path", "/healthz", `Defines
|
defHealthzURL = flags.String("health-check-path", "/healthz", `Defines
|
||||||
the URL to be used as health check inside in the default server in NGINX.`)
|
the URL to be used as health check inside in the default server in NGINX.`)
|
||||||
|
|
||||||
updateStatus = flags.Bool("update-status", true, `Indicates if the
|
updateStatus = flags.Bool("update-status", true, `Indicates if the
|
||||||
ingress controller should update the Ingress status IP/hostname. Default is true`)
|
ingress controller should update the Ingress status IP/hostname. Default is true`)
|
||||||
|
|
||||||
electionID = flags.String("election-id", "ingress-controller-leader", `Election id to use for status update.`)
|
electionID = flags.String("election-id", "ingress-controller-leader", `Election id to use for status update.`)
|
||||||
|
|
||||||
forceIsolation = flags.Bool("force-namespace-isolation", false,
|
forceIsolation = flags.Bool("force-namespace-isolation", false,
|
||||||
`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.`)
|
||||||
|
|
||||||
updateStatusOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
|
disableNodeList = flags.Bool("disable-node-list", false,
|
||||||
ingress controller should update the Ingress status IP/hostname when the controller
|
`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
|
||||||
|
ingress controller should update the Ingress status IP/hostname when the controller
|
||||||
is being stopped. Default is true`)
|
is being stopped. Default is true`)
|
||||||
|
|
||||||
sortBackends = flags.Bool("sort-backends", false,
|
sortBackends = flags.Bool("sort-backends", false,
|
||||||
|
@ -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