aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/controller.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2018-02-16 11:05:52 -0500
committerGravatar John Belamaric <jbelamaric@infoblox.com> 2018-02-16 11:05:52 -0500
commit9719a47c1bc0bf0098ee07fd004e4d2d2ee139d9 (patch)
tree5b9c4384aabf1dfdca1c512d098e339a883ae991 /plugin/kubernetes/controller.go
parent2cad04ec10584a19dae5b34434d34dedccaabd26 (diff)
downloadcoredns-9719a47c1bc0bf0098ee07fd004e4d2d2ee139d9.tar.gz
coredns-9719a47c1bc0bf0098ee07fd004e4d2d2ee139d9.tar.zst
coredns-9719a47c1bc0bf0098ee07fd004e4d2d2ee139d9.zip
plugin/kubernetes: Add noendpoints option (#1536)
* add noendpoints option * go fmt
Diffstat (limited to 'plugin/kubernetes/controller.go')
-rw-r--r--plugin/kubernetes/controller.go37
1 files changed, 24 insertions, 13 deletions
diff --git a/plugin/kubernetes/controller.go b/plugin/kubernetes/controller.go
index e539b0a72..4774d46d6 100644
--- a/plugin/kubernetes/controller.go
+++ b/plugin/kubernetes/controller.go
@@ -76,8 +76,9 @@ type dnsControl struct {
}
type dnsControlOpts struct {
- initPodCache bool
- resyncPeriod time.Duration
+ initPodCache bool
+ initEndpointsCache bool
+ resyncPeriod time.Duration
// Label handling.
labelSelector *meta.LabelSelector
selector labels.Selector
@@ -113,15 +114,17 @@ func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dn
cache.Indexers{podIPIndex: podIPIndexFunc})
}
- dns.epLister, dns.epController = cache.NewIndexerInformer(
- &cache.ListWatch{
- ListFunc: endpointsListFunc(dns.client, namespace, dns.selector),
- WatchFunc: endpointsWatchFunc(dns.client, namespace, dns.selector),
- },
- &api.Endpoints{},
- opts.resyncPeriod,
- cache.ResourceEventHandlerFuncs{AddFunc: dns.Add, UpdateFunc: dns.Update, DeleteFunc: dns.Delete},
- cache.Indexers{epNameNamespaceIndex: epNameNamespaceIndexFunc, epIPIndex: epIPIndexFunc})
+ if opts.initEndpointsCache {
+ dns.epLister, dns.epController = cache.NewIndexerInformer(
+ &cache.ListWatch{
+ ListFunc: endpointsListFunc(dns.client, namespace, dns.selector),
+ WatchFunc: endpointsWatchFunc(dns.client, namespace, dns.selector),
+ },
+ &api.Endpoints{},
+ opts.resyncPeriod,
+ cache.ResourceEventHandlerFuncs{AddFunc: dns.Add, UpdateFunc: dns.Update, DeleteFunc: dns.Delete},
+ cache.Indexers{epNameNamespaceIndex: epNameNamespaceIndexFunc, epIPIndex: epIPIndexFunc})
+ }
dns.nsLister.Store, dns.nsController = cache.NewInformer(
&cache.ListWatch{
@@ -307,7 +310,9 @@ func (dns *dnsControl) Stop() error {
// Run starts the controller.
func (dns *dnsControl) Run() {
go dns.svcController.Run(dns.stopCh)
- go dns.epController.Run(dns.stopCh)
+ if dns.epController != nil {
+ go dns.epController.Run(dns.stopCh)
+ }
if dns.podController != nil {
go dns.podController.Run(dns.stopCh)
}
@@ -318,7 +323,10 @@ func (dns *dnsControl) Run() {
// HasSynced calls on all controllers.
func (dns *dnsControl) HasSynced() bool {
a := dns.svcController.HasSynced()
- b := dns.epController.HasSynced()
+ b := true
+ if dns.epController != nil {
+ b = dns.epController.HasSynced()
+ }
c := true
if dns.podController != nil {
c = dns.podController.HasSynced()
@@ -431,6 +439,9 @@ func (dns *dnsControl) EpIndexReverse(ip string) (ep []*api.Endpoints) {
}
func (dns *dnsControl) EndpointsList() (eps []*api.Endpoints) {
+ if dns.epLister == nil {
+ return nil
+ }
os := dns.epLister.List()
for _, o := range os {
ep, ok := o.(*api.Endpoints)