
Connect to Azure
az login
Azure list connections
az account list -o table
Name CloudName SubscriptionId TenantId
------------------------ ----------- -------------- --------
Customer1 AzureCloud *****-*****-***** ***-***
Azure Pass - Sponsorship AzureCloud *****-*****-***** ***-***
You can filter single subscription – add in the main.tf filter the subscription and tenant ID

Check SKU for managed Azure Mysql target
az mysql server list-skus --location westeurope -o table

Put SKU name value on database.tf

Check terraform state list
terraform state list

Remove all terraform state (if you redeploy the same test resources how in this case)
terraform state list | cut -f 1 -d '[' | xargs -L 1 terraform state rm

Start and apply Terraform
terraform init
terraform plan -out main.tfplan

Go Terraform and take a coffee!
terraform apply main.tfplan

Azure list resources on “wordpress” Resource Group
az resource list -g wordpress -o table

Terraform output the public IP and we can check on web browser if all is ok


Configure kubectl
az aks get-credentials --resource-group wordpress --name wordpress

Check if pods are up & running
kubectl get pod -o wide

Check Horizontal Replica Set settings (previously configured in deployment.tf)
kubectl get hpa -A

Run load generator to stress cluster
kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://20.231.113.103; done"
Automatic Horizontal Replica running..
kubectl get pods --watch

kubectl get hpa --watch

CTRL + C to block load generator

Numbers of pods back to normal operations


Destroy all
terraform plan -destroy -out main.destroy.tfplan
terraform apply main.destroy.tfplan
List Terraform Azure regions
https://github.com/claranet/terraform-azurerm-regions/blob/master/REGIONS.md
Download