diff --git a/api/v1alpha1/dnspolicy_types.go b/api/v1alpha1/dnspolicy_types.go index 0ff26b8a8..bae65112e 100644 --- a/api/v1alpha1/dnspolicy_types.go +++ b/api/v1alpha1/dnspolicy_types.go @@ -348,31 +348,14 @@ func (p *DNSPolicy) WithHealthCheckFor(endpoint string, port *int, protocol stri //LoadBalancing -func (p *DNSPolicy) WithLoadBalancingWeighted(lbWeighted LoadBalancingWeighted) *DNSPolicy { - if p.Spec.LoadBalancing == nil { - p.WithLoadBalancing(LoadBalancingSpec{}) - } - p.Spec.LoadBalancing.Weighted = &lbWeighted - return p -} - -func (p *DNSPolicy) WithLoadBalancingGeo(lbGeo LoadBalancingGeo) *DNSPolicy { - if p.Spec.LoadBalancing == nil { - p.Spec.LoadBalancing = &LoadBalancingSpec{} - } - p.Spec.LoadBalancing.Geo = &lbGeo - return p -} - -func (p *DNSPolicy) WithLoadBalancingWeightedFor(defaultWeight Weight, custom []*CustomWeight) *DNSPolicy { - return p.WithLoadBalancingWeighted(LoadBalancingWeighted{ - DefaultWeight: defaultWeight, - Custom: custom, - }) -} - -func (p *DNSPolicy) WithLoadBalancingGeoFor(defaultGeo string) *DNSPolicy { - return p.WithLoadBalancingGeo(LoadBalancingGeo{ - DefaultGeo: defaultGeo, +func (p *DNSPolicy) WithLoadBalancingFor(defaultWeight Weight, custom []*CustomWeight, defaultGeo string) *DNSPolicy { + return p.WithLoadBalancing(LoadBalancingSpec{ + Weighted: &LoadBalancingWeighted{ + DefaultWeight: defaultWeight, + Custom: custom, + }, + Geo: &LoadBalancingGeo{ + DefaultGeo: defaultGeo, + }, }) } diff --git a/controllers/dns_helper.go b/controllers/dns_helper.go index 92e270d5e..9a39ee9f6 100644 --- a/controllers/dns_helper.go +++ b/controllers/dns_helper.go @@ -244,28 +244,21 @@ func (dh *dnsHelper) getLoadBalancedEndpoints(mcgTarget *multicluster.GatewayTar } endpoints = append(endpoints, clusterEndpoints...) - //Create lbName CNAME (lb-a1b2.shop.example.com -> default.lb-a1b2.shop.example.com) - endpoint = createOrUpdateEndpoint(lbName, []string{geoLbName}, kuadrantdnsv1alpha1.CNAMERecordType, string(geoCode), DefaultCnameTTL, currentEndpoints) - - //Deal with the default geo endpoint first - if geoCode.IsDefaultCode() { - defaultEndpoint = endpoint - // continue here as we will add the `defaultEndpoint` later - continue - } else if (geoCode == mcgTarget.GetDefaultGeo()) || defaultEndpoint == nil { - // Ensure that a `defaultEndpoint` is always set, but the expected default takes precedence + //Deal with the default geo endpoint + if geoCode == mcgTarget.GetDefaultGeo() { + // Ensure that `defaultEndpoint` is set only if geo of the current cluster is desired default geo defaultEndpoint = createOrUpdateEndpoint(lbName, []string{geoLbName}, kuadrantdnsv1alpha1.CNAMERecordType, "default", DefaultCnameTTL, currentEndpoints) + defaultEndpoint.SetProviderSpecificProperty(kuadrantdnsv1alpha1.ProviderSpecificGeoCode, string(v1alpha1.WildcardGeo)) + endpoints = append(endpoints, defaultEndpoint) } + //Create lbName CNAME (lb-a1b2.shop.example.com -> default.lb-a1b2.shop.example.com) + ep := createOrUpdateEndpoint(lbName, []string{geoLbName}, kuadrantdnsv1alpha1.CNAMERecordType, string(geoCode), DefaultCnameTTL, currentEndpoints) + ep.SetProviderSpecificProperty(kuadrantdnsv1alpha1.ProviderSpecificGeoCode, string(geoCode)) + endpoints = append(endpoints, ep) - endpoint.SetProviderSpecificProperty(kuadrantdnsv1alpha1.ProviderSpecificGeoCode, string(geoCode)) - - endpoints = append(endpoints, endpoint) } if len(endpoints) > 0 { - // Add the `defaultEndpoint`, this should always be set by this point if `endpoints` isn't empty - defaultEndpoint.SetProviderSpecificProperty(kuadrantdnsv1alpha1.ProviderSpecificGeoCode, string(v1alpha1.WildcardGeo)) - endpoints = append(endpoints, defaultEndpoint) //Create gwListenerHost CNAME (shop.example.com -> lb-a1b2.shop.example.com) endpoint = createOrUpdateEndpoint(hostname, []string{lbName}, kuadrantdnsv1alpha1.CNAMERecordType, "", DefaultCnameTTL, currentEndpoints) endpoints = append(endpoints, endpoint) diff --git a/controllers/dnspolicy_controller_multi_cluster_test.go b/controllers/dnspolicy_controller_multi_cluster_test.go index 768f3f3bc..2c8bc5d23 100644 --- a/controllers/dnspolicy_controller_multi_cluster_test.go +++ b/controllers/dnspolicy_controller_multi_cluster_test.go @@ -183,156 +183,13 @@ var _ = Describe("DNSPolicy Multi Cluster", func() { Context("loadbalanced routing strategy", func() { - Context("weighted", func() { + Context("geo+weighted with default weights", func() { BeforeEach(func() { dnsPolicy = v1alpha1.NewDNSPolicy("test-dns-policy", testNamespace). WithTargetGateway(TestGatewayName). WithRoutingStrategy(v1alpha1.LoadBalancedRoutingStrategy). - WithLoadBalancingWeightedFor(120, nil) - Expect(k8sClient.Create(ctx, dnsPolicy)).To(Succeed()) - }) - - It("should create dns records", func() { - Eventually(func(g Gomega, ctx context.Context) { - recordList := &kuadrantdnsv1alpha1.DNSRecordList{} - err := k8sClient.List(ctx, recordList, &client.ListOptions{Namespace: testNamespace}) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(recordList.Items).To(HaveLen(2)) - - dnsRecord := &kuadrantdnsv1alpha1.DNSRecord{} - err = k8sClient.Get(ctx, client.ObjectKey{Name: recordName, Namespace: testNamespace}, dnsRecord) - g.Expect(err).NotTo(HaveOccurred()) - - wildcardDnsRecord := &kuadrantdnsv1alpha1.DNSRecord{} - err = k8sClient.Get(ctx, client.ObjectKey{Name: wildcardRecordName, Namespace: testNamespace}, wildcardDnsRecord) - g.Expect(err).NotTo(HaveOccurred()) - - g.Expect(*dnsRecord).To( - MatchFields(IgnoreExtras, Fields{ - "ObjectMeta": HaveField("Name", recordName), - "Spec": MatchFields(IgnoreExtras, Fields{ - "OwnerID": Equal(&ownerID), - "ManagedZoneRef": HaveField("Name", "mz-example-com"), - "Endpoints": ConsistOf( - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.test.example.com"), - "Targets": ConsistOf(TestIPAddressTwo), - "RecordType": Equal("A"), - "SetIdentifier": Equal(""), - "RecordTTL": Equal(externaldns.TTL(60)), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("default.klb.test.example.com"), - "Targets": ConsistOf(clusterTwoIDHash + "-" + gwHash + ".klb.test.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.test.example.com"), - "RecordTTL": Equal(externaldns.TTL(60)), - "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("default.klb.test.example.com"), - "Targets": ConsistOf(clusterOneIDHash + "-" + gwHash + ".klb.test.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal(clusterOneIDHash + "-" + gwHash + ".klb.test.example.com"), - "RecordTTL": Equal(externaldns.TTL(60)), - "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal(clusterOneIDHash + "-" + gwHash + ".klb.test.example.com"), - "Targets": ConsistOf(TestIPAddressOne), - "RecordType": Equal("A"), - "SetIdentifier": Equal(""), - "RecordTTL": Equal(externaldns.TTL(60)), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("klb.test.example.com"), - "Targets": ConsistOf("default.klb.test.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal("default"), - "RecordTTL": Equal(externaldns.TTL(300)), - "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "*"}}), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal(TestHostOne), - "Targets": ConsistOf("klb.test.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal(""), - "RecordTTL": Equal(externaldns.TTL(300)), - })), - ), - }), - }), - ) - g.Expect(*wildcardDnsRecord).To( - MatchFields(IgnoreExtras, Fields{ - "ObjectMeta": HaveField("Name", wildcardRecordName), - "Spec": MatchFields(IgnoreExtras, Fields{ - "OwnerID": Equal(&ownerID), - "ManagedZoneRef": HaveField("Name", "mz-example-com"), - "Endpoints": ConsistOf( - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.example.com"), - "Targets": ConsistOf(TestIPAddressTwo), - "RecordType": Equal("A"), - "SetIdentifier": Equal(""), - "RecordTTL": Equal(externaldns.TTL(60)), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("default.klb.example.com"), - "Targets": ConsistOf(clusterTwoIDHash + "-" + gwHash + ".klb.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.example.com"), - "RecordTTL": Equal(externaldns.TTL(60)), - "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("default.klb.example.com"), - "Targets": ConsistOf(clusterOneIDHash + "-" + gwHash + ".klb.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal(clusterOneIDHash + "-" + gwHash + ".klb.example.com"), - "RecordTTL": Equal(externaldns.TTL(60)), - "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal(clusterOneIDHash + "-" + gwHash + ".klb.example.com"), - "Targets": ConsistOf(TestIPAddressOne), - "RecordType": Equal("A"), - "SetIdentifier": Equal(""), - "RecordTTL": Equal(externaldns.TTL(60)), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("klb.example.com"), - "Targets": ConsistOf("default.klb.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal("default"), - "RecordTTL": Equal(externaldns.TTL(300)), - "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "*"}}), - })), - PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal(TestHostWildcard), - "Targets": ConsistOf("klb.example.com"), - "RecordType": Equal("CNAME"), - "SetIdentifier": Equal(""), - "RecordTTL": Equal(externaldns.TTL(300)), - })), - ), - }), - }), - ) - }, TestTimeoutMedium, TestRetryIntervalMedium, ctx).Should(Succeed()) - }) - - }) - - Context("geo+weighted", func() { - - BeforeEach(func() { - dnsPolicy = v1alpha1.NewDNSPolicy("test-dns-policy", testNamespace). - WithTargetGateway(TestGatewayName). - WithRoutingStrategy(v1alpha1.LoadBalancedRoutingStrategy). - WithLoadBalancingGeoFor("IE"). - WithLoadBalancingWeightedFor(120, nil) + WithLoadBalancingFor(120, nil, "IE") Expect(k8sClient.Create(ctx, dnsPolicy)).To(Succeed()) }) @@ -491,7 +348,7 @@ var _ = Describe("DNSPolicy Multi Cluster", func() { dnsPolicy = v1alpha1.NewDNSPolicy("test-dns-policy", testNamespace). WithTargetGateway(TestGatewayName). WithRoutingStrategy(v1alpha1.LoadBalancedRoutingStrategy). - WithLoadBalancingWeightedFor(120, []*v1alpha1.CustomWeight{ + WithLoadBalancingFor(120, []*v1alpha1.CustomWeight{ { Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ @@ -508,8 +365,7 @@ var _ = Describe("DNSPolicy Multi Cluster", func() { }, Weight: 160, }, - }). - WithLoadBalancingGeoFor("IE") + }, "IE") Expect(k8sClient.Create(ctx, dnsPolicy)).To(Succeed()) Eventually(func() error { @@ -681,6 +537,174 @@ var _ = Describe("DNSPolicy Multi Cluster", func() { }) + Context("geo+weighted with foreign geo", func() { + + BeforeEach(func() { + dnsPolicy = v1alpha1.NewDNSPolicy("test-dns-policy", testNamespace). + WithTargetGateway(TestGatewayName). + WithRoutingStrategy(v1alpha1.LoadBalancedRoutingStrategy). + WithLoadBalancingFor(120, nil, "cat") + Expect(k8sClient.Create(ctx, dnsPolicy)).To(Succeed()) + + Eventually(func() error { + gateway.Labels = map[string]string{} + gateway.Labels["clusters.kuadrant.io/"+TestClusterNameOne+"_lb-attribute-geo-code"] = "IE" + gateway.Labels["clusters.kuadrant.io/"+TestClusterNameTwo+"_lb-attribute-geo-code"] = "ES" + return k8sClient.Update(ctx, gateway) + }, TestTimeoutMedium, TestRetryIntervalMedium).ShouldNot(HaveOccurred()) + + Expect(gateway.Labels).To(HaveKeyWithValue("clusters.kuadrant.io/test-placed-control_lb-attribute-geo-code", "IE")) + Expect(gateway.Labels).To(HaveKeyWithValue("clusters.kuadrant.io/test-placed-workload-1_lb-attribute-geo-code", "ES")) + }) + + It("should create dns records", func() { + Eventually(func(g Gomega, ctx context.Context) { + recordList := &kuadrantdnsv1alpha1.DNSRecordList{} + err := k8sClient.List(ctx, recordList, &client.ListOptions{Namespace: testNamespace}) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(recordList.Items).To(HaveLen(2)) + + dnsRecord := &kuadrantdnsv1alpha1.DNSRecord{} + err = k8sClient.Get(ctx, client.ObjectKey{Name: recordName, Namespace: testNamespace}, dnsRecord) + g.Expect(err).NotTo(HaveOccurred()) + + wildcardDnsRecord := &kuadrantdnsv1alpha1.DNSRecord{} + err = k8sClient.Get(ctx, client.ObjectKey{Name: wildcardRecordName, Namespace: testNamespace}, wildcardDnsRecord) + g.Expect(err).NotTo(HaveOccurred()) + + g.Expect(*dnsRecord).To( + MatchFields(IgnoreExtras, Fields{ + "ObjectMeta": HaveField("Name", recordName), + "Spec": MatchFields(IgnoreExtras, Fields{ + "OwnerID": Equal(&ownerID), + "ManagedZoneRef": HaveField("Name", "mz-example-com"), + "Endpoints": ConsistOf( + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal(clusterOneIDHash + "-" + gwHash + ".klb.test.example.com"), + "Targets": ConsistOf(TestIPAddressOne), + "RecordType": Equal("A"), + "SetIdentifier": Equal(""), + "RecordTTL": Equal(externaldns.TTL(60)), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("ie.klb.test.example.com"), + "Targets": ConsistOf(clusterOneIDHash + "-" + gwHash + ".klb.test.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal(clusterOneIDHash + "-" + gwHash + ".klb.test.example.com"), + "RecordTTL": Equal(externaldns.TTL(60)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("es.klb.test.example.com"), + "Targets": ConsistOf(clusterTwoIDHash + "-" + gwHash + ".klb.test.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.test.example.com"), + "RecordTTL": Equal(externaldns.TTL(60)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.test.example.com"), + "Targets": ConsistOf(TestIPAddressTwo), + "RecordType": Equal("A"), + "SetIdentifier": Equal(""), + "RecordTTL": Equal(externaldns.TTL(60)), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal(TestHostOne), + "Targets": ConsistOf("klb.test.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal(""), + "RecordTTL": Equal(externaldns.TTL(300)), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("klb.test.example.com"), + "Targets": ConsistOf("es.klb.test.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal("ES"), + "RecordTTL": Equal(externaldns.TTL(300)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "ES"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("klb.test.example.com"), + "Targets": ConsistOf("ie.klb.test.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal("IE"), + "RecordTTL": Equal(externaldns.TTL(300)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "IE"}}), + })), + ), + }), + }), + ) + + g.Expect(*wildcardDnsRecord).To( + MatchFields(IgnoreExtras, Fields{ + "ObjectMeta": HaveField("Name", wildcardRecordName), + "Spec": MatchFields(IgnoreExtras, Fields{ + "OwnerID": Equal(&ownerID), + "ManagedZoneRef": HaveField("Name", "mz-example-com"), + "Endpoints": ConsistOf( + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal(clusterOneIDHash + "-" + gwHash + ".klb.example.com"), + "Targets": ConsistOf(TestIPAddressOne), + "RecordType": Equal("A"), + "SetIdentifier": Equal(""), + "RecordTTL": Equal(externaldns.TTL(60)), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("ie.klb.example.com"), + "Targets": ConsistOf(clusterOneIDHash + "-" + gwHash + ".klb.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal(clusterOneIDHash + "-" + gwHash + ".klb.example.com"), + "RecordTTL": Equal(externaldns.TTL(60)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("es.klb.example.com"), + "Targets": ConsistOf(clusterTwoIDHash + "-" + gwHash + ".klb.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.example.com"), + "RecordTTL": Equal(externaldns.TTL(60)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "weight", Value: "120"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal(clusterTwoIDHash + "-" + gwHash + ".klb.example.com"), + "Targets": ConsistOf(TestIPAddressTwo), + "RecordType": Equal("A"), + "SetIdentifier": Equal(""), + "RecordTTL": Equal(externaldns.TTL(60)), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal(TestHostWildcard), + "Targets": ConsistOf("klb.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal(""), + "RecordTTL": Equal(externaldns.TTL(300)), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("klb.example.com"), + "Targets": ConsistOf("es.klb.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal("ES"), + "RecordTTL": Equal(externaldns.TTL(300)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "ES"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("klb.example.com"), + "Targets": ConsistOf("ie.klb.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal("IE"), + "RecordTTL": Equal(externaldns.TTL(300)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "IE"}}), + })), + ), + }), + }), + ) + }, TestTimeoutMedium, TestRetryIntervalMedium, ctx).Should(Succeed()) + }) + }) + }) }) diff --git a/controllers/dnspolicy_controller_single_cluster_test.go b/controllers/dnspolicy_controller_single_cluster_test.go index e1fd0b642..b991d9079 100644 --- a/controllers/dnspolicy_controller_single_cluster_test.go +++ b/controllers/dnspolicy_controller_single_cluster_test.go @@ -172,7 +172,8 @@ var _ = Describe("DNSPolicy Single Cluster", func() { BeforeEach(func() { dnsPolicy = v1alpha1.NewDNSPolicy("test-dns-policy", testNamespace). WithTargetGateway(TestGatewayName). - WithRoutingStrategy(v1alpha1.LoadBalancedRoutingStrategy) + WithRoutingStrategy(v1alpha1.LoadBalancedRoutingStrategy). + WithLoadBalancingFor(120, nil, "IE") Expect(k8sClient.Create(ctx, dnsPolicy)).To(Succeed()) }) @@ -206,7 +207,7 @@ var _ = Describe("DNSPolicy Single Cluster", func() { "RecordTTL": Equal(externaldns.TTL(60)), })), PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("default." + "klb.test.example.com"), + "DNSName": Equal("ie.klb.test.example.com"), "Targets": ConsistOf(clusterHash + "-" + gwHash + "." + "klb.test.example.com"), "RecordType": Equal("CNAME"), "SetIdentifier": Equal(clusterHash + "-" + gwHash + "." + "klb.test.example.com"), @@ -215,7 +216,15 @@ var _ = Describe("DNSPolicy Single Cluster", func() { })), PointTo(MatchFields(IgnoreExtras, Fields{ "DNSName": Equal("klb.test.example.com"), - "Targets": ConsistOf("default." + "klb.test.example.com"), + "Targets": ConsistOf("ie.klb.test.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal("IE"), + "RecordTTL": Equal(externaldns.TTL(300)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "IE"}}), + })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("klb.test.example.com"), + "Targets": ConsistOf("ie.klb.test.example.com"), "RecordType": Equal("CNAME"), "SetIdentifier": Equal("default"), "RecordTTL": Equal(externaldns.TTL(300)), @@ -247,7 +256,7 @@ var _ = Describe("DNSPolicy Single Cluster", func() { "RecordTTL": Equal(externaldns.TTL(60)), })), PointTo(MatchFields(IgnoreExtras, Fields{ - "DNSName": Equal("default." + "klb.example.com"), + "DNSName": Equal("ie.klb.example.com"), "Targets": ConsistOf(clusterHash + "-" + gwHash + "." + "klb.example.com"), "RecordType": Equal("CNAME"), "SetIdentifier": Equal(clusterHash + "-" + gwHash + "." + "klb.example.com"), @@ -256,12 +265,20 @@ var _ = Describe("DNSPolicy Single Cluster", func() { })), PointTo(MatchFields(IgnoreExtras, Fields{ "DNSName": Equal("klb.example.com"), - "Targets": ConsistOf("default." + "klb.example.com"), + "Targets": ConsistOf("ie.klb.example.com"), "RecordType": Equal("CNAME"), "SetIdentifier": Equal("default"), "RecordTTL": Equal(externaldns.TTL(300)), "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "*"}}), })), + PointTo(MatchFields(IgnoreExtras, Fields{ + "DNSName": Equal("klb.example.com"), + "Targets": ConsistOf("ie.klb.example.com"), + "RecordType": Equal("CNAME"), + "SetIdentifier": Equal("IE"), + "RecordTTL": Equal(externaldns.TTL(300)), + "ProviderSpecific": Equal(externaldns.ProviderSpecific{{Name: "geo-code", Value: "IE"}}), + })), PointTo(MatchFields(IgnoreExtras, Fields{ "DNSName": Equal(TestHostWildcard), "Targets": ConsistOf("klb.example.com"),