- 1. Prerequisites
- 2. Download the Azure Cloud Kit
- 3. Configure Azure CLI
- 4. Prepare Environment for Terraform State
- 5. Initialize terraform
- 6. Customize Terraform for your Setup
- 7. Run
- 8. Run
- 9. Use
kubectlto Connect to Kubernetes Cluster
- 10. Cleanup Terraform Deployed Items
Azure Cloud Kit lets you quickly deploy your Vaadin application to Microsoft’s Azure Cloud.
The Azure Cloud Kit includes a set of Terraform blueprints that helps you to deploy your application to Azure Cloud, specifically to Azure Kubernetes Service (AKS). Terraform is an open-source infrastructure as code (IaC) software tool that provides a consistent CLI workflow that allows you safely and predictably to create, change, and improve your cloud infrastructure.
The Azure Cloud Kit is available in a private GitHub repository. If your commercial subscription includes the right to use the Azure Cloud Kit, or if you’d like to obtain a trial license, please contact us through this form, and we’ll provide you access to the private GitHub repository. Once you have access, download the Azure Cloud Kit from github.com/vaadin/azure-kit. When you’ve done this, unzip it to a local directory.
To start, you need to use Azure CLI from a terminal to login to your Azure account. Then select the Azure subscription you want to use for your deployment.
Login to Azure
Select the Azure subscription you want to use for your deployment
az account set --subscription <SUBSCRIPTION_ID>
Verify that you are logged in and the correct subscription is selected
az account show
To use the Azure Cloud Kit, you need to create a storage account and a container for Terraform state.
Terraform state is used to keep track of the resources that have been created.
Terraform uses this information to determine what changes need to be made when you run the
terraform apply command, which is used to deploy your application to Azure.
The Azure Cloud Kit provides a script called,
create_terraform_storage.sh. This script creates a storage account and a container for Terraform state in the Azure subscription you selected.
To run the script, open a terminal and navigate to the folder where you unzipped the Azure Cloud Kit. Then run the following:
The output of the script contains the name of the storage account,
storageaccount. This name is generated randomly and unique for your Azure subscription. You need to use this name in the next step, so make sure you save the
Next, you need to initialize the directory where you unzipped the Azure Cloud Kit as a Terraform working directory. To do this, open a terminal and navigate to that directory and execute the following:
Terraform will then download the Azure provider and other required plugins. During the initialization, Terraform will ask you to provide the name of the storage account you created in the previous step.
Initializing modules... - acr in modules/acr - aks in modules/aks - keyvault in modules/keyvault - network in modules/network Initializing the backend... storage_account_name The name of the storage account. Enter a value: <enter storageaccount name> Successfully configured the backend "azurerm"! Terraform will automatically use this backend unless the backend configuration changes. Initializing provider plugins... ...
The Azure Cloud Kit stores the configuration that defines your deployment in two files:
You’ll find these files in the root directory of the Azure Cloud Kit.
variables.tf file contains most the variables that describe the deployment. These variables include:
The name of your application and the name of your environment;
The Azure region where you want to deploy your application;
The number of nodes in your Kubernetes cluster; and
The size of the nodes.
This list of variables is not comprehensive. There may be others.
settings.tf file contains the network settings for your deployment.
settings.tf files are already populated with default values.
However, you can customize these files to match your needs.
Before you deploy your application to Azure, you should run the
terraform plan command to see what resources will be created.
This command won’t create any resources, but it will show you what resources will be created if you run the
terraform apply command.
This is a good way to verify that the configuration is correct and that you’re satisfied with the resources that will be created.
terraform plan -out=plan.out
Verify the output on screen and proceed if the proposed setup is acceptable.
When you’re satisfied with the output of the
terraform plan command, you can run
terraform apply to deploy your application to Azure.
This command will create all the resources that are defined in the
$ terraform apply "plan.out" azurerm_resource_group.resource_group: Creating... ... Apply complete! Resources: 8 added, 0 changed, 0 destroyed.
To connect to the Kubernetes cluster that was created by the Azure Cloud Kit, use the
kubectl command with the
kubeconfig file. This configuration file was auto-generated by running the
terraform apply command in the earlier step.
To connect specifically to the Kubernetes cluster, run the following from the command line:
$ export KUBECONFIG="./kubeconfig" $ kubectl get nodes NAME STATUS ROLES AGE VERSION aks-nodepool-31060480-vmss000000 Ready agent 3m v1.23.12 aks-nodepool-31060480-vmss000001 Ready agent 3m v1.23.12
In order to get the ingress IP address, you would execute the following from the command line:
$ kubectl -n kube-system get service ingress-nginx-controller NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx-controller LoadBalancer 10.240.97.40 a.b.c.d 80:30799/TCP,443:31928/TCP 106m
If you want to remove all of the resources that were created by the Azure Cloud Kit, you can run the
terraform destroy command like so:
Additionally, you will need to remove manually from the Azure portal the storage account, which is in a file called
storageaccount, and the resource group called,
Terraform-ResourceGroup, which was created by the shell script above.