Kubernetes client: set resync period to 5 minutes for more robustness

This commit is contained in:
Yves Peter 2016-11-13 22:11:58 +01:00 committed by Yves Peter
parent 15540764a0
commit 0b78375211

View file

@ -1,6 +1,8 @@
package k8s package k8s
import ( import (
"time"
"k8s.io/client-go/1.5/kubernetes" "k8s.io/client-go/1.5/kubernetes"
"k8s.io/client-go/1.5/pkg/api" "k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/api/v1" "k8s.io/client-go/1.5/pkg/api/v1"
@ -13,6 +15,8 @@ import (
"k8s.io/client-go/1.5/tools/cache" "k8s.io/client-go/1.5/tools/cache"
) )
const resyncPeriod = time.Minute * 5
// Client is a client for the Kubernetes master. // Client is a client for the Kubernetes master.
type Client interface { type Client interface {
GetIngresses(namespaces Namespaces) []*v1beta1.Ingress GetIngresses(namespaces Namespaces) []*v1beta1.Ingress
@ -99,7 +103,7 @@ func (c *clientImpl) WatchIngresses(labelSelector labels.Selector, stopCh <-chan
c.ingStore, c.ingController = cache.NewInformer( c.ingStore, c.ingController = cache.NewInformer(
source, source,
&v1beta1.Ingress{}, &v1beta1.Ingress{},
0, resyncPeriod,
newResourceEventHandlerFuncs(watchCh)) newResourceEventHandlerFuncs(watchCh))
go c.ingController.Run(stopCh) go c.ingController.Run(stopCh)
@ -140,7 +144,7 @@ func (c *clientImpl) WatchServices(stopCh <-chan struct{}) chan interface{} {
c.svcStore, c.svcController = cache.NewInformer( c.svcStore, c.svcController = cache.NewInformer(
source, source,
&v1.Service{}, &v1.Service{},
0, resyncPeriod,
newResourceEventHandlerFuncs(watchCh)) newResourceEventHandlerFuncs(watchCh))
go c.svcController.Run(stopCh) go c.svcController.Run(stopCh)
@ -173,7 +177,7 @@ func (c *clientImpl) WatchEndpoints(stopCh <-chan struct{}) chan interface{} {
c.epStore, c.epController = cache.NewInformer( c.epStore, c.epController = cache.NewInformer(
source, source,
&v1.Endpoints{}, &v1.Endpoints{},
0, resyncPeriod,
newResourceEventHandlerFuncs(watchCh)) newResourceEventHandlerFuncs(watchCh))
go c.epController.Run(stopCh) go c.epController.Run(stopCh)