1
-
2
1
module "network" {
3
- source = " Azure/network/azurerm"
2
+ source = " Azure/subnets/azurerm"
3
+ version = " 1.0.0"
4
+
4
5
resource_group_name = azurerm_resource_group. example . name
5
- address_space = " 10.52.0.0/16"
6
- subnet_prefixes = [" 10.52.0.0/24" ]
7
- subnet_names = [" subnet1" ]
8
- depends_on = [azurerm_resource_group . example ]
9
- subnet_enforce_private_link_endpoint_network_policies = {
10
- " subnet1" : true
6
+ subnets = {
7
+ subnet1 = {
8
+ address_prefixes = [" 10.52.0.0/24" ]
9
+ private_endpoint_network_policies_enabled = true
10
+ service_endpoints = [" Microsoft.Storage" ]
11
+ delegations = [
12
+ {
13
+ name = " Microsoft.DBforMySQL.flexibleServers"
14
+ service_delegation = {
15
+ name = " Microsoft.DBforMySQL/flexibleServers"
16
+ actions = [" Microsoft.Network/virtualNetworks/subnets/join/action" ]
17
+ }
18
+ }
19
+ ]
20
+ }
11
21
}
22
+ virtual_network_address_space = [" 10.52.0.0/16" ]
23
+ virtual_network_location = azurerm_resource_group. example . location
24
+ virtual_network_name = " subnet1"
12
25
}
13
26
14
27
resource "azurerm_container_registry" "example" {
@@ -26,44 +39,35 @@ resource "azurerm_role_assignment" "example" {
26
39
depends_on = [module . aks ]
27
40
}
28
41
29
- # Grant AKS cluster access to use AKS subnet
30
- resource "azurerm_role_assignment" "aks" {
31
- principal_id = module. aks . system_assigned_identity [0 ]. principal_id
32
- role_definition_name = " Network Contributor"
33
- scope = module. network . vnet_subnets [0 ]
34
- depends_on = [module . aks ]
35
- }
36
-
37
42
module "aks" {
38
- source = " Azure/aks/azurerm"
39
- version = " 4.16.0"
40
- resource_group_name = azurerm_resource_group. example . name
41
- client_id = var. client_id
42
- client_secret = var. client_secret
43
- kubernetes_version = " 1.23.5"
44
- orchestrator_version = " 1.23.5"
45
- prefix = " default"
46
- cluster_name = var. cluster_name
47
- network_plugin = " azure"
48
- vnet_subnet_id = module. network . vnet_subnets [0 ]
49
- os_disk_size_gb = 50
50
- sku_tier = " Paid" # defaults to Free
51
- enable_role_based_access_control = true
52
- rbac_aad_admin_group_object_ids = var. rbac_aad_admin_group_object_ids
53
- rbac_aad_managed = true
54
- private_cluster_enabled = false
55
- enable_http_application_routing = true
56
- enable_azure_policy = true
57
- enable_auto_scaling = true
58
- enable_host_encryption = false
59
- agents_min_count = 1
60
- agents_max_count = 1
61
- agents_count = null # Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes.
62
- agents_max_pods = 100
63
- agents_pool_name = " exnodepool"
64
- agents_availability_zones = [" 1" , " 2" ]
65
- agents_type = " VirtualMachineScaleSets"
66
- agents_size = " standard_dc2s_v2"
43
+ source = " Azure/aks/azurerm"
44
+ version = " 8.0.0"
45
+ resource_group_name = azurerm_resource_group. example . name
46
+ client_id = var. client_id
47
+ client_secret = var. client_secret
48
+ kubernetes_version = " 1.29.2"
49
+ orchestrator_version = " 1.29.2"
50
+ prefix = " default"
51
+ cluster_name = var. cluster_name
52
+ network_plugin = " azure"
53
+ vnet_subnet_id = module. network . vnet_subnets_name_id [" subnet1" ]
54
+ os_disk_size_gb = 50
55
+ sku_tier = " Standard"
56
+ role_based_access_control_enabled = true
57
+ rbac_aad_admin_group_object_ids = var. rbac_aad_admin_group_object_ids
58
+ rbac_aad_managed = true
59
+ private_cluster_enabled = false
60
+ web_app_routing = { dns_zone_id = " " }
61
+ enable_auto_scaling = true
62
+ enable_host_encryption = false
63
+ agents_min_count = 1
64
+ agents_max_count = 1
65
+ agents_count = null # Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes.
66
+ agents_max_pods = 100
67
+ agents_pool_name = " exnodepool"
68
+ agents_availability_zones = [" 1" , " 2" ]
69
+ agents_type = " VirtualMachineScaleSets"
70
+ agents_size = " standard_dc2s_v2"
67
71
68
72
agents_labels = {
69
73
" nodepool" : " defaultnodepool"
@@ -73,14 +77,12 @@ module "aks" {
73
77
" Agent" : " defaultnodepoolagent"
74
78
}
75
79
76
- enable_ingress_application_gateway = true
77
- ingress_application_gateway_name = " aks-agw "
78
- ingress_application_gateway_subnet_cidr = " 10.52.1 .0/24 "
80
+ network_policy = " azure "
81
+ net_profile_dns_service_ip = " 10.0.0.10 "
82
+ net_profile_service_cidr = " 10.0.0 .0/16 "
79
83
80
- network_policy = " azure"
81
- net_profile_dns_service_ip = " 10.0.0.10"
82
- net_profile_docker_bridge_cidr = " 172.16.0.1/16"
83
- net_profile_service_cidr = " 10.0.0.0/16"
84
+ # Grant AKS cluster access to use AKS subnet
85
+ network_contributor_role_assigned_subnet_ids = { " subnet1" = module.network.vnet_subnets_name_id[" subnet1" ] }
84
86
85
87
depends_on = [module . network ]
86
88
}
0 commit comments