aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/kubernetes.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2018-08-27 10:10:51 -0400
committerGravatar GitHub <noreply@github.com> 2018-08-27 10:10:51 -0400
commitd60993e0210cba3576fa0bfa158a23e8abab6f80 (patch)
tree85bb291a2e4cd2d43190466f9c2c517232be16ed /plugin/kubernetes/kubernetes.go
parent75f1b9c988e036a56f0ae31224401aa9b652e9ef (diff)
downloadcoredns-d60993e0210cba3576fa0bfa158a23e8abab6f80.tar.gz
coredns-d60993e0210cba3576fa0bfa158a23e8abab6f80.tar.zst
coredns-d60993e0210cba3576fa0bfa158a23e8abab6f80.zip
plugin/kubernetes: Create records for portless services (#2052)
inject sentinels for portless services
Diffstat (limited to '')
-rw-r--r--plugin/kubernetes/kubernetes.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go
index 03b93748b..eaadb142c 100644
--- a/plugin/kubernetes/kubernetes.go
+++ b/plugin/kubernetes/kubernetes.go
@@ -459,13 +459,17 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
for _, addr := range eps.Addresses {
// See comments in parse.go parseRequest about the endpoint handling.
-
if r.endpoint != "" {
if !match(r.endpoint, endpointHostname(addr, k.endpointNameMode)) {
continue
}
}
+ if len(eps.Ports) == 0 {
+ // add a sentinel port (-1) entry so we create records for services without any declared ports
+ eps.Ports = append(eps.Ports, api.EndpointPort{Port: -1})
+ }
+
for _, p := range eps.Ports {
if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) {
continue
@@ -496,6 +500,10 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
}
// ClusterIP service
+ if len(svc.Spec.Ports) == 0 {
+ // add a sentinel port (-1) entry so we create records for services without any declared ports
+ svc.Spec.Ports = append(svc.Spec.Ports, api.ServicePort{Port: -1})
+ }
for _, p := range svc.Spec.Ports {
if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) {
continue