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

User story281947b #387

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions quickstart/101-aks-extended-zones/README.MD
Original file line number Diff line number Diff line change
@@ -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 |
135 changes: 135 additions & 0 deletions quickstart/101-aks-extended-zones/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
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 = ["192.168.0.0/16"]
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name

subnet {
name = "subnet1"
address_prefix = "192.168.1.0/24"
}
}

resource "azapi_resource" "aks" {
count = 1
type = "Microsoft.ContainerService/ManagedClusters@2024-05-01"
name = random_pet.azurerm_kubernetes_cluster_name.id
parent_id = azurerm_resource_group.rg.id
location = azurerm_resource_group.rg.location
identity {
type = "SystemAssigned"
}
body = {
extendedLocation = {
name = var.aks_extended_zone
type = "EdgeZone"
}
sku = {
name = "Base"
tier = "Free"
}
properties = {
dnsPrefix = random_pet.azurerm_kubernetes_cluster_dns_prefix.id
kubernetesVersion = "1.29"
agentPoolProfiles = [
{
name = "agentpool"
count = var.aks_node_count
vmSize = var.aks_node_vm_size
osDiskSizeGB = 128
kubeletDiskType = "OS"
vnetSubnetID = element(tolist(azurerm_virtual_network.vnet.subnet), 0).id
maxPods = 30
type = "VirtualMachineScaleSets"
enableAutoScaling = false,
scaleDownMode = "Delete",
orchestratorVersion = "1.29"
enableNodePublicIP = false
mode = "System"
enableEncryptionAtHost = false
enableUltraSSD = false
osType = "Linux"
osSKU = "Ubuntu"
upgradeSettings = {
maxSurge = "10%"
}
enableFIPS = false
}
]
windowsProfile = {
adminUsername = var.admin_username
adminPassword = var.admin_password
licenseType = "None"
enableCSIProxy = true
}
servicePrincipalProfile = {
clientId = "msi"
}
enableRBAC = true
supportPlan = "KubernetesOfficial"
networkProfile = {
networkPlugin = "azure"
networkPolicy = "none"
networkDataplane = "azure"
loadBalancerSku = "standard"
loadBalancerProfile = {
managedOutboundIPs = {
count = 1
}
backendPoolType = "nodeIPConfiguration"
}
serviceCidr = "10.0.0.0/16"
dnsServiceIP = "10.0.0.10"
outboundType = "loadBalancer"
serviceCidrs = [
"10.0.0.0/16",
]
ipFamilies = ["IPv4"]
}
autoUpgradeProfile = {
upgradeChannel = "none"
nodeOSUpgradeChannel = "NodeImage"
}
disableLocalAccounts = false
storageProfile = {
diskCSIDriver = {
enabled = true
}
fileCSIDriver = {
enabled = true
}
snapshotController = {
enabled = true
}
}
oidcIssuerProfile = {
enabled = false
}
azureMonitorProfile = {
metrics = {
enabled = false
}
}
}
}
timeouts {
create = "6h"
}
}
11 changes: 11 additions & 0 deletions quickstart/101-aks-extended-zones/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
# }
20 changes: 20 additions & 0 deletions quickstart/101-aks-extended-zones/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
azapi = {
source = "Azure/azapi"
version = "2.0.1"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {}
}
47 changes: 47 additions & 0 deletions quickstart/101-aks-extended-zones/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 = "West US"
description = "Location of the resource group."
}

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"
}
Loading