Plugin/Kubernetes: Service and Endpoint Indexing (#1149)
* indexing * corrections
This commit is contained in:
parent
0c63248a0e
commit
b6b05eae8f
10 changed files with 501 additions and 26 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue