Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make private dns reconcile/delete async #2007

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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