diff options
Diffstat (limited to 'plugin/kubernetes/kubernetes.go')
-rw-r--r-- | plugin/kubernetes/kubernetes.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go index 3a2c4870d..4e79738e7 100644 --- a/plugin/kubernetes/kubernetes.go +++ b/plugin/kubernetes/kubernetes.go @@ -311,14 +311,6 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, zonePath := msg.Path(zone, "coredns") ip := "" - err = errNoItems - if wildcard(podname) && !wildcard(namespace) { - // If namespace exist, err should be nil, so that we return nodata instead of NXDOMAIN - if k.namespace(namespace) { - err = nil - } - } - if strings.Count(podname, "-") == 3 && !strings.Contains(podname, "--") { ip = strings.Replace(podname, "-", ".", -1) } else { @@ -326,7 +318,18 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, } if k.podMode == podModeInsecure { - return []msg.Service{{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}}, nil + if !wildcard(namespace) && !k.namespace(namespace) { // no wildcard, but namespace does not exist + return nil, errNoItems + } + return []msg.Service{{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}}, err + } + + err = errNoItems + if wildcard(podname) && !wildcard(namespace) { + // If namespace exist, err should be nil, so that we return nodata instead of NXDOMAIN + if k.namespace(namespace) { + err = nil + } } // PodModeVerified @@ -335,6 +338,7 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, if wildcard(namespace) && !k.namespaceExposed(p.Namespace) { continue } + // check for matching ip and namespace if ip == p.Status.PodIP && match(namespace, p.Namespace) { s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl} |