Provision infra for DIGIT on Azure using Terraform
Azure Kubernetes Service (AKS) manages your hosted Kubernetes environment. AKS allows you to deploy and manage containerized applications without container orchestration expertise. AKS also enables you to do many common maintenance operations without taking your app offline. These operations include provisioning, upgrading, and scaling resources on demand.
All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.
The Azure Kubernetes Service (AKS) is one of the Azure services for deploying, managing and scaling any distributed and containerized workloads, here we can provision the AKS cluster on Azure from the ground up using terraform (infra-as-code) and then deploy the DIGIT platform services as config-as-code using Helm.
Know what is terraform: https://youtu.be/h970ZBgKINg
Azure subscription: If you don't have an Azure subscription, create a free account before you begin.
Install Azure CLI
Configure Terraform: Follow the directions in the article, Terraform and configure access to Azure
Azure service principal: Follow the directions in the Create the service principal section in the article, Create an Azure service principal with Azure CLI. Take note of the values for the appId, displayName, password, and tenant.
Install kubectl on your local machine that helps you interact with the kubernetes cluster
Install Helm that helps you package the services along with the configurations, envs, secrets, etc into a Kubernetes manifests
All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.
Annexures:
All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.
To deploy the solution to the cloud there are several ways that we can choose. In this case, we will use terraform as an Infra-as-code.
Terraform is an open source infrastructure as code (IaC) software tool that allows DevOps engineers to programmatically provision the physical resources an application requires to run.
Infrastructure as code is an IT practice that manages an application's underlying IT infrastructure through programming. This approach to resource allocation allows developers to logically manage, monitor and provision resources -- as opposed to requiring that an operations team manually configure each required resource.
Terraform users define and enforce infrastructure configurations by using a JSON-like configuration language called HCL (HashiCorp Configuration Language). HCL's simple syntax makes it easy for DevOps teams to provision and re-provision infrastructure across multiple cloud and on-premises data centers.
Before we provision the cloud resources, we need to understand and be sure about what resources need to be provisioned by terraform to deploy DIGIT. The following picture shows the various key components. (AKS, Node Pools, Postgres DB, Volumes, Load Balancer)
Ideally, one would write the terraform script from the scratch using this doc.
Here we have already written the terraform script that one can reuse/leverage that provisions the production-grade DIGIT Infra and can be customized with the user specific configuration.
Clone the following DIGIT-DevOps where we have all the sample terraform scripts available for you to leverage.
2. Change the main.tf according to your requirements,
3. Declare the variables in variables.tf
Save the file and exit the editor
4. Create a Terraform output file (output.tf) and Paste the following code into file.
Once you have finished declaring the resources, you can deploy all resources.
terraform init
: command is used to initialize a working directory containing Terraform configuration files.
terraform plan
: command creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.
terraform apply
: command executes the actions proposed in a Terraform plan to create or update infrastructure.
After the complete creation, you can see resources in your Azure account.
Now that we know what the terraform script does, the resources graph that it provisions and what custom values should be given with respect to your env.
Let's begin to run the terraform scripts to provision infra required to Deploy DIGIT on Azure.
First CD into the following directory and run the following command 1-by-1 and watch the output closely.
6. Test the Kubernetes cluster
The Kubernetes tools can be used to verify the newly created cluster.
1. Once terraform apply execution is done it will generate the Kubernetes configuration file or you can get it from Terraform state.
2. Set an environment variable so that kubectl picks up the correct config.
3.
Verify the health of the cluster.
You should see the details of your worker nodes, and they should all have a status Ready, as shown in the following image:
All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.