Correctly set a namespace label in the required domain for xds routes

If an upstream is not in the default namespace, we expect DNS requests
to be served over "<service-name>.ingress.<namespace>.*"
This commit is contained in:
Chris Piraino 2020-05-06 13:39:38 -05:00
parent 114a18e890
commit d498a0afc9

View File

@ -98,6 +98,7 @@ func routesFromSnapshotIngressGateway(cfgSnap *proxycfg.ConfigSnapshot) ([]proto
continue
}
namespace := u.GetEnterpriseMeta().NamespaceOrDefault()
var domains []string
switch {
case len(upstreams) == 1:
@ -110,6 +111,8 @@ func routesFromSnapshotIngressGateway(cfgSnap *proxycfg.ConfigSnapshot) ([]proto
// If a user has specified hosts, do not add the default
// "<service-name>.*" prefix
domains = u.IngressHosts
case namespace != structs.IntentionDefaultNamespace:
domains = []string{fmt.Sprintf("%s.ingress.%s.*", chain.ServiceName, namespace)}
default:
domains = []string{fmt.Sprintf("%s.*", chain.ServiceName)}
}