October 21, 2020 By Vidyasagar Machupalli 4 min read

Learn how to provision and auto scale VSI on VPC using Terraform scripts and explore auto scale scenarios like SSL termination (offloading) and end-to-end encryption.

With Auto Scale for VPC, you can create an instance group to scale according to your requirements. Based on the target utilization metrics that you define, the instance group can dynamically add or remove instances to achieve your specified instance availability.

Let’s start with a quick one, like an introduction to VPC.

What is a VPC?

A virtual private cloud (VPC) is a public cloud offering that lets an enterprise establish its own private cloud-like computing environment on shared public cloud infrastructure. A VPC gives an enterprise the ability to define and control a virtual network that is logically isolated from all other public cloud tenants, creating a private, secure place on the public cloud.

Auto scaling on VPC

With Auto Scale for VPC, you can improve performance and costs by dynamically creating virtual server instances (VSIs) to meet the demands of your environment. You set scaling policies that define your desired average utilization for metrics like CPU, memory, and network usage. You can create an instance group in your IBM Cloud VPC to auto scale according to your requirements by using the IBM Cloud console. Based on the target utilization metrics that you define, the instance group can dynamically add or remove instances to achieve your specified instance availability.

What’s the outcome?

Following the instructions and executing the Terraform scripts, you will provision the following:

  • A VPC
  • Two subnets — one in each zone (zone 1 and zone 2) — Configure in main.tf file
  • One VSI in subnet-zone-1 (to start with)
  • Load balancer (backend pool and frontend listener)
  • Instance group using an instance template
  • Instance group manager with a scaling policy (CPU utilization) attached to the instance group

Pre-requisites

  • IBM Cloud IAM API key (refer to the IAM documentation)
  • SSH key (refer to the VPC SSH documentation)
  • If you want to enable SSH offloading (termination) or end-to-end encryption, you need to create a Certificate manager service, order a certificate, and pass that to load balancer HTTPS listener. Follow the instructions here to learn the certificate ordering process.

Step-by-step instructions

  1. Clone the vpc-tutorials GitHub repository and move to the vpc-autoscale directory:
    git clone https://github.com/IBM-Cloud/vpc-tutorials.git
    cd vpc-autoscale
  2. Copy the Terraform variables template:
    cp terraform.tfvars.template terraform.tfvars
  3. Update the values in the terraform.tfvars file based on your requirement and save the file. To understand the variables, refer to the variables.tf file.
  4. Initialize the Terraform providers by running the following:
    terraform init
  5. Execute the Terraform plan:
    terraform plan
  6. Apply the Terraform plan:
    terraform apply

Note: The max_membership_count to scale is set to 5, the aggregation_window is set to 90 secs, and cooldown is set to 120 secs. You can change these values in the main.tf file. Refer to the Instance-group-manager Terraform provider documentation.

SSL offloading (termination)

For all incoming HTTPS connections, the load balancer service terminates the SSL connection and establishes a plain-text HTTP communication with the backend server. CPU-intensive SSL handshakes and encryption/decryption tasks are shifted away from the backend servers, allowing them to use all their CPU cycles for processing application traffic.

End-to-end encryption

In this section, you will enable end-to-end encryption by creating a self-signed certificate in the VSI. You will use the SSL installation script – install-software-ssl.sh.

Clean-up

Run the following command to delete the resources you created. The action is irreversible:

terraform destroy

Terraform-as-a-Service

With IBM Cloud Schematics, you can simplify the above Terraform experience. Schematics delivers Terraform-as-a-Service so that you can use a high-level scripting language to model the resources that you want in your IBM Cloud environment and enable Infrastructure as Code (IaC).

Refer to this post to understand how Schematics works with an example.

What’s next?

How about automatically assigning a floating IP to a newly created VSI by monitoring Activity Tracker events and using Cloud Functions to interact with the VPC API? Yes, you can achieve this by following the instructions in this post: “Extend VPC Resources with Cloud Functions, Activity Tracker with LogDNA, and Schematics.” 

Explore other VPC scenarios

There are additional scripts in the vpc-tutorials repo that are used to set-up scenarios for VPC tutorials and to clean up VPC resources:

Questions and feedback

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter @VidyasagarMSC or use the feedback button on the tutorial to report a problem on its content. You can also open issues.

The tutorials section has a feedback form on the side where you can comment on the content. If you have suggestions on the existing tutorials or ideas for future additions, please submit your feedback.

Was this article helpful?
YesNo

More from Cloud

Attention new clients: exciting financial incentives for VMware Cloud Foundation on IBM Cloud

4 min read - New client specials: Get up to 50% off when you commit to a 1- or 3-year term contract on new VCF-as-a-Service offerings, plus an additional value of up to USD 200K in credits through 30 June 2025 when you migrate your VMware workloads to IBM Cloud®.1 Low starting prices: On-demand VCF-as-a-Service deployments begin under USD 200 per month.2 The IBM Cloud benefit: See the potential for a 201%3 return on investment (ROI) over 3 years with reduced downtime, cost and…

24 IBM offerings winning TrustRadius 2024 Top Rated Awards

2 min read - TrustRadius is a buyer intelligence platform for business technology. Comprehensive product information, in-depth customer insights and peer conversations enable buyers to make confident decisions. “Earning a Top Rated Award means the vendor has excellent customer satisfaction and proven credibility. It’s based entirely on reviews and customer sentiment,” said Becky Susko, TrustRadius, Marketing Program Manager of Awards. Top Rated Awards have to be earned: Gain 10+ new reviews in the past 12 months Earn a trScore of 7.5 or higher from…

IBM Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters