Getting Started with Azure Cloud Kit
Azure Cloud Kit lets you deploy quickly your Vaadin application to Microsoft’s Azure Cloud. The Kit includes a set of Terraform blueprints for deploying 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.
Download Azure Cloud Kit
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 Vaadin, and you’ll be provided access to the private GitHub repository.
Once you have access, download the Azure Cloud Kit from GitHub. Then extract it to a local directory.
Configure Azure CLI
To start, you need to use Azure CLI from a terminal to log into your Azure account. Then select the Azure subscription you want to use for your deployment.
Log into Azure by executing the following from a terminal:
az login
Now, select the Azure subscription you want to use for your deployment:
az account set --subscription <SUBSCRIPTION_ID>
Be sure to verify that you’re logged in, and that the correct subscription is selected. You can do this by executing the following:
az account show
Prepare Environment for Terraform State
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 the necessary changes when you run terraform apply
, which is used to deploy your application to Azure.
Included in Azure Cloud Kit is a script called, create_terraform_storage.sh
. When run, it’ll create a storage account and a container for Terraform state in the Azure subscription you selected.
To run the script, open a terminal window and navigate to the folder where you extracted the Azure Cloud Kit. Then executed the following from the command-line:
create_terraform_storage.sh
The output of the script contains the name of the storage account (i.e., the storageaccount
). It’s generated randomly and is unique for your Azure subscription. You’ll need to use that name in the next step, so be sure to make note of the storageaccount
value.
Initialize Terraform
Next, you need to initialize the directory where you extracted 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 init
Terraform then downloads the Azure provider and other required plugins. During the initialization, Terraform asks 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...
...
Customizing
The Azure Cloud Kit stores the configuration that defines your deployment in two files: variables.tf
and settings.tf
. You’ll find these files in the root directory of the Azure Cloud Kit.
The variables.tf
file contains most of the variables that describe the deployment. They 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 isn’t comprehensive. There may be others.
The settings.tf
file contains the network settings for your deployment.
The variables.tf
and settings.tf
files are already populated with default values. However, you can edit them to suit your needs.
Check the Plan
Before you deploy your application to Azure, you should run the terraform
command with the plan
option to see what resources it’ll create. Using it with that option only shows you what resources it’ll create if you were to run the command with the apply
option — which you’ll do in the next step. It’s a good way to verify that the configuration is correct, and to make sure you’re satisfied with the resources that’ll be created.
terraform plan -out=plan.out
After executing this, verify the output on screen and proceed to the next step — if the proposed setup is acceptable.
Apply Terraform
Assuming you’re satisfied with the output from terraform plan
, you can run terraform
with the apply
option. It’ll deploy your application to Azure, and create all of the resources that are defined in the variables.tf
and settings.tf
files.
$ terraform apply "plan.out"
azurerm_resource_group.resource_group: Creating...
...
Apply complete! Resources: 8 added, 0 changed, 0 destroyed.
You would execute only what’s shown here on the first line, after the dollar-sign prompt. The rest that’s shown are sample results. Your results may differ.
Connect to Kubernetes Cluster
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 when you ran terraform apply
in the previous step.
To connect specifically to the Kubernetes cluster, execute 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
Cleanup Terraform Deployed Items
If you want to remove all of the resources that were created by the Azure Cloud Kit, you can run the following from the command-line:
terraform destroy
Additionally, you’ll need to remove manually the storage account (i.e., storageaccount
) from the Azure portal, and the resource group called, Terraform-ResourceGroup
. It was created by the shell script above.
3EFFB1E4-FEF7-4836-90A4-30B9B6CB455E