Skip to content

Commit e78ae0b

Browse files
committed
make private dns reconciliation async
1 parent e4d992a commit e78ae0b

21 files changed

+1767
-1352
lines changed

api/v1beta1/conditions_consts.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ const (
104104
SubnetsReadyCondition clusterv1.ConditionType = "SubnetsReady"
105105
// LoadBalancersReadyCondition means the load balancers exist and are ready to be used.
106106
LoadBalancersReadyCondition clusterv1.ConditionType = "LoadBalancersReady"
107-
// PrivateDNSReadyCondition means the private DNS exists and is ready to be used.
108-
PrivateDNSReadyCondition clusterv1.ConditionType = "PrivateDNSReady"
107+
// PrivateDNSZoneReadyCondition means the private DNS zone exists and is ready to be used.
108+
PrivateDNSZoneReadyCondition clusterv1.ConditionType = "PrivateDNSZoneReady"
109+
// PrivateDNSLinkReadyCondition means the private DNS links exist and are ready to be used.
110+
PrivateDNSLinkReadyCondition clusterv1.ConditionType = "PrivateDNSLinkReady"
111+
// PrivateDNSRecordReadyCondition means the private DNS records exist and are ready to be used.
112+
PrivateDNSRecordReadyCondition clusterv1.ConditionType = "PrivateDNSRecordReady"
109113
// BastionHostReadyCondition means the bastion host exists and is ready to be used.
110114
BastionHostReadyCondition clusterv1.ConditionType = "BastionHostReady"
111115
// InboundNATRulesReadyCondition means the inbound NAT rules exist and are ready to be used.

azure/scope/cluster.go

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"sigs.k8s.io/cluster-api-provider-azure/azure/services/groups"
3535
"sigs.k8s.io/cluster-api-provider-azure/azure/services/loadbalancers"
3636
"sigs.k8s.io/cluster-api-provider-azure/azure/services/natgateways"
37+
"sigs.k8s.io/cluster-api-provider-azure/azure/services/privatedns"
3738
"sigs.k8s.io/cluster-api-provider-azure/azure/services/routetables"
3839
"sigs.k8s.io/cluster-api-provider-azure/azure/services/securitygroups"
3940
"sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets"
@@ -387,35 +388,53 @@ func (s *ClusterScope) VNetSpec() azure.ResourceSpecGetter {
387388
}
388389

389390
// PrivateDNSSpec returns the private dns zone spec.
390-
func (s *ClusterScope) PrivateDNSSpec() *azure.PrivateDNSSpec {
391-
var specs *azure.PrivateDNSSpec
391+
func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, linkSpec, recordSpec []azure.ResourceSpecGetter) {
392392
if s.IsAPIServerPrivate() {
393-
links := make([]azure.PrivateDNSLinkSpec, 1+len(s.Vnet().Peerings))
394-
links[0] = azure.PrivateDNSLinkSpec{
395-
VNetName: s.Vnet().Name,
393+
zone := privatedns.ZoneSpec{
394+
Name: s.GetPrivateDNSZoneName(),
395+
ResourceGroup: s.ResourceGroup(),
396+
ClusterName: s.ClusterName(),
397+
AdditionalTags: s.AdditionalTags(),
398+
}
399+
400+
links := make([]azure.ResourceSpecGetter, 1+len(s.Vnet().Peerings))
401+
links[0] = privatedns.LinkSpec{
402+
Name: azure.GenerateVNetLinkName(s.Vnet().Name),
403+
ZoneName: s.GetPrivateDNSZoneName(),
404+
SubscriptionID: s.SubscriptionID(),
396405
VNetResourceGroup: s.Vnet().ResourceGroup,
397-
LinkName: azure.GenerateVNetLinkName(s.Vnet().Name),
406+
VNetName: s.Vnet().Name,
407+
ResourceGroup: s.ResourceGroup(),
408+
ClusterName: s.ClusterName(),
409+
AdditionalTags: s.AdditionalTags(),
398410
}
399411
for i, peering := range s.Vnet().Peerings {
400-
links[i+1] = azure.PrivateDNSLinkSpec{
401-
VNetName: peering.RemoteVnetName,
412+
links[i+1] = privatedns.LinkSpec{
413+
Name: azure.GenerateVNetLinkName(peering.RemoteVnetName),
414+
ZoneName: s.GetPrivateDNSZoneName(),
415+
SubscriptionID: s.SubscriptionID(),
402416
VNetResourceGroup: peering.ResourceGroup,
403-
LinkName: azure.GenerateVNetLinkName(peering.RemoteVnetName),
417+
VNetName: peering.RemoteVnetName,
418+
ResourceGroup: s.ResourceGroup(),
419+
ClusterName: s.ClusterName(),
420+
AdditionalTags: s.AdditionalTags(),
404421
}
405422
}
406-
specs = &azure.PrivateDNSSpec{
407-
ZoneName: s.GetPrivateDNSZoneName(),
408-
Links: links,
409-
Records: []infrav1.AddressRecord{
410-
{
411-
Hostname: azure.PrivateAPIServerHostname,
412-
IP: s.APIServerPrivateIP(),
413-
},
423+
424+
records := make([]azure.ResourceSpecGetter, 1)
425+
records[0] = privatedns.RecordSpec{
426+
Record: infrav1.AddressRecord{
427+
Hostname: azure.PrivateAPIServerHostname,
428+
IP: s.APIServerPrivateIP(),
414429
},
430+
ZoneName: s.GetPrivateDNSZoneName(),
431+
ResourceGroup: s.ResourceGroup(),
415432
}
433+
434+
return zone, links, records
416435
}
417436

418-
return specs
437+
return nil, nil, nil
419438
}
420439

421440
// IsAzureBastionEnabled returns true if the azure bastion is enabled.
@@ -700,6 +719,9 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
700719
infrav1.VNetReadyCondition,
701720
infrav1.SubnetsReadyCondition,
702721
infrav1.SecurityGroupsReadyCondition,
722+
infrav1.PrivateDNSZoneReadyCondition,
723+
infrav1.PrivateDNSLinkReadyCondition,
724+
infrav1.PrivateDNSRecordReadyCondition,
703725
}})
704726
}
705727

azure/services/privatedns/client.go

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)