mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 01:56:57 +02:00
fix: support namespaces on the hostnames in istio gateway
One feature that's supported for the Istio Gateway resource is the ability to restrict what namespace may provide a VirtualService for a given hostname/domain by specifying it in the form `my-namespace/my-domain.com` which restricts the availability of `my-domain.com` to the `my-namespace` namespace. When creating the associated DNS records, the namespace should not be included.
This commit is contained in:
parent
cf7437f1a1
commit
38a2040759
@ -273,6 +273,15 @@ func (sc *gatewaySource) endpointsFromGatewayConfig(config istiomodel.Config) ([
|
|||||||
if host == "" {
|
if host == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parts := strings.Split(host, "/")
|
||||||
|
|
||||||
|
// If the input hostname is of the form my-namespace/foo.bar.com, remove the namespace
|
||||||
|
// before appending it to the list of endpoints to create
|
||||||
|
if len(parts) == 2 {
|
||||||
|
host = parts[1]
|
||||||
|
}
|
||||||
|
|
||||||
endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific)...)
|
endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,25 @@ func testEndpointsFromGatewayConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "one namespaced rule.host one lb.hostname",
|
||||||
|
lbServices: []fakeIngressGatewayService{
|
||||||
|
{
|
||||||
|
hostnames: []string{"lb.com"}, // Kubernetes omits the trailing dot
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config: fakeGatewayConfig{
|
||||||
|
dnsnames: [][]string{
|
||||||
|
{"my-namespace/foo.bar"}, // Kubernetes requires removal of trailing dot
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: []*endpoint.Endpoint{
|
||||||
|
{
|
||||||
|
DNSName: "foo.bar",
|
||||||
|
Targets: endpoint.Targets{"lb.com"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "one rule.host one lb.IP",
|
title: "one rule.host one lb.IP",
|
||||||
lbServices: []fakeIngressGatewayService{
|
lbServices: []fakeIngressGatewayService{
|
||||||
|
Loading…
Reference in New Issue
Block a user