Add flag to allow switch off the update of Ingress status

This commit is contained in:
Manuel de Brito Fontes 2017-01-20 19:01:37 -03:00
parent b896215613
commit 6cd20734c6
2 changed files with 21 additions and 7 deletions

View file

@ -128,6 +128,8 @@ type Configuration struct {
// Backend is the particular implementation to be used. // Backend is the particular implementation to be used.
// (for instance NGINX) // (for instance NGINX)
Backend ingress.Controller Backend ingress.Controller
UpdateStatus bool
} }
// newIngressController creates an Ingress controller // newIngressController creates an Ingress controller
@ -257,11 +259,15 @@ func newIngressController(config *Configuration) *GenericController {
cache.ResourceEventHandlerFuncs{}, cache.ResourceEventHandlerFuncs{},
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
if config.UpdateStatus {
ic.syncStatus = status.NewStatusSyncer(status.Config{ ic.syncStatus = status.NewStatusSyncer(status.Config{
Client: config.Client, Client: config.Client,
PublishService: ic.cfg.PublishService, PublishService: ic.cfg.PublishService,
IngressLister: ic.ingLister, IngressLister: ic.ingLister,
}) })
} else {
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
}
ic.annotations = newAnnotationExtractor(ic) ic.annotations = newAnnotationExtractor(ic)
@ -970,7 +976,9 @@ func (ic GenericController) Stop() error {
close(ic.stopCh) close(ic.stopCh)
go ic.syncQueue.Shutdown() go ic.syncQueue.Shutdown()
go ic.secretQueue.Shutdown() go ic.secretQueue.Shutdown()
if ic.syncStatus != nil {
ic.syncStatus.Shutdown() ic.syncStatus.Shutdown()
}
return nil return nil
} }
@ -990,7 +998,9 @@ func (ic GenericController) Start() {
go ic.secretQueue.Run(5*time.Second, ic.stopCh) go ic.secretQueue.Run(5*time.Second, ic.stopCh)
go ic.syncQueue.Run(5*time.Second, ic.stopCh) go ic.syncQueue.Run(5*time.Second, ic.stopCh)
if ic.syncStatus != nil {
go ic.syncStatus.Run(ic.stopCh) go ic.syncStatus.Run(ic.stopCh)
}
<-ic.stopCh <-ic.stopCh
} }

View file

@ -73,6 +73,9 @@ func NewIngressController(backend ingress.Controller) *GenericController {
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
ingress controller should update the Ingress status IP/hostname. Default is true`)
) )
flags.AddGoFlagSet(flag.CommandLine) flags.AddGoFlagSet(flag.CommandLine)
@ -134,6 +137,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
os.MkdirAll(ingress.DefaultSSLDirectory, 0655) os.MkdirAll(ingress.DefaultSSLDirectory, 0655)
config := &Configuration{ config := &Configuration{
UpdateStatus: *updateStatus,
Client: kubeClient, Client: kubeClient,
ResyncPeriod: *resyncPeriod, ResyncPeriod: *resyncPeriod,
DefaultService: *defaultSvc, DefaultService: *defaultSvc,