While working on creating training material on Azure IaC using Terraform, I created a small demo project to create an Azure AKS cluster from scratch and integrated it with Terraform Cloud. It came out quite nicely and therefore I thought I would share it with larger audience 🙂.
Detailed instructions can be found on the repo README. You'll need your own Azure account and a subscription. The AKS cluster code is a local module and the created cluster will have the following features:
- Nodes with Ubuntu OS
- Azure CNI
- Separate vnet and subnet
- Single nodepool with autoscaling enabled
- AKS managed Azure AD integration
- System-assigned managed Identity
- Cluster auto-upgrade enabled
Quick note about Terraform Cloud - if you haven't tried it yet, you should. It has a free plan for smaller teams up to 5 and provides a way to manage state remotely and securely.
Happy coding 🤘.
ospatil / k8s-azure-devops
Experiments with K8s, Azure and DevOps tools like Terraform
Kubernetes, Azure, Terraform and DevOps Sandbox
Base setup
- Install Azure CLI:
brew install azure-cli
. - Install terraform:
brew install terraform
.
Initial Steps
-
Login into Azure using the command
az login
The subscription list can be obtained usingaz account list
Default subscription can be set usingaz account set --subscription <SUBSCRIPTION_ID>
-
Terraform Cloud has a free plan that allows managing remote state. Create a TF Cloud account and a workspace.
-
Login to Terraform Cloud using
terraform login
and follow the instructions. -
Create and configure an Azure service principal in TF Cloud workspace. This will allow TF workspace to connect to and create resources in the Azure subscription.
Add the necessary permissions to the SP to get the AKS admin group name from the
azuread
provider. We only needGroup.Read.All
permission.
Examples
Each subdirectory represents one scenario and usually corresponds to one TF Cloud workspace.
…
Top comments (0)