make ignore empty work with ext svc types (#2823)

This commit is contained in:
Chris O'Haver 2019-05-07 20:31:50 -04:00 committed by John Belamaric
parent 6e1c57acfa
commit c147e20373
2 changed files with 11 additions and 1 deletions

View file

@ -19,6 +19,14 @@ var dnsEmptyServiceTestCases = []test.Case{
test.SOA("cluster.local. 5 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 5"),
},
},
// CNAME to external
{
Qname: "external.testns.svc.cluster.local.", Qtype: dns.TypeCNAME,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{
test.CNAME("external.testns.svc.cluster.local. 5 IN CNAME ext.interwebs.test."),
},
},
}
func TestServeDNSEmptyService(t *testing.T) {

View file

@ -439,7 +439,9 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
continue
}
if k.opts.ignoreEmptyService && svc.ClusterIP != api.ClusterIPNone {
// If "ignore empty_service" option is set and no endpoints exist, return NXDOMAIN unless
// it's a headless or externalName service (covered below).
if k.opts.ignoreEmptyService && svc.ClusterIP != api.ClusterIPNone && svc.Type != api.ServiceTypeExternalName {
// serve NXDOMAIN if no endpoint is able to answer
podsCount := 0
for _, ep := range endpointsListFunc() {