2018-08-20 03:48:22 +02:00
|
|
|
# Organize cluster into a resource group
|
|
|
|
resource "azurerm_resource_group" "cluster" {
|
2019-05-28 06:43:08 +02:00
|
|
|
name = var.cluster_name
|
|
|
|
location = var.region
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_network" "network" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
2019-05-28 06:43:08 +02:00
|
|
|
name = var.cluster_name
|
|
|
|
location = azurerm_resource_group.cluster.location
|
|
|
|
address_space = [var.host_cidr]
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Subnets - separate subnets for controller and workers because Azure
|
|
|
|
# network security groups are based on IPv4 CIDR rather than instance
|
|
|
|
# tags like GCP or security group membership like AWS
|
|
|
|
|
|
|
|
resource "azurerm_subnet" "controller" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "controller"
|
2019-05-28 06:43:08 +02:00
|
|
|
virtual_network_name = azurerm_virtual_network.network.name
|
|
|
|
address_prefix = cidrsubnet(var.host_cidr, 1, 0)
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
2020-03-08 03:40:39 +01:00
|
|
|
resource "azurerm_subnet_network_security_group_association" "controller" {
|
|
|
|
subnet_id = azurerm_subnet.controller.id
|
|
|
|
network_security_group_id = azurerm_network_security_group.controller.id
|
|
|
|
}
|
|
|
|
|
2018-08-20 03:48:22 +02:00
|
|
|
resource "azurerm_subnet" "worker" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "worker"
|
2019-05-28 06:43:08 +02:00
|
|
|
virtual_network_name = azurerm_virtual_network.network.name
|
|
|
|
address_prefix = cidrsubnet(var.host_cidr, 1, 1)
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
2019-05-28 06:43:08 +02:00
|
|
|
|
2020-03-08 03:40:39 +01:00
|
|
|
resource "azurerm_subnet_network_security_group_association" "worker" {
|
|
|
|
subnet_id = azurerm_subnet.worker.id
|
|
|
|
network_security_group_id = azurerm_network_security_group.worker.id
|
|
|
|
}
|
|
|
|
|