-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from TomArcherMsft/UserStory275199
User Story 275199
- Loading branch information
Showing
5 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Windows-based Azure Kubernetes Service (AKS) cluster | ||
|
||
This template deploys an AKS cluster with Windows nodes. | ||
|
||
## 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) | ||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | ||
- [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) | ||
- [azurerm_kubernetes_cluster_node_pool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster_node_pool) | ||
|
||
## Variables | ||
|
||
| Name | Description | Default | | ||
|-|-|-| | ||
| `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. | eastus | | ||
| `node_count_linux` | Initial quantity of Linux nodes for the node pool. | 1 | | ||
| `node_count_windows` | Initial quantity of Windows nodes for the node pool. | 1 | | ||
| `admin_username` | Admin username for the Windows node pool. | azureuser | | ||
| `admin_password` | Admin password for the Windows node pool. | Passw0rd1234Us! | | ||
|
||
## Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Generate random resource group name | ||
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 "random_string" "azurerm_kubernetes_cluster_node_pool" { | ||
length = 6 | ||
special = false | ||
numeric = false | ||
lower = true | ||
upper = false | ||
} | ||
|
||
resource "azurerm_virtual_network" "vnet" { | ||
name = "myvnet" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
address_space = ["10.1.0.0/16"] | ||
|
||
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.node_count_linux | ||
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" | ||
} | ||
} | ||
|
||
resource "azurerm_kubernetes_cluster_node_pool" "win" { | ||
name = random_string.azurerm_kubernetes_cluster_node_pool.result | ||
kubernetes_cluster_id = azurerm_kubernetes_cluster.aks.id | ||
vm_size = "Standard_D4s_v3" | ||
node_count = var.node_count_windows | ||
os_type = "Windows" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
output "resource_group_name" { | ||
value = azurerm_resource_group.rg.name | ||
} | ||
|
||
output "kubernetes_cluster_name" { | ||
value = azurerm_kubernetes_cluster.aks.name | ||
} | ||
|
||
output "kubernetes_cluster_dns_prefix" { | ||
value = azurerm_kubernetes_cluster.aks.dns_prefix | ||
} | ||
|
||
output "kubernetes_cluster_node_pool_name" { | ||
value = azurerm_kubernetes_cluster_node_pool.win.name | ||
} | ||
|
||
output "kubernetes_cluster_kube_config_raw" { | ||
value = azurerm_kubernetes_cluster.aks.kube_config_raw | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~>3.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~>3.0" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
variable "resource_group_location" { | ||
type = string | ||
default = "eastus" | ||
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 "node_count_linux" { | ||
type = number | ||
description = "The initial quantity of Linux nodes for the node pool." | ||
default = 1 | ||
} | ||
|
||
variable "node_count_windows" { | ||
type = number | ||
description = "The initial quantity of Windows nodes for the node pool." | ||
default = 1 | ||
} | ||
|
||
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!" | ||
} |