Pass k8s Service data through to the TCP balancer script.

Fixes broken L4 ExternalName services.

Details
---------

The `tcp_udp_balancer.lua` script checks if the property
`backend.service.spec["type"]` equals "ExternalName".  If so,
the script does a DNS lookup on the name in order to configure
the backend configuration.

However, before this commit, the k8s `Service` data was
_not_ set on the `Backend` struct passed into the `tcp_udp_balancer.lua`
script and therefore the ExternalName check always returned false.

This commit fixes the issue by setting the `Service` field on
the `Backend` struct. This also requires adding a new field to the
`L4Backend` struct first, so that it's available to set on the `Backend`.
This commit is contained in:
Kevin Pullin 2019-01-01 20:35:17 -08:00
parent c3eeaca972
commit f0173f0822
3 changed files with 5 additions and 0 deletions

View file

@ -343,6 +343,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
ProxyProtocol: svcProxyProtocol,
},
Endpoints: endps,
Service: svc,
})
}
// Keep upstream order sorted to reduce unnecessary nginx config reloads.

View file

@ -821,6 +821,7 @@ func configureDynamically(pcfg *ingress.Configuration, port int, isDynamicCertif
Name: key,
Endpoints: ep.Endpoints,
Port: intstr.FromInt(ep.Port),
Service: ep.Service,
})
}
for _, ep := range pcfg.UDPEndpoints {
@ -829,6 +830,7 @@ func configureDynamically(pcfg *ingress.Configuration, port int, isDynamicCertif
Name: key,
Endpoints: ep.Endpoints,
Port: intstr.FromInt(ep.Port),
Service: ep.Service,
})
}

View file

@ -322,6 +322,8 @@ type L4Service struct {
Backend L4Backend `json:"backend"`
// Endpoints active endpoints of the service
Endpoints []Endpoint `json:"endpoints,omitempty"`
// k8s Service
Service *apiv1.Service `json:"service,omitempty"`
}
// L4Backend describes the kubernetes service behind L4 Ingress service