mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Add namespace_labels configuration for kubernetes plugin (#2707)
This commit is contained in:
committed by
Miek Gieben
parent
43c3e0ab68
commit
a3dd8cdf8d
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user