plugin/kubernetes: Create records for portless services (#2052)
inject sentinels for portless services
This commit is contained in:
parent
75f1b9c988
commit
d60993e021
3 changed files with 64 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue