Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
b6b05eae
Commit
b6b05eae
authored
Oct 17, 2017
by
Sandeep Rajan
Committed by
John Belamaric
Oct 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plugin/Kubernetes: Service and Endpoint Indexing (#1149)
* indexing * corrections
parent
0c63248a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
501 additions
and
26 deletions
+501
-26
plugin/federation/kubernetes_api_test.go
plugin/federation/kubernetes_api_test.go
+76
-2
plugin/kubernetes/controller.go
plugin/kubernetes/controller.go
+118
-4
plugin/kubernetes/handler_test.go
plugin/kubernetes/handler_test.go
+134
-2
plugin/kubernetes/kubernetes.go
plugin/kubernetes/kubernetes.go
+19
-4
plugin/kubernetes/kubernetes_test.go
plugin/kubernetes/kubernetes_test.go
+135
-3
plugin/kubernetes/local.go
plugin/kubernetes/local.go
+1
-1
plugin/kubernetes/ns.go
plugin/kubernetes/ns.go
+1
-1
plugin/kubernetes/ns_test.go
plugin/kubernetes/ns_test.go
+8
-4
plugin/kubernetes/reverse.go
plugin/kubernetes/reverse.go
+1
-1
plugin/kubernetes/reverse_test.go
plugin/kubernetes/reverse_test.go
+8
-4
No files found.
plugin/federation/kubernetes_api_test.go
View file @
b6b05eae
...
...
@@ -9,8 +9,10 @@ import (
type
APIConnFederationTest
struct
{}
func
(
APIConnFederationTest
)
Run
()
{
return
}
func
(
APIConnFederationTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnFederationTest
)
Run
()
{
return
}
func
(
APIConnFederationTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnFederationTest
)
SvcIndexReverse
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnFederationTest
)
EpIndexReverse
(
string
)
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnFederationTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
a
:=
[]
*
api
.
Pod
{{
...
...
@@ -24,6 +26,49 @@ func (APIConnFederationTest) PodIndex(string) []*api.Pod {
return
a
}
func
(
APIConnFederationTest
)
SvcIndex
(
string
)
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"10.0.0.1"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
api
.
ClusterIPNone
,
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"external"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ExternalName
:
"ext.interwebs.test"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
}
return
svcs
}
func
(
APIConnFederationTest
)
ServiceList
()
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
{
...
...
@@ -67,6 +112,35 @@ func (APIConnFederationTest) ServiceList() []*api.Service {
return
svcs
}
func
(
APIConnFederationTest
)
EpIndex
(
string
)
[]
*
api
.
Endpoints
{
eps
:=
[]
*
api
.
Endpoints
{
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.1"
,
Hostname
:
"ep1a"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
},
}
return
eps
}
func
(
APIConnFederationTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
eps
:=
[]
*
api
.
Endpoints
{
{
...
...
plugin/kubernetes/controller.go
View file @
b6b05eae
...
...
@@ -21,10 +21,18 @@ var (
)
const
podIPIndex
=
"PodIP"
const
svcNameNamespaceIndex
=
"NameNamespace"
const
svcIPIndex
=
"ServiceIP"
const
epNameNamespaceIndex
=
"EndpointNameNamespace"
const
epIPIndex
=
"EndpointsIP"
type
dnsController
interface
{
ServiceList
()
[]
*
api
.
Service
SvcIndex
(
string
)
[]
*
api
.
Service
SvcIndexReverse
(
string
)
[]
*
api
.
Service
PodIndex
(
string
)
[]
*
api
.
Pod
EpIndex
(
string
)
[]
*
api
.
Endpoints
EpIndexReverse
(
string
)
[]
*
api
.
Endpoints
EndpointsList
()
[]
*
api
.
Endpoints
GetNodeByName
(
string
)
(
*
api
.
Node
,
error
)
...
...
@@ -44,7 +52,7 @@ type dnsControl struct {
svcLister
cache
.
Indexer
podLister
cache
.
Indexer
epLister
cache
.
Store
epLister
cache
.
Indexer
// stopLock is used to enforce only a single call to Stop is active.
// Needed because we allow stopping through an http endpoint and
...
...
@@ -77,7 +85,7 @@ func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dn
&
api
.
Service
{},
opts
.
resyncPeriod
,
cache
.
ResourceEventHandlerFuncs
{},
cache
.
Indexers
{
cache
.
NamespaceIndex
:
cache
.
MetaNamespace
IndexFunc
})
cache
.
Indexers
{
svcNameNamespaceIndex
:
svcNameNamespaceIndexFunc
,
svcIPIndex
:
svcIP
IndexFunc
})
if
opts
.
initPodCache
{
dns
.
podLister
,
dns
.
podController
=
cache
.
NewIndexerInformer
(
...
...
@@ -90,14 +98,15 @@ func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dn
cache
.
ResourceEventHandlerFuncs
{},
cache
.
Indexers
{
podIPIndex
:
podIPIndexFunc
})
}
dns
.
epLister
,
dns
.
epController
=
cache
.
NewInformer
(
dns
.
epLister
,
dns
.
epController
=
cache
.
NewIn
dexerIn
former
(
&
cache
.
ListWatch
{
ListFunc
:
endpointsListFunc
(
dns
.
client
,
namespace
,
dns
.
selector
),
WatchFunc
:
endpointsWatchFunc
(
dns
.
client
,
namespace
,
dns
.
selector
),
},
&
api
.
Endpoints
{},
opts
.
resyncPeriod
,
cache
.
ResourceEventHandlerFuncs
{})
cache
.
ResourceEventHandlerFuncs
{},
cache
.
Indexers
{
epNameNamespaceIndex
:
epNameNamespaceIndexFunc
,
epIPIndex
:
epIPIndexFunc
})
return
&
dns
}
...
...
@@ -110,6 +119,38 @@ func podIPIndexFunc(obj interface{}) ([]string, error) {
return
[]
string
{
p
.
Status
.
PodIP
},
nil
}
func
svcIPIndexFunc
(
obj
interface
{})
([]
string
,
error
)
{
svc
,
ok
:=
obj
.
(
*
api
.
Service
)
if
!
ok
{
return
nil
,
errors
.
New
(
"obj was not an *api.Service"
)
}
return
[]
string
{
svc
.
Spec
.
ClusterIP
},
nil
}
func
svcNameNamespaceIndexFunc
(
obj
interface
{})
([]
string
,
error
)
{
s
,
ok
:=
obj
.
(
*
api
.
Service
)
if
!
ok
{
return
nil
,
errors
.
New
(
"obj was not an *api.Service"
)
}
return
[]
string
{
s
.
ObjectMeta
.
Name
+
"."
+
s
.
ObjectMeta
.
Namespace
},
nil
}
func
epNameNamespaceIndexFunc
(
obj
interface
{})
([]
string
,
error
)
{
s
,
ok
:=
obj
.
(
*
api
.
Endpoints
)
if
!
ok
{
return
nil
,
errors
.
New
(
"obj was not an *api.Endpoints"
)
}
return
[]
string
{
s
.
ObjectMeta
.
Name
+
"."
+
s
.
ObjectMeta
.
Namespace
},
nil
}
func
epIPIndexFunc
(
obj
interface
{})
([]
string
,
error
)
{
ep
,
ok
:=
obj
.
(
*
api
.
EndpointAddress
)
if
!
ok
{
return
nil
,
errors
.
New
(
"obj was not an *api.EndpointAddress"
)
}
return
[]
string
{
ep
.
IP
},
nil
}
func
serviceListFunc
(
c
*
kubernetes
.
Clientset
,
ns
string
,
s
*
labels
.
Selector
)
func
(
meta
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
return
func
(
opts
meta
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
if
s
!=
nil
{
...
...
@@ -255,6 +296,79 @@ func (dns *dnsControl) PodIndex(ip string) (pods []*api.Pod) {
return
pods
}
func
(
dns
*
dnsControl
)
SvcIndex
(
idx
string
)
(
svcs
[]
*
api
.
Service
)
{
if
dns
.
svcLister
==
nil
{
return
nil
}
os
,
err
:=
dns
.
svcLister
.
ByIndex
(
svcNameNamespaceIndex
,
idx
)
if
err
!=
nil
{
return
nil
}
for
_
,
o
:=
range
os
{
s
,
ok
:=
o
.
(
*
api
.
Service
)
if
!
ok
{
continue
}
svcs
=
append
(
svcs
,
s
)
}
return
svcs
}
func
(
dns
*
dnsControl
)
SvcIndexReverse
(
ip
string
)
(
svcs
[]
*
api
.
Service
)
{
if
dns
.
svcLister
==
nil
{
return
nil
}
os
,
err
:=
dns
.
svcLister
.
ByIndex
(
svcIPIndex
,
ip
)
if
err
!=
nil
{
return
nil
}
for
_
,
o
:=
range
os
{
s
,
ok
:=
o
.
(
*
api
.
Service
)
if
!
ok
{
continue
}
svcs
=
append
(
svcs
,
s
)
}
return
svcs
}
func
(
dns
*
dnsControl
)
EpIndex
(
idx
string
)
(
ep
[]
*
api
.
Endpoints
)
{
if
dns
.
epLister
==
nil
{
return
nil
}
os
,
err
:=
dns
.
epLister
.
ByIndex
(
epNameNamespaceIndex
,
idx
)
if
err
!=
nil
{
return
nil
}
for
_
,
o
:=
range
os
{
e
,
ok
:=
o
.
(
*
api
.
Endpoints
)
if
!
ok
{
continue
}
ep
=
append
(
ep
,
e
)
}
return
ep
}
func
(
dns
*
dnsControl
)
EpIndexReverse
(
ip
string
)
(
ep
[]
*
api
.
Endpoints
)
{
if
dns
.
svcLister
==
nil
{
return
nil
}
os
,
err
:=
dns
.
epLister
.
ByIndex
(
epIPIndex
,
ip
)
if
err
!=
nil
{
return
nil
}
for
_
,
o
:=
range
os
{
e
,
ok
:=
o
.
(
*
api
.
Endpoints
)
if
!
ok
{
continue
}
ep
=
append
(
ep
,
e
)
}
return
ep
}
func
(
dns
*
dnsControl
)
EndpointsList
()
(
eps
[]
*
api
.
Endpoints
)
{
os
:=
dns
.
epLister
.
List
()
for
_
,
o
:=
range
os
{
...
...
plugin/kubernetes/handler_test.go
View file @
b6b05eae
...
...
@@ -191,8 +191,10 @@ func TestServeDNS(t *testing.T) {
type
APIConnServeTest
struct
{}
func
(
APIConnServeTest
)
Run
()
{
return
}
func
(
APIConnServeTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnServeTest
)
Run
()
{
return
}
func
(
APIConnServeTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnServeTest
)
EpIndexReverse
(
string
)
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnServeTest
)
SvcIndexReverse
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnServeTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
a
:=
[]
*
api
.
Pod
{{
...
...
@@ -206,6 +208,49 @@ func (APIConnServeTest) PodIndex(string) []*api.Pod {
return
a
}
func
(
APIConnServeTest
)
SvcIndex
(
string
)
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"10.0.0.1"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
api
.
ClusterIPNone
,
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"external"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ExternalName
:
"ext.interwebs.test"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
}
return
svcs
}
func
(
APIConnServeTest
)
ServiceList
()
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
{
...
...
@@ -249,6 +294,93 @@ func (APIConnServeTest) ServiceList() []*api.Service {
return
svcs
}
func
(
APIConnServeTest
)
EpIndex
(
string
)
[]
*
api
.
Endpoints
{
n
:=
"test.node.foo.bar"
eps
:=
[]
*
api
.
Endpoints
{
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.1"
,
Hostname
:
"ep1a"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.2"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.3"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"10.9.8.7"
,
NodeName
:
&
n
,
},
},
},
},
},
}
return
eps
}
func
(
APIConnServeTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
n
:=
"test.node.foo.bar"
...
...
plugin/kubernetes/kubernetes.go
View file @
b6b05eae
...
...
@@ -331,8 +331,18 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
func
(
k
*
Kubernetes
)
findServices
(
r
recordRequest
,
zone
string
)
(
services
[]
msg
.
Service
,
err
error
)
{
zonePath
:=
msg
.
Path
(
zone
,
"coredns"
)
err
=
errNoItems
// Set to errNoItems to signal really nothing found, gets reset when name is matched.
for
_
,
svc
:=
range
k
.
APIConn
.
ServiceList
()
{
var
(
endpointsList
[]
*
api
.
Endpoints
serviceList
[]
*
api
.
Service
idx
string
)
if
wildcard
(
r
.
service
)
||
wildcard
(
r
.
namespace
)
{
serviceList
=
k
.
APIConn
.
ServiceList
()
}
else
{
idx
=
r
.
service
+
"."
+
r
.
namespace
serviceList
=
k
.
APIConn
.
SvcIndex
(
idx
)
}
for
_
,
svc
:=
range
serviceList
{
if
!
(
match
(
r
.
namespace
,
svc
.
Namespace
)
&&
match
(
r
.
service
,
svc
.
Name
))
{
continue
...
...
@@ -346,8 +356,13 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
// Endpoint query or headless service
if
svc
.
Spec
.
ClusterIP
==
api
.
ClusterIPNone
||
r
.
endpoint
!=
""
{
for
_
,
ep
:=
range
k
.
APIConn
.
EndpointsList
()
{
if
wildcard
(
r
.
service
)
||
wildcard
(
r
.
namespace
)
{
endpointsList
=
k
.
APIConn
.
EndpointsList
()
}
else
{
idx
=
r
.
service
+
"."
+
r
.
namespace
endpointsList
=
k
.
APIConn
.
EpIndex
(
idx
)
}
for
_
,
ep
:=
range
endpointsList
{
if
ep
.
ObjectMeta
.
Name
!=
svc
.
Name
||
ep
.
ObjectMeta
.
Namespace
!=
svc
.
Namespace
{
continue
}
...
...
plugin/kubernetes/kubernetes_test.go
View file @
b6b05eae
...
...
@@ -51,9 +51,54 @@ func TestEndpointHostname(t *testing.T) {
type
APIConnServiceTest
struct
{}
func
(
APIConnServiceTest
)
Run
()
{
return
}
func
(
APIConnServiceTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnServiceTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
return
nil
}
func
(
APIConnServiceTest
)
Run
()
{
return
}
func
(
APIConnServiceTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnServiceTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
return
nil
}
func
(
APIConnServiceTest
)
SvcIndexReverse
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnServiceTest
)
EpIndexReverse
(
string
)
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnServiceTest
)
SvcIndex
(
string
)
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"10.0.0.1"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
api
.
ClusterIPNone
,
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"external"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ExternalName
:
"coredns.io"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
}
return
svcs
}
func
(
APIConnServiceTest
)
ServiceList
()
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
...
...
@@ -98,6 +143,93 @@ func (APIConnServiceTest) ServiceList() []*api.Service {
return
svcs
}
func
(
APIConnServiceTest
)
EpIndex
(
string
)
[]
*
api
.
Endpoints
{
n
:=
"test.node.foo.bar"
eps
:=
[]
*
api
.
Endpoints
{
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.1"
,
Hostname
:
"ep1a"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.2"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.3"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"10.9.8.7"
,
NodeName
:
&
n
,
},
},
},
},
},
}
return
eps
}
func
(
APIConnServiceTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
n
:=
"test.node.foo.bar"
...
...
plugin/kubernetes/local.go
View file @
b6b05eae
...
...
@@ -28,7 +28,7 @@ func (k *Kubernetes) localNodeName() string {
}
// Find endpoint matching localIP
for
_
,
ep
:=
range
k
.
APIConn
.
E
ndpointsList
(
)
{
for
_
,
ep
:=
range
k
.
APIConn
.
E
pIndexReverse
(
localIP
.
String
()
)
{
for
_
,
eps
:=
range
ep
.
Subsets
{
for
_
,
addr
:=
range
eps
.
Addresses
{
if
localIP
.
Equal
(
net
.
ParseIP
(
addr
.
IP
))
{
...
...
plugin/kubernetes/ns.go
View file @
b6b05eae
...
...
@@ -23,7 +23,7 @@ func (k *Kubernetes) nsAddr() *dns.A {
rr
.
A
=
localIP
FindEndpoint
:
for
_
,
ep
:=
range
k
.
APIConn
.
E
ndpointsList
(
)
{
for
_
,
ep
:=
range
k
.
APIConn
.
E
pIndexReverse
(
localIP
.
String
()
)
{
for
_
,
eps
:=
range
ep
.
Subsets
{
for
_
,
addr
:=
range
eps
.
Addresses
{
if
localIP
.
Equal
(
net
.
ParseIP
(
addr
.
IP
))
{
...
...
plugin/kubernetes/ns_test.go
View file @
b6b05eae
...
...
@@ -9,9 +9,13 @@ import (
type
APIConnTest
struct
{}
func
(
APIConnTest
)
Run
()
{
return
}
func
(
APIConnTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
return
nil
}
func
(
APIConnTest
)
Run
()
{
return
}
func
(
APIConnTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
return
nil
}
func
(
APIConnTest
)
SvcIndex
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnTest
)
SvcIndexReverse
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnTest
)
EpIndex
(
string
)
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnTest
)
ServiceList
()
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
...
...
@@ -28,7 +32,7 @@ func (APIConnTest) ServiceList() []*api.Service {
return
svcs
}
func
(
APIConnTest
)
E
ndpointsList
(
)
[]
*
api
.
Endpoints
{
func
(
APIConnTest
)
E
pIndexReverse
(
string
)
[]
*
api
.
Endpoints
{
eps
:=
[]
*
api
.
Endpoints
{
{
Subsets
:
[]
api
.
EndpointSubset
{
...
...
plugin/kubernetes/reverse.go
View file @
b6b05eae
...
...
@@ -35,7 +35,7 @@ func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
}
}
// If no cluster ips match, search endpoints
for
_
,
ep
:=
range
k
.
APIConn
.
E
ndpointsList
(
)
{
for
_
,
ep
:=
range
k
.
APIConn
.
E
pIndexReverse
(
ip
)
{
if
(
len
(
k
.
Namespaces
)
>
0
)
&&
!
k
.
namespaceExposed
(
ep
.
ObjectMeta
.
Namespace
)
{
continue
}
...
...
plugin/kubernetes/reverse_test.go
View file @
b6b05eae
...
...
@@ -14,9 +14,13 @@ import (
type
APIConnReverseTest
struct
{}
func
(
APIConnReverseTest
)
Run
()
{
return
}
func
(
APIConnReverseTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnReverseTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
return
nil
}
func
(
APIConnReverseTest
)
Run
()
{
return
}
func
(
APIConnReverseTest
)
Stop
()
error
{
return
nil
}
func
(
APIConnReverseTest
)
PodIndex
(
string
)
[]
*
api
.
Pod
{
return
nil
}
func
(
APIConnReverseTest
)
SvcIndex
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnReverseTest
)
SvcIndexReverse
(
string
)
[]
*
api
.
Service
{
return
nil
}
func
(
APIConnReverseTest
)
EpIndex
(
string
)
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnReverseTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
return
nil
}
func
(
APIConnReverseTest
)
ServiceList
()
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
...
...
@@ -38,7 +42,7 @@ func (APIConnReverseTest) ServiceList() []*api.Service {
return
svcs
}
func
(
APIConnReverseTest
)
E
ndpointsList
(
)
[]
*
api
.
Endpoints
{
func
(
APIConnReverseTest
)
E
pIndexReverse
(
string
)
[]
*
api
.
Endpoints
{
eps
:=
[]
*
api
.
Endpoints
{
{
Subsets
:
[]
api
.
EndpointSubset
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment