diff options
author | 2017-08-22 21:52:18 +0100 | |
---|---|---|
committer | 2017-08-22 21:52:18 +0100 | |
commit | 12db6618c82c6e6687c8610edfb1c0a0e352ced3 (patch) | |
tree | fde7f7a1a321f8c43aa3ed41e0911854362b9655 /middleware/kubernetes/controller.go | |
parent | 6a4e69eb9fd0aa02c47d74d743ae4fce292dcbb7 (diff) | |
download | coredns-12db6618c82c6e6687c8610edfb1c0a0e352ced3.tar.gz coredns-12db6618c82c6e6687c8610edfb1c0a0e352ced3.tar.zst coredns-12db6618c82c6e6687c8610edfb1c0a0e352ced3.zip |
mw/kubernetes: resync to opts (#957)
* mw/kubernetes: resync to opts
Only used to initialize the cache that already has a dnsControlopts, so
remove it from the main kubernetes struct.
* Fix test
* mw/kubernetes: LabelSelector to options as well
Labels select is also only used for init. Don't carry it in the main
kubernetes struct.
* remove this test: can't happen
Caddyfile parser will only call setup when it sees kubernetes.
* erge gone wrong
Diffstat (limited to 'middleware/kubernetes/controller.go')
-rw-r--r-- | middleware/kubernetes/controller.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/middleware/kubernetes/controller.go b/middleware/kubernetes/controller.go index 3d60718ee..b809264e1 100644 --- a/middleware/kubernetes/controller.go +++ b/middleware/kubernetes/controller.go @@ -9,6 +9,7 @@ import ( "k8s.io/client-go/1.5/kubernetes" "k8s.io/client-go/1.5/pkg/api" + unversionedapi "k8s.io/client-go/1.5/pkg/api/unversioned" "k8s.io/client-go/1.5/pkg/api/v1" "k8s.io/client-go/1.5/pkg/labels" "k8s.io/client-go/1.5/pkg/runtime" @@ -71,13 +72,17 @@ type dnsControl struct { type dnsControlOpts struct { initPodCache bool + resyncPeriod time.Duration + // Label handling. + labelSelector *unversionedapi.LabelSelector + selector *labels.Selector } // newDNSController creates a controller for CoreDNS. -func newdnsController(kubeClient *kubernetes.Clientset, resyncPeriod time.Duration, lselector *labels.Selector, opts dnsControlOpts) *dnsControl { +func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dnsControl { dns := dnsControl{ client: kubeClient, - selector: lselector, + selector: opts.selector, stopCh: make(chan struct{}), } @@ -87,7 +92,7 @@ func newdnsController(kubeClient *kubernetes.Clientset, resyncPeriod time.Durati WatchFunc: serviceWatchFunc(dns.client, namespace, dns.selector), }, &api.Service{}, - resyncPeriod, + opts.resyncPeriod, cache.ResourceEventHandlerFuncs{}, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) @@ -98,7 +103,7 @@ func newdnsController(kubeClient *kubernetes.Clientset, resyncPeriod time.Durati WatchFunc: podWatchFunc(dns.client, namespace, dns.selector), }, &api.Pod{}, // TODO replace with a lighter-weight custom struct - resyncPeriod, + opts.resyncPeriod, cache.ResourceEventHandlerFuncs{}, cache.Indexers{podIPIndex: podIPIndexFunc}) } @@ -108,14 +113,18 @@ func newdnsController(kubeClient *kubernetes.Clientset, resyncPeriod time.Durati ListFunc: namespaceListFunc(dns.client, dns.selector), WatchFunc: namespaceWatchFunc(dns.client, dns.selector), }, - &api.Namespace{}, resyncPeriod, cache.ResourceEventHandlerFuncs{}) + &api.Namespace{}, + opts.resyncPeriod, + cache.ResourceEventHandlerFuncs{}) dns.epLister.Store, dns.epController = cache.NewInformer( &cache.ListWatch{ ListFunc: endpointsListFunc(dns.client, namespace, dns.selector), WatchFunc: endpointsWatchFunc(dns.client, namespace, dns.selector), }, - &api.Endpoints{}, resyncPeriod, cache.ResourceEventHandlerFuncs{}) + &api.Endpoints{}, + opts.resyncPeriod, + cache.ResourceEventHandlerFuncs{}) return &dns } |