From 7a5a0062e417b02162d3ee2ab900662fdf5e1c66 Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 8 Oct 2024 12:00:04 -0700 Subject: [PATCH 1/7] Initial put --- quickstart/101-aks-extended-zones/main.tf | 58 +++++++++++++++++++ quickstart/101-aks-extended-zones/outputs.tf | 11 ++++ .../101-aks-extended-zones/providers.tf | 16 +++++ .../101-aks-extended-zones/variables.tf | 47 +++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 quickstart/101-aks-extended-zones/main.tf create mode 100644 quickstart/101-aks-extended-zones/outputs.tf create mode 100644 quickstart/101-aks-extended-zones/providers.tf create mode 100644 quickstart/101-aks-extended-zones/variables.tf diff --git a/quickstart/101-aks-extended-zones/main.tf b/quickstart/101-aks-extended-zones/main.tf new file mode 100644 index 000000000..2af73c3c2 --- /dev/null +++ b/quickstart/101-aks-extended-zones/main.tf @@ -0,0 +1,58 @@ +resource "random_pet" "rg_name" { + prefix = var.resource_group_name_prefix +} + +resource "azurerm_resource_group" "rg" { + location = var.resource_group_location + name = random_pet.rg_name.id +} + +resource "random_pet" "azurerm_kubernetes_cluster_name" { + prefix = "cluster" +} + +resource "random_pet" "azurerm_kubernetes_cluster_dns_prefix" { + prefix = "dns" +} + +resource "azurerm_virtual_network" "vnet" { + name = var.virtual_network_name + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + + subnet { + name = "subnet1" + address_prefix = "10.1.1.0/24" + } +} + +resource "azurerm_kubernetes_cluster" "aks" { + name = random_pet.azurerm_kubernetes_cluster_name.id + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + dns_prefix = random_pet.azurerm_kubernetes_cluster_dns_prefix.id + + identity { + type = "SystemAssigned" + } + + default_node_pool { + name = "agentpool" + vm_size = "Standard_D2_v2" + node_count = var.aks_node_count + vnet_subnet_id = element(tolist(azurerm_virtual_network.vnet.subnet), 0).id + } + + windows_profile { + admin_username = var.admin_username + admin_password = var.admin_password + } + + network_profile { + network_plugin = "azure" + load_balancer_sku = "standard" + } + + edge_zone = var.aks_extended_zone +} \ No newline at end of file diff --git a/quickstart/101-aks-extended-zones/outputs.tf b/quickstart/101-aks-extended-zones/outputs.tf new file mode 100644 index 000000000..c2cce80fb --- /dev/null +++ b/quickstart/101-aks-extended-zones/outputs.tf @@ -0,0 +1,11 @@ +output "resource_group_name" { + value = azurerm_resource_group.rg.name +} + +output "aks_cluster_name" { + value = azurerm_kubernetes_cluster.aks.name +} + +output "aks_extended_zone" { + value = azurerm_kubernetes_cluster.aks.edge_zone +} \ No newline at end of file diff --git a/quickstart/101-aks-extended-zones/providers.tf b/quickstart/101-aks-extended-zones/providers.tf new file mode 100644 index 000000000..7261b1fb4 --- /dev/null +++ b/quickstart/101-aks-extended-zones/providers.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~>3.0" + } + random = { + source = "hashicorp/random" + version = "~>3.0" + } + } +} + +provider "azurerm" { + features {} +} \ No newline at end of file diff --git a/quickstart/101-aks-extended-zones/variables.tf b/quickstart/101-aks-extended-zones/variables.tf new file mode 100644 index 000000000..b0ed48e5b --- /dev/null +++ b/quickstart/101-aks-extended-zones/variables.tf @@ -0,0 +1,47 @@ +variable "resource_group_location" { + type = string + default = "Central US" + description = "Location of the resource group." +} + +variable "resource_group_name_prefix" { + type = string + default = "rg" + description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." +} + +variable "virtual_network_name" { + type = string + description = "Virtual network names" + default = "example-vnet" +} + +variable "aks_node_count" { + type = number + description = "AKS node count" + default = 3 +} + +variable "aks_node_vm_size" { + type = string + description = "AKS node VM size" + default = "Standard_D2_v2" +} + +variable "admin_username" { + type = string + description = "The admin username for the Windows node pool." + default = "azureuser" +} + +variable "admin_password" { + type = string + description = "The admin password for the Windows node pool." + default = "Passw0rd1234Us!" +} + +variable "aks_extended_zone" { + type = string + description = "AKS extended zone" + default = "Los Angeles" +} \ No newline at end of file From 42d2f05b88628e3b9c6bd30ffae9cb0b6cef6b5e Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 8 Oct 2024 12:22:17 -0700 Subject: [PATCH 2/7] Added README --- quickstart/101-aks-extended-zones/README.MD | 23 +++++++++++++++++++ quickstart/101-aks-extended-zones/main.tf | 2 +- .../101-aks-extended-zones/variables.tf | 12 +++++----- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 quickstart/101-aks-extended-zones/README.MD diff --git a/quickstart/101-aks-extended-zones/README.MD b/quickstart/101-aks-extended-zones/README.MD new file mode 100644 index 000000000..c88c9d72c --- /dev/null +++ b/quickstart/101-aks-extended-zones/README.MD @@ -0,0 +1,23 @@ +# Azure Kubernetes Service (AKS) cluster in an Azure Extended Zone + +This template deploys an Azure Kubernetes Service (AKS) cluster in an Azure Extended Zones. + +## Terraform resource types + +- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) +- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) +- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) +- [azurerm_kubernetes_cluster](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster) + +## Variables + +| Name | Description | Default value | +|-|-|-| +| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg | +| `resource_group_location` | Location of the resource group. | Central US | +| `virtual_network_name` | Name of the virtual network resource. | example-vnet | +| `aks_node_count` | Number of nodes in the AKS cluster. | 3 | +| `aks_node_vm_size` | Size of the VMs in the AKS cluster. | Standard_D2_v2 | +| `admin_username` | The admin username for the Windows node pool. | azureuser | +| `admin_password` | The admin password for the Windows node pool. | Passw0rd1234Us! | +| `aks_extended_zone` | AKS extended zone. | Los Angeles | diff --git a/quickstart/101-aks-extended-zones/main.tf b/quickstart/101-aks-extended-zones/main.tf index 2af73c3c2..1527060e8 100644 --- a/quickstart/101-aks-extended-zones/main.tf +++ b/quickstart/101-aks-extended-zones/main.tf @@ -39,7 +39,7 @@ resource "azurerm_kubernetes_cluster" "aks" { default_node_pool { name = "agentpool" - vm_size = "Standard_D2_v2" + vm_size = var.aks_node_vm_size node_count = var.aks_node_count vnet_subnet_id = element(tolist(azurerm_virtual_network.vnet.subnet), 0).id } diff --git a/quickstart/101-aks-extended-zones/variables.tf b/quickstart/101-aks-extended-zones/variables.tf index b0ed48e5b..2569852b6 100644 --- a/quickstart/101-aks-extended-zones/variables.tf +++ b/quickstart/101-aks-extended-zones/variables.tf @@ -1,15 +1,15 @@ -variable "resource_group_location" { - type = string - default = "Central US" - description = "Location of the resource group." -} - variable "resource_group_name_prefix" { type = string default = "rg" description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." } +variable "resource_group_location" { + type = string + default = "Central US" + description = "Location of the resource group." +} + variable "virtual_network_name" { type = string description = "Virtual network names" From 5fab9cadd829bdb8ae69721ad26cda45eacf840c Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 8 Oct 2024 12:42:41 -0700 Subject: [PATCH 3/7] Trying to fix IP address errors --- quickstart/101-aks-extended-zones/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickstart/101-aks-extended-zones/main.tf b/quickstart/101-aks-extended-zones/main.tf index 1527060e8..fe6cff5cb 100644 --- a/quickstart/101-aks-extended-zones/main.tf +++ b/quickstart/101-aks-extended-zones/main.tf @@ -17,13 +17,13 @@ resource "random_pet" "azurerm_kubernetes_cluster_dns_prefix" { resource "azurerm_virtual_network" "vnet" { name = var.virtual_network_name - address_space = ["10.0.0.0/16"] + address_space = ["192.168.0.0/16"] location = azurerm_resource_group.rg.location resource_group_name = azurerm_resource_group.rg.name subnet { name = "subnet1" - address_prefix = "10.1.1.0/24" + address_prefix = "192.168.1.0/24" } } From cb439f7d5869b0e9a52aa7ef4091bbe55372fadf Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 8 Oct 2024 12:56:10 -0700 Subject: [PATCH 4/7] Changed rg loc to access extended zone of 'los angeles' --- quickstart/101-aks-extended-zones/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/101-aks-extended-zones/variables.tf b/quickstart/101-aks-extended-zones/variables.tf index 2569852b6..d66cf8c1d 100644 --- a/quickstart/101-aks-extended-zones/variables.tf +++ b/quickstart/101-aks-extended-zones/variables.tf @@ -6,7 +6,7 @@ variable "resource_group_name_prefix" { variable "resource_group_location" { type = string - default = "Central US" + default = "West US" description = "Location of the resource group." } From 20f388a4abb878c53db4b21dc2f76546a052de3c Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 8 Oct 2024 13:21:26 -0700 Subject: [PATCH 5/7] Changed rg loc --- quickstart/101-aks-extended-zones/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/101-aks-extended-zones/variables.tf b/quickstart/101-aks-extended-zones/variables.tf index d66cf8c1d..9e9210742 100644 --- a/quickstart/101-aks-extended-zones/variables.tf +++ b/quickstart/101-aks-extended-zones/variables.tf @@ -6,7 +6,7 @@ variable "resource_group_name_prefix" { variable "resource_group_location" { type = string - default = "West US" + default = "West US 2" description = "Location of the resource group." } From af54768aa48044331006276fef35cd4d6156208a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 30 Oct 2024 05:25:29 +0000 Subject: [PATCH 6/7] increase create timeout --- quickstart/101-aks-extended-zones/main.tf | 4 ++++ quickstart/101-aks-extended-zones/variables.tf | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/quickstart/101-aks-extended-zones/main.tf b/quickstart/101-aks-extended-zones/main.tf index fe6cff5cb..fee3e4266 100644 --- a/quickstart/101-aks-extended-zones/main.tf +++ b/quickstart/101-aks-extended-zones/main.tf @@ -55,4 +55,8 @@ resource "azurerm_kubernetes_cluster" "aks" { } edge_zone = var.aks_extended_zone + + timeouts { + create = "3h" + } } \ No newline at end of file diff --git a/quickstart/101-aks-extended-zones/variables.tf b/quickstart/101-aks-extended-zones/variables.tf index 9e9210742..d66cf8c1d 100644 --- a/quickstart/101-aks-extended-zones/variables.tf +++ b/quickstart/101-aks-extended-zones/variables.tf @@ -6,7 +6,7 @@ variable "resource_group_name_prefix" { variable "resource_group_location" { type = string - default = "West US 2" + default = "West US" description = "Location of the resource group." } From c7cf719ed111248c3a8981b4423238b5e91f93d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 30 Oct 2024 08:46:23 +0000 Subject: [PATCH 7/7] increase create timeout --- quickstart/101-aks-extended-zones/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/101-aks-extended-zones/main.tf b/quickstart/101-aks-extended-zones/main.tf index fee3e4266..3a2a8900a 100644 --- a/quickstart/101-aks-extended-zones/main.tf +++ b/quickstart/101-aks-extended-zones/main.tf @@ -57,6 +57,6 @@ resource "azurerm_kubernetes_cluster" "aks" { edge_zone = var.aks_extended_zone timeouts { - create = "3h" + create = "6h" } } \ No newline at end of file