|
| 1 | +--- |
| 2 | +title: 'Quickstart: Create a Windows-based Azure Kubernetes Service (AKS) cluster using Terraform' |
| 3 | +description: In this quickstart, you create an Azure Kubernetes cluster with a default node pool and a separate Windows node pool. |
| 4 | +ms.author: schaffererin |
| 5 | +author: schaffererin |
| 6 | +ms.topic: quickstart |
| 7 | +ms.date: 07/15/2024 |
| 8 | +ms.custom: devx-track-terraform |
| 9 | +ms.service: azure-kubernetes-service |
| 10 | +content_well_notification: |
| 11 | + - AI-contribution |
| 12 | +ai-usage: ai-assisted |
| 13 | +#customer intent: As a Terraform user, I want to see how to create an Azure Kubernetes cluster with a Windows node pool. |
| 14 | +--- |
| 15 | + |
| 16 | +# Quickstart: Create a Windows-based Azure Kubernetes Service (AKS) cluster using Terraform |
| 17 | + |
| 18 | +In this quickstart, you create an Azure Kubernetes cluster with a Windows node pool using Terraform. Azure Kubernetes Service (AKS) is a managed container orchestration service provided by Azure. It simplifies the deployment, scaling, and operations of containerized applications. The service uses Kubernetes, an open-source system for automating the deployment, scaling, and management of containerized applications. The Windows node pool allows you to run Windows containers in your Kubernetes cluster. |
| 19 | + |
| 20 | +[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)] |
| 21 | + |
| 22 | +> [!div class="checklist"] |
| 23 | +> * Generate a random resource group name. |
| 24 | +> * Create an Azure resource group. |
| 25 | +> * Create an Azure virtual network. |
| 26 | +> * Create an Azure Kubernetes cluster. |
| 27 | +> * Create an Azure Kubernetes cluster node pool. |
| 28 | +
|
| 29 | +## Prerequisites |
| 30 | + |
| 31 | +- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 32 | + |
| 33 | +- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure) |
| 34 | + |
| 35 | +## Implement the Terraform code |
| 36 | + |
| 37 | +> [!NOTE] |
| 38 | +> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-aks-cluster-windows). You can view the log file containing the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/tree/master/quickstart/101-aks-cluster-windows/TestRecord.md). |
| 39 | +> |
| 40 | +> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform) |
| 41 | +
|
| 42 | +1. Create a directory in which to test and run the sample Terraform code and make it the current directory. |
| 43 | + |
| 44 | +1. Create a file named `providers.tf` and insert the following code. |
| 45 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-aks-cluster-windows/providers.tf"::: |
| 46 | + |
| 47 | +1. Create a file named `main.tf` and insert the following code. |
| 48 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-aks-cluster-windows/main.tf"::: |
| 49 | + |
| 50 | +1. Create a file named `variables.tf` and insert the following code. |
| 51 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-aks-cluster-windows/variables.tf"::: |
| 52 | + |
| 53 | +1. Create a file named `outputs.tf` and insert the following code. |
| 54 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-aks-cluster-windows/outputs.tf"::: |
| 55 | + |
| 56 | +## Initialize Terraform |
| 57 | + |
| 58 | +[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)] |
| 59 | + |
| 60 | +## Create a Terraform execution plan |
| 61 | + |
| 62 | +[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)] |
| 63 | + |
| 64 | +## Apply a Terraform execution plan |
| 65 | + |
| 66 | +[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)] |
| 67 | + |
| 68 | +## Verify the results |
| 69 | + |
| 70 | +Run [kubectl get](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#get) to print the cluster's nodes. |
| 71 | + |
| 72 | +```bash |
| 73 | +kubectl get node -o wide |
| 74 | +``` |
| 75 | + |
| 76 | +## Clean up resources |
| 77 | + |
| 78 | +[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)] |
| 79 | + |
| 80 | +## Troubleshoot Terraform on Azure |
| 81 | + |
| 82 | +[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot). |
| 83 | + |
| 84 | +## Next steps |
| 85 | + |
| 86 | +> [!div class="nextstepaction"] |
| 87 | +> [See more articles about Azure kubernetes cluster](/azure/aks) |
0 commit comments