How to create Azure Kubernetes Service using Terraform - Part 1
MakendranG
Posted on May 18, 2022
In this article, We will see how to create AKS cluster using Hashicorp Terraform
How to create Azure Kubernetes Service using Terraform
- How to create Azure Kubernetes Service using Terraform - Part 1
- How to create Azure Kubernetes Service using Terraform - Part 2
Azure Kubernetes Service (AKS) is a highly available, secure, and fully managed Kubernetes service of Microsoft Azure.
AKS is a fully managed service from Microsoft that is highly available and secure.
Azure Kubernetes Service (AKS) simplifies deploying a managed Kubernetes cluster in Azure by offloading the operational overhead to Azure. As a hosted Kubernetes service, Azure handles important tasks, like health monitoring and maintenance. Since Kubernetes masters are managed by Azure, we only manage and maintain the agent nodes. Thus, AKS is free; we only pay for the agent nodes within our clusters, not for the masters.
Pre-requisites
Setting up the Azure account
Before we begin developing clusters and utilizing Terraform, we have to deploy the Azure CLI.
You can locate the respectable documentation on putting in the Azure CLI here.
Terraform Installation
Follow the instructions here to set up Terraform. When you’re done, we need to be in a position to run the terraform command:
terraform -version
Azure Service Principal Creation
We want to create the service principal, for that Kindly run following command in CMD.
az login
Configuring Azure storage to keep Terraform state file
Terraform tracks state locally by means of the terraform.tfstate
file. This pattern works well in a standalone environment. However, in a business enterprise environment, we need to track state using Azure storage
.
Use below option to create an Azure storage account and container:
We have created the following resources to create AKS.
- Terraform hooked up in the machine
- Azure Service Principal – To create the azure k8s
- Azure Storage and containers – To keep tfstate file
Before we execute the terraform, We will create a git repository. Once the repository is ready, create following files,
- provider.tf
- main.tf
- variables.tf
- outputs.tf
Kindly refer the article for How to create Azure Kubernetes Service using Terraform - Part 2
Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.
Posted on May 18, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.