diff --git a/Gopkg.lock b/Gopkg.lock index fda2380b1dc..8ade119c8da 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -18,7 +18,7 @@ version = "v0.4.11" [[projects]] - digest = "1:935d0d8d2e432e3ab8a86d095ac5cd9fb2795170c472c1ebdd4a525f13c123c1" + digest = "1:0e1b77a659461596e0b6ab8187c0672082452135e7d842cab03c89fe35a5b3d9" name = "github.com/Azure/azure-sdk-for-go" packages = [ "profiles/latest/dns/mgmt/dns", @@ -27,6 +27,7 @@ "services/dns/mgmt/2017-10-01/dns", "services/graphrbac/1.6/graphrbac", "services/preview/dns/mgmt/2018-03-01-preview/dns", + "services/privatedns/mgmt/2018-09-01/privatedns", "services/resources/mgmt/2018-05-01/resources", "services/resources/mgmt/2018-06-01/subscriptions", "version", @@ -1287,6 +1288,7 @@ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute", "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac", "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns", + "github.com/Azure/azure-sdk-for-go/services/privatedns/mgmt/2018-09-01/privatedns", "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources", "github.com/Azure/go-autorest/autorest", "github.com/Azure/go-autorest/autorest/azure", diff --git a/data/data/azure/bootstrap/variables.tf b/data/data/azure/bootstrap/variables.tf index 1c076440596..b4eaa9d6e3f 100644 --- a/data/data/azure/bootstrap/variables.tf +++ b/data/data/azure/bootstrap/variables.tf @@ -59,11 +59,6 @@ variable "tags" { description = "tags to be applied to created resources." } -variable "private_dns_zone_id" { - type = string - description = "This is to create explicit dependency on private zone to exist before VMs are created in the vnet. https://github.com/MicrosoftDocs/azure-docs/issues/13728" -} - variable "nsg_name" { type = string description = "The network security group for the subnet." diff --git a/data/data/azure/dns/dns.tf b/data/data/azure/dns/dns.tf index 4062bf04c12..a9e21266ff4 100644 --- a/data/data/azure/dns/dns.tf +++ b/data/data/azure/dns/dns.tf @@ -3,17 +3,29 @@ locals { api_external_name = "api.${replace(var.cluster_domain, ".${var.base_domain}", "")}" } -resource "azurerm_dns_a_record" "apiint_internal" { +resource "azureprivatedns_zone" "private" { + name = var.cluster_domain + resource_group_name = var.resource_group_name +} + +resource "azureprivatedns_zone_virtual_network_link" "network" { + name = "${var.cluster_id}-network-link" + resource_group_name = var.resource_group_name + private_dns_zone_name = azureprivatedns_zone.private.name + virtual_network_id = var.virtual_network +} + +resource "azureprivatedns_a_record" "apiint_internal" { name = "api-int" - zone_name = var.private_dns_zone_name + zone_name = azureprivatedns_zone.private.name resource_group_name = var.resource_group_name ttl = 300 records = [var.internal_lb_ipaddress] } -resource "azurerm_dns_a_record" "api_internal" { +resource "azureprivatedns_a_record" "api_internal" { name = "api" - zone_name = var.private_dns_zone_name + zone_name = azureprivatedns_zone.private.name resource_group_name = var.resource_group_name ttl = 300 records = [var.internal_lb_ipaddress] @@ -27,26 +39,26 @@ resource "azurerm_dns_cname_record" "api_external" { record = var.external_lb_fqdn } -resource "azurerm_dns_a_record" "etcd_a_nodes" { +resource "azureprivatedns_a_record" "etcd_a_nodes" { count = var.etcd_count name = "etcd-${count.index}" - zone_name = var.private_dns_zone_name + zone_name = azureprivatedns_zone.private.name resource_group_name = var.resource_group_name ttl = 60 records = [var.etcd_ip_addresses[count.index]] } -resource "azurerm_dns_srv_record" "etcd_cluster" { +resource "azureprivatedns_srv_record" "etcd_cluster" { name = "_etcd-server-ssl._tcp" - zone_name = var.private_dns_zone_name + zone_name = azureprivatedns_zone.private.name resource_group_name = var.resource_group_name ttl = 60 dynamic "record" { - for_each = azurerm_dns_a_record.etcd_a_nodes.*.name + for_each = azureprivatedns_a_record.etcd_a_nodes.*.name iterator = name content { - target = "${name.value}.${var.private_dns_zone_name}" + target = "${name.value}.${azureprivatedns_zone.private.name}" priority = 10 weight = 10 port = 2380 diff --git a/data/data/azure/dns/variables.tf b/data/data/azure/dns/variables.tf index c63057bbfe7..d9111ca38c3 100644 --- a/data/data/azure/dns/variables.tf +++ b/data/data/azure/dns/variables.tf @@ -4,6 +4,11 @@ variable "tags" { description = "tags to be applied to created resources." } +variable "cluster_id" { + description = "The identifier for the cluster." + type = string +} + variable "cluster_domain" { description = "The domain for the cluster that all DNS records must belong" type = string @@ -29,8 +34,8 @@ variable "internal_lb_ipaddress" { type = string } -variable "private_dns_zone_name" { - description = "private DNS zone name that should be used for records" +variable "virtual_network" { + description = "The ID for Virtual Network that will be linked to the Private DNS zone." type = string } diff --git a/data/data/azure/main.tf b/data/data/azure/main.tf index 4faaede12e7..c2d62ca9147 100644 --- a/data/data/azure/main.tf +++ b/data/data/azure/main.tf @@ -5,9 +5,6 @@ locals { }, var.azure_extra_tags, ) - - master_subnet_cidr = cidrsubnet(var.machine_cidr, 3, 0) #master subnet is a smaller subnet within the vnet. i.e from /21 to /24 - node_subnet_cidr = cidrsubnet(var.machine_cidr, 3, 1) #node subnet is a smaller subnet within the vnet. i.e from /21 to /24 } provider "azurerm" { @@ -17,6 +14,13 @@ provider "azurerm" { tenant_id = var.azure_tenant_id } +provider "azureprivatedns" { + subscription_id = var.azure_subscription_id + client_id = var.azure_client_id + client_secret = var.azure_client_secret + tenant_id = var.azure_tenant_id +} + module "bootstrap" { source = "./bootstrap" resource_group_name = azurerm_resource_group.main.name @@ -32,24 +36,15 @@ module "bootstrap" { tags = local.tags storage_account = azurerm_storage_account.cluster nsg_name = module.vnet.master_nsg_name - - # This is to create explicit dependency on private zone to exist before VMs are created in the vnet. https://github.com/MicrosoftDocs/azure-docs/issues/13728 - private_dns_zone_id = azurerm_dns_zone.private.id } module "vnet" { source = "./vnet" - vnet_name = azurerm_virtual_network.cluster_vnet.name resource_group_name = azurerm_resource_group.main.name vnet_cidr = var.machine_cidr - master_subnet_cidr = local.master_subnet_cidr - node_subnet_cidr = local.node_subnet_cidr cluster_id = var.cluster_id region = var.azure_region dns_label = var.cluster_id - - # This is to create explicit dependency on private zone to exist before VMs are created in the vnet. https://github.com/MicrosoftDocs/azure-docs/issues/13728 - private_dns_zone_id = azurerm_dns_zone.private.id } module "master" { @@ -69,20 +64,18 @@ module "master" { instance_count = var.master_count storage_account = azurerm_storage_account.cluster os_volume_size = var.azure_master_root_volume_size - - # This is to create explicit dependency on private zone to exist before VMs are created in the vnet. https://github.com/MicrosoftDocs/azure-docs/issues/13728 - private_dns_zone_id = azurerm_dns_zone.private.id } module "dns" { source = "./dns" cluster_domain = var.cluster_domain + cluster_id = var.cluster_id base_domain = var.base_domain + virtual_network = module.vnet.network_id external_lb_fqdn = module.vnet.public_lb_pip_fqdn internal_lb_ipaddress = module.vnet.internal_lb_ip_address resource_group_name = azurerm_resource_group.main.name base_domain_resource_group_name = var.azure_base_domain_resource_group_name - private_dns_zone_name = azurerm_dns_zone.private.name etcd_count = var.master_count etcd_ip_addresses = module.master.ip_addresses } @@ -120,21 +113,6 @@ resource "azurerm_role_assignment" "main" { principal_id = azurerm_user_assigned_identity.main.principal_id } -# https://github.com/MicrosoftDocs/azure-docs/issues/13728 -resource "azurerm_dns_zone" "private" { - name = var.cluster_domain - resource_group_name = azurerm_resource_group.main.name - zone_type = "Private" - resolution_virtual_network_ids = [azurerm_virtual_network.cluster_vnet.id] -} - -resource "azurerm_virtual_network" "cluster_vnet" { - name = "${var.cluster_id}-vnet" - resource_group_name = azurerm_resource_group.main.name - location = var.azure_region - address_space = [var.machine_cidr] -} - # copy over the vhd to cluster resource group and create an image using that resource "azurerm_storage_container" "vhd" { name = "vhd" diff --git a/data/data/azure/master/variables.tf b/data/data/azure/master/variables.tf index 98a4a63567c..b5199ac38b8 100644 --- a/data/data/azure/master/variables.tf +++ b/data/data/azure/master/variables.tf @@ -78,11 +78,6 @@ variable "ignition" { type = string } -variable "private_dns_zone_id" { - type = string - description = "This is to create explicit dependency on private zone to exist before VMs are created in the vnet. https://github.com/MicrosoftDocs/azure-docs/issues/13728" -} - variable "availability_zones" { type = list(string) description = "List of the availability zones in which to create the masters. The length of this list must match instance_count." diff --git a/data/data/azure/vnet/common.tf b/data/data/azure/vnet/common.tf index 227f9f12fdf..1ac4c4967a8 100644 --- a/data/data/azure/vnet/common.tf +++ b/data/data/azure/vnet/common.tf @@ -3,15 +3,11 @@ // Only reference data sources which are guaranteed to exist at any time (above) in this locals{} block locals { - subnet_ids = azurerm_subnet.master_subnet.id - - lb_fqdn = azurerm_lb.public.id - - elb_backend_pool_id = azurerm_lb_backend_address_pool.master_public_lb_pool.id - - internal_lb_controlplane_pool_id = azurerm_lb_backend_address_pool.internal_lb_controlplane_pool.id - - public_lb_id = azurerm_lb.public.id - internal_lb_id = azurerm_lb.internal.id + master_subnet_cidr = cidrsubnet(var.vnet_cidr, 3, 0) #master subnet is a smaller subnet within the vnet. i.e from /21 to /24 + node_subnet_cidr = cidrsubnet(var.vnet_cidr, 3, 1) #node subnet is a smaller subnet within the vnet. i.e from /21 to /24 } +data "azurerm_virtual_network" "cluster_vnet" { + name = azurerm_virtual_network.cluster_vnet.name + resource_group_name = var.resource_group_name +} diff --git a/data/data/azure/vnet/outputs.tf b/data/data/azure/vnet/outputs.tf index 49720e252e5..dc46a8f381a 100644 --- a/data/data/azure/vnet/outputs.tf +++ b/data/data/azure/vnet/outputs.tf @@ -2,8 +2,12 @@ output "cluster-pip" { value = azurerm_public_ip.cluster_public_ip.ip_address } +output "network_id" { + value = data.azurerm_virtual_network.cluster_vnet.id +} + output "public_subnet_id" { - value = local.subnet_ids + value = azurerm_subnet.master_subnet.id } output "public_lb_backend_pool_id" { @@ -11,11 +15,11 @@ output "public_lb_backend_pool_id" { } output "internal_lb_backend_pool_id" { - value = local.internal_lb_controlplane_pool_id + value = azurerm_lb_backend_address_pool.internal_lb_controlplane_pool.id } output "public_lb_id" { - value = local.public_lb_id + value = azurerm_lb.public.id } output "public_lb_pip_fqdn" { diff --git a/data/data/azure/vnet/variables.tf b/data/data/azure/vnet/variables.tf index 607f2cc10c4..a7538a697ce 100644 --- a/data/data/azure/vnet/variables.tf +++ b/data/data/azure/vnet/variables.tf @@ -1,21 +1,7 @@ -variable "vnet_name" { - type = string -} - variable "vnet_cidr" { type = string } -variable "master_subnet_cidr" { - type = string - description = "The subnet for the masters" -} - -variable "node_subnet_cidr" { - type = string - description = "The subnet for the workers" -} - variable "resource_group_name" { type = string description = "Resource group for the deployment" @@ -50,8 +36,3 @@ variable "dns_label" { type = string description = "The label used to build the dns name. i.e.