Add namespace_labels configuration for kubernetes plugin (#2707)

This commit is contained in:
Matt Greenfield 2019-03-22 08:32:40 -06:00 committed by Miek Gieben
parent 43c3e0ab68
commit a3dd8cdf8d
9 changed files with 278 additions and 40 deletions

View file

@ -54,6 +54,7 @@ type dnsControl struct {
client kubernetes.Interface
selector labels.Selector
namespaceSelector labels.Selector
svcController cache.Controller
podController cache.Controller
@ -81,9 +82,12 @@ type dnsControlOpts struct {
initEndpointsCache bool
resyncPeriod time.Duration
ignoreEmptyService bool
// Label handling.
labelSelector *meta.LabelSelector
selector labels.Selector
namespaceLabelSelector *meta.LabelSelector
namespaceSelector labels.Selector
zones []string
endpointNameMode bool
@ -94,6 +98,7 @@ func newdnsController(kubeClient kubernetes.Interface, opts dnsControlOpts) *dns
dns := dnsControl{
client: kubeClient,
selector: opts.selector,
namespaceSelector: opts.namespaceSelector,
stopCh: make(chan struct{}),
zones: opts.zones,
endpointNameMode: opts.endpointNameMode,
@ -140,10 +145,12 @@ func newdnsController(kubeClient kubernetes.Interface, opts dnsControlOpts) *dns
dns.nsLister, dns.nsController = cache.NewInformer(
&cache.ListWatch{
ListFunc: namespaceListFunc(dns.client, dns.selector),
WatchFunc: namespaceWatchFunc(dns.client, dns.selector),
ListFunc: namespaceListFunc(dns.client, dns.namespaceSelector),
WatchFunc: namespaceWatchFunc(dns.client, dns.namespaceSelector),
},
&api.Namespace{}, opts.resyncPeriod, cache.ResourceEventHandlerFuncs{})
&api.Namespace{},
opts.resyncPeriod,
cache.ResourceEventHandlerFuncs{})
return &dns
}