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

Update the AKS-Generic Module to support Terraform 3.x.x #124

Merged
merged 3 commits into from
Dec 9, 2024
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
19 changes: 8 additions & 11 deletions modules/azurerm/AKS-Generic/aks_cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ resource "azurerm_kubernetes_cluster" "aks_cluster" {
resource_group_name = var.aks_resource_group_name
dns_prefix = join("-", ["aks", var.aks_cluster_dns_prefix])
kubernetes_version = var.kubernetes_version
api_server_authorized_ip_ranges = var.api_server_authorized_ip_ranges
node_resource_group = join("-", ["rg", var.aks_node_pool_resource_group_name])
sku_tier = var.sku_tier
private_cluster_enabled = var.private_cluster_enabled
Expand All @@ -42,13 +41,13 @@ resource "azurerm_kubernetes_cluster" "aks_cluster" {
zones = var.default_node_pool_availability_zones
os_disk_size_gb = var.default_node_pool_os_disk_size_gb
os_disk_type = var.default_node_pool_os_disk_type
enable_auto_scaling = var.default_node_pool_enable_auto_scaling
auto_scaling_enabled = var.default_node_pool_enable_auto_scaling
vnet_subnet_id = azurerm_subnet.aks_node_pool_subnet.id
max_count = var.default_node_pool_max_count
min_count = var.default_node_pool_min_count
max_pods = var.default_node_pool_max_pods
orchestrator_version = var.default_node_pool_orchestrator_version
enable_node_public_ip = false
node_public_ip_enabled = var.node_public_ip_enabled
only_critical_addons_enabled = var.default_node_pool_only_critical_addons_enabled
}

Expand All @@ -57,7 +56,6 @@ resource "azurerm_kubernetes_cluster" "aks_cluster" {
}

azure_active_directory_role_based_access_control {
managed = true
admin_group_object_ids = var.aks_admin_group_object_ids
azure_rbac_enabled = var.aks_azure_rbac_enabled
}
Expand All @@ -67,13 +65,12 @@ resource "azurerm_kubernetes_cluster" "aks_cluster" {
}

network_profile {
network_plugin = "azure"
network_policy = "calico"
load_balancer_sku = "standard"
service_cidr = var.service_cidr
dns_service_ip = var.dns_service_ip
docker_bridge_cidr = var.docker_bridge_cidr
outbound_type = var.outbound_type
network_plugin = "azure"
network_policy = "calico"
load_balancer_sku = "standard"
service_cidr = var.service_cidr
dns_service_ip = var.dns_service_ip
outbound_type = var.outbound_type
}

lifecycle {
Expand Down
32 changes: 12 additions & 20 deletions modules/azurerm/AKS-Generic/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
# --------------------------------------------------------------------------------------

resource "azurerm_subnet" "aks_node_pool_subnet" {
name = join("-", ["snet", var.aks_node_pool_subnet_name])
resource_group_name = local.virtual_network_resource_group_name
virtual_network_name = var.virtual_network_name
address_prefixes = [var.aks_node_pool_subnet_address_prefix]
service_endpoints = var.aks_nodepool_subnet_allowed_service_endpoints
private_endpoint_network_policies_enabled = var.aks_nodepool_subnet_enforce_private_link_endpoint_network_policies
name = join("-", ["snet", var.aks_node_pool_subnet_name])
resource_group_name = local.virtual_network_resource_group_name
virtual_network_name = var.virtual_network_name
address_prefixes = [var.aks_node_pool_subnet_address_prefix]
service_endpoints = var.aks_nodepool_subnet_allowed_service_endpoints
private_endpoint_network_policies = var.aks_nodepool_subnet_enforce_private_link_endpoint_network_policies
}

resource "azurerm_route_table" "aks_node_pool_route_table" {
Expand Down Expand Up @@ -57,10 +57,6 @@ resource "azurerm_network_security_rule" "aks_node_pool_subnet_nsg_rules" {
direction = each.value.direction
access = each.value.access
protocol = each.value.protocol
source_port_range = each.value.source_port_range
destination_port_range = each.value.destination_port_range
source_address_prefix = each.value.source_address_prefix
destination_address_prefix = each.value.destination_address_prefix
source_port_ranges = each.value.source_port_ranges
destination_port_ranges = each.value.destination_port_ranges
source_address_prefixes = each.value.source_address_prefixes
Expand All @@ -83,12 +79,12 @@ resource "azurerm_subnet_network_security_group_association" "aks_node_pool_subn
}

resource "azurerm_subnet" "internal_load_balancer_subnet" {
name = join("-", ["snet", var.aks_load_balancer_subnet_name])
resource_group_name = local.virtual_network_resource_group_name
virtual_network_name = var.virtual_network_name
address_prefixes = [var.internal_loadbalancer_subnet_address_prefix]
service_endpoints = ["Microsoft.Sql", "Microsoft.ContainerRegistry", "Microsoft.EventHub", "Microsoft.Storage"]
private_endpoint_network_policies_enabled = var.internal_load_balancer_subnet_enforce_private_link_endpoint_network_policies
name = join("-", ["snet", var.aks_load_balancer_subnet_name])
resource_group_name = local.virtual_network_resource_group_name
virtual_network_name = var.virtual_network_name
address_prefixes = [var.internal_loadbalancer_subnet_address_prefix]
service_endpoints = ["Microsoft.Sql", "Microsoft.ContainerRegistry", "Microsoft.EventHub", "Microsoft.Storage"]
private_endpoint_network_policies = var.internal_load_balancer_subnet_enforce_private_link_endpoint_network_policies
}

resource "azurerm_network_security_group" "internal_load_balancer_subnet_nsg" {
Expand All @@ -107,10 +103,6 @@ resource "azurerm_network_security_rule" "aks_load_balancer_subnet_nsg_rules" {
direction = each.value.direction
access = each.value.access
protocol = each.value.protocol
source_port_range = each.value.source_port_range
destination_port_range = each.value.destination_port_range
source_address_prefix = each.value.source_address_prefix
destination_address_prefix = each.value.destination_address_prefix
source_port_ranges = each.value.source_port_ranges
destination_port_ranges = each.value.destination_port_ranges
source_address_prefixes = each.value.source_address_prefixes
Expand Down
31 changes: 9 additions & 22 deletions modules/azurerm/AKS-Generic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,9 @@ variable "aks_node_pool_subnet_nsg_rules" {
direction = string
access = string
protocol = string
source_port_range = string
source_port_ranges = list(string)
destination_port_range = string
destination_port_ranges = list(string)
source_address_prefix = string
source_address_prefixes = list(string)
destination_address_prefix = string
destination_address_prefixes = list(string)
source_application_security_group_ids = list(string)
destination_application_security_group_ids = list(string)
Expand All @@ -131,13 +127,9 @@ variable "aks_load_balancer_subnet_nsg_rules" {
direction = string
access = string
protocol = string
source_port_range = string
source_port_ranges = list(string)
destination_port_range = string
destination_port_ranges = list(string)
source_address_prefix = string
source_address_prefixes = list(string)
destination_address_prefix = string
destination_address_prefixes = list(string)
source_application_security_group_ids = list(string)
destination_application_security_group_ids = list(string)
Expand Down Expand Up @@ -193,11 +185,6 @@ variable "dns_service_ip" {
type = string
}

variable "docker_bridge_cidr" {
description = "CIDR block for the docker bridge"
type = string
}

variable "private_cluster_public_fqdn_enable" {
default = false
description = "Flag for whether a public FQDN for this private cluster should be added."
Expand Down Expand Up @@ -243,6 +230,11 @@ variable "default_node_pool_orchestrator_version" {
description = "Kubernetes version for the default nodepool"
type = string
}
variable "node_public_ip_enabled" {
description = "Flag to assign each node have a public IP address"
type = bool
default = false
}

variable "default_node_pool_only_critical_addons_enabled" {
description = "Flag to only use default nodepool for Critical workloads"
Expand Down Expand Up @@ -297,18 +289,13 @@ variable "azure_policy_enabled" {
}

variable "aks_nodepool_subnet_enforce_private_link_endpoint_network_policies" {
default = false
default = "Disabled"
description = "Enable or Disable network policies for the private link endpoint on the aks nodepool subnet"
type = bool
type = string
}

variable "internal_load_balancer_subnet_enforce_private_link_endpoint_network_policies" {
default = false
default = "Disabled"
description = "Enable or Disable network policies for the private link endpoint on the internal load balancer subnet"
type = bool
}

variable "api_server_authorized_ip_ranges" {
description = "List of authorized IP ranges for the Kubernetes API server"
type = list(string)
type = string
}
Loading