Skip to content

Commit

Permalink
make private dns reconciliation async
Browse files Browse the repository at this point in the history
  • Loading branch information
shysank committed Apr 4, 2022
1 parent e4d992a commit e78ae0b
Show file tree
Hide file tree
Showing 21 changed files with 1,767 additions and 1,352 deletions.
8 changes: 6 additions & 2 deletions api/v1beta1/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ const (
SubnetsReadyCondition clusterv1.ConditionType = "SubnetsReady"
// LoadBalancersReadyCondition means the load balancers exist and are ready to be used.
LoadBalancersReadyCondition clusterv1.ConditionType = "LoadBalancersReady"
// PrivateDNSReadyCondition means the private DNS exists and is ready to be used.
PrivateDNSReadyCondition clusterv1.ConditionType = "PrivateDNSReady"
// PrivateDNSZoneReadyCondition means the private DNS zone exists and is ready to be used.
PrivateDNSZoneReadyCondition clusterv1.ConditionType = "PrivateDNSZoneReady"
// PrivateDNSLinkReadyCondition means the private DNS links exist and are ready to be used.
PrivateDNSLinkReadyCondition clusterv1.ConditionType = "PrivateDNSLinkReady"
// PrivateDNSRecordReadyCondition means the private DNS records exist and are ready to be used.
PrivateDNSRecordReadyCondition clusterv1.ConditionType = "PrivateDNSRecordReady"
// BastionHostReadyCondition means the bastion host exists and is ready to be used.
BastionHostReadyCondition clusterv1.ConditionType = "BastionHostReady"
// InboundNATRulesReadyCondition means the inbound NAT rules exist and are ready to be used.
Expand Down
58 changes: 40 additions & 18 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"sigs.k8s.io/cluster-api-provider-azure/azure/services/groups"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/loadbalancers"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/natgateways"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/privatedns"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/routetables"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/securitygroups"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets"
Expand Down Expand Up @@ -387,35 +388,53 @@ func (s *ClusterScope) VNetSpec() azure.ResourceSpecGetter {
}

// PrivateDNSSpec returns the private dns zone spec.
func (s *ClusterScope) PrivateDNSSpec() *azure.PrivateDNSSpec {
var specs *azure.PrivateDNSSpec
func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, linkSpec, recordSpec []azure.ResourceSpecGetter) {
if s.IsAPIServerPrivate() {
links := make([]azure.PrivateDNSLinkSpec, 1+len(s.Vnet().Peerings))
links[0] = azure.PrivateDNSLinkSpec{
VNetName: s.Vnet().Name,
zone := privatedns.ZoneSpec{
Name: s.GetPrivateDNSZoneName(),
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
}

links := make([]azure.ResourceSpecGetter, 1+len(s.Vnet().Peerings))
links[0] = privatedns.LinkSpec{
Name: azure.GenerateVNetLinkName(s.Vnet().Name),
ZoneName: s.GetPrivateDNSZoneName(),
SubscriptionID: s.SubscriptionID(),
VNetResourceGroup: s.Vnet().ResourceGroup,
LinkName: azure.GenerateVNetLinkName(s.Vnet().Name),
VNetName: s.Vnet().Name,
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
}
for i, peering := range s.Vnet().Peerings {
links[i+1] = azure.PrivateDNSLinkSpec{
VNetName: peering.RemoteVnetName,
links[i+1] = privatedns.LinkSpec{
Name: azure.GenerateVNetLinkName(peering.RemoteVnetName),
ZoneName: s.GetPrivateDNSZoneName(),
SubscriptionID: s.SubscriptionID(),
VNetResourceGroup: peering.ResourceGroup,
LinkName: azure.GenerateVNetLinkName(peering.RemoteVnetName),
VNetName: peering.RemoteVnetName,
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
}
}
specs = &azure.PrivateDNSSpec{
ZoneName: s.GetPrivateDNSZoneName(),
Links: links,
Records: []infrav1.AddressRecord{
{
Hostname: azure.PrivateAPIServerHostname,
IP: s.APIServerPrivateIP(),
},

records := make([]azure.ResourceSpecGetter, 1)
records[0] = privatedns.RecordSpec{
Record: infrav1.AddressRecord{
Hostname: azure.PrivateAPIServerHostname,
IP: s.APIServerPrivateIP(),
},
ZoneName: s.GetPrivateDNSZoneName(),
ResourceGroup: s.ResourceGroup(),
}

return zone, links, records
}

return specs
return nil, nil, nil
}

// IsAzureBastionEnabled returns true if the azure bastion is enabled.
Expand Down Expand Up @@ -700,6 +719,9 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
infrav1.VNetReadyCondition,
infrav1.SubnetsReadyCondition,
infrav1.SecurityGroupsReadyCondition,
infrav1.PrivateDNSZoneReadyCondition,
infrav1.PrivateDNSLinkReadyCondition,
infrav1.PrivateDNSRecordReadyCondition,
}})
}

Expand Down
183 changes: 0 additions & 183 deletions azure/services/privatedns/client.go

This file was deleted.

Loading

0 comments on commit e78ae0b

Please sign in to comment.