GCP - Provision Infrastructure

Overview

There are several ways to deploy the solution to the cloud. In this case, we will use Terraform 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 clouds and on-premises data centres.

Cloud Resources Required

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 (VPC, GKE, Node Pools, Postgres DB, Volumes, Load Balancer).

Understand Terraform Script

  • Ideally, one would write the Terraform script from 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 customised with the user-specific configuration.

Deployment Steps

  1. Clone the following DIGIT-DevOps, where we have all the sample Terraform scripts available for you to leverage.

  1. Declare the variables in remote-state/variables.tf for GCP storage to maintain assets & terraform remote state.

  1. Update bucket-name in main.tf, to initialize backend.

  1. Declare the variables in variables.tf

Save the files and exit the editor.

Terraform Execution: Infrastructure Resources Provisioning

Once you have finished declaring the resources, you can deploy all resources.

  1. terraform init: command is used to initialise a working directory containing Terraform configuration files.

  2. terraform plan: command creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.

  3. 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 we know what the terraform script does, the resources graph that it provisions and what custom values should be given with respect to your environment. The next step is to begin to run the Terraform scripts to provision the infrastructure required to deploy DIGIT on Azure.

Use the CD command to move into the following directory, run the following commands 1-by-1 and watch the output closely.

Test Kubernetes Cluster

The Kubernetes tools can be used to verify the newly created cluster.

  1. Once the Terraform Apply execution is complete, use the following command to get the kubeconfig. It will store your kubeconfig in the .kube/<file-name> folder.

  1. Verify the health of the cluster. Note: The details of the worker nodes should reflect the status as Ready for All.

  1. Update below output received post terraform apply in the environment configuration

  1. Sample sops configuration

Note: Refer to the HCM deployment documentation to deploy HCM services.

Last updated

Was this helpful?