vCloud Director 8.10.1, best way to learn cloud AND… – Part 3

So one last thing in this series of blogs, I would like to demo you something easy to setup but perhaps would be very Great in POC. That’s by enabling AutoScaling with vCloud Director. Actually VMware provides an official recommendation HERE on using autoscaling through the use of vRealize Orchestrator with vCloud Director.

So you can implement following with few hundred lines of JavaScripts for VCO workflow Development…

But for POC, the above is just too complicated??? Agree?

So let’s do something Easier!

First of all, I would have like to show you the result of the AutoScaling Mechanism we can achieve.

As you can see from the clip above, the sequence of event we can achieve by following this POC guide for enabling Auto-Scaling in vCloud Director

  1. Stress a VM running on vCloud Director
  2. An alert monitoring Memory is triggered
  3. vCloud Director VM Cloned, Configured with Network and Powered ON

So if this is something you would like to try out and play around, let’s get started!!!

Start the POC Setup

In my setup, of course I have a vCloud Director. But I don’t want to setup a vRO (VCO) just for this POC and making stuffs soooo complicated. Actually if you read into the vCLoud Architecture Framework as mentioned above, the VRO is used for collecting SNMP trap and trigger workflows which help cloning and configuring the VM. This is why I replaced these feature with the following:

  1. vCenter Alarm Definition (Performance Monitor and Trigger)
  2. Trap Receiver (Windows Based SNMP collector)
  3. PowerCLI Script (Execute by Trap Receiver )

Let’s do this quickly!

vCenter Alarm Definition

So, first, you need to define some alert monitor for monitoring a criteria you wanna oversee. In my POC, I setup a alarm definition at vCenter level to monitor the Memory usage.

While 5 mins > 70 will be a warning and 10 mins > 95 is an alert

while the following is more important that we need to ensure a trip is being send out when a warning is triggered

So where does the snmp should send to? We will setup a snmp collector in next step

Trap Receiver 

As mentioned above, we need to have a snmp collector to get the trigger and execute the autoscale out actions. I use a very simple but useful tool which can be installed on any Windows Machine. You can following the steps as below:

Download it from the www.trapreiver.com

Unzip and Execute the Setup binary

Accept the installation path

Complete the setup

Start the Trap Receiver Program and Click the “Configure” button

Add a new “Action” by using “Community” in “Watch” and define the community string under “Equals”. Then we need to select a bat file for it to execute by checking the “Execute” checkbox.

And select the Batch file defined. I will elaborate bit more about the scripts, but anyway you can define an empty bat file like me first

Of course you need to ensure the your vCenter is sending SNMP to this Trap Receiver Equipped Windows Machine

By stressing the VM, you can check if your alert is being triggered and the SNMP trap is being received. So I use “stress” to stress my CentOS machine. Please following this, if you don’t know what’s it.

From the SNMP massage, you should able to read the details

By the way, you can see I define no filter on the SNMP message, so actually every SNMP trap will trigger the action. This is why I have disable all other alert definitions to avoid such. You can do this by PowerCLI easily.

PowerCLI Script

So, as mentioned above, the Trap Receiver will help you collecting the SNMP Trap and Kick off a bat Script. The auto-scaling stuff actually come from the script logic and we need PowerCLI which can help talking to vCloud Director and instruct it working. So followings are my scripts:

As Trap Receiver can only invoke a Batch, so I write a scaleout.bat triggering the PowerShell Script scaleout.ps1.

While the scaleout.bat is as follow:

powershell.exe -ExecutionPolicy Unrestricted -NonInteractive -NoProfile -File C:\autoscale\scaleout.ps1

And the scaleout.ps1 is as follow:

if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {
. “C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1”
}

connect-ciserver -server https://vcd.vmware.lab -user administrator -password P@ssw0rd

$centos_template = Get-CIVMTemplate -Name centos65
$centos_vapp = Get-CIVApp -Name cloud-vm
$centos_vm_count = ($centos_vapp | get-civm).count + 1
$new_civm_name = “cloud-vm-0$centos_vm_count”
$new_civm_computername = “cloudvm0$centos_vm_count”
$new_civm_network = (get-civm cloud-vm-01 | Get-CINetworkAdapter).vAppNetwork

$new_civm = $centos_vapp | new-civm -Name $new_civm_name -ComputerName $new_civm_computername -VMTemplate $centos_template
$new_civm | Get-CINetworkAdapter | Set-CINetworkAdapter -Connected $true -IPAddressAllocationMode Pool -VAppNetwork $new_civm_network
$new_civm | start-civm

disconnect-ciserver * -Confirm:$false

So you can see from the PowerShell Script logic, there are many hard coded stuffs and do remember to check this for your environment to make this working, these includes the assumptions of:

  1. A vCloud Director VM template Named “centos65”
  2. A target vApp named “cloud-vm” we going to Auto-Scaling out

So after setting this up. You are all done.

Conclusion

Again these setup is totally not for production ready environment, but i think this helps providing a very easy and simple demonstration on Auto-Scaling feature on vCloud Director. Although for the true autoscaling you should also configure the load balancer to take up the new node, I wish this helpful enough for you to start trying it in your environment too. As a result you can keep scaling out the nodes like the following clip!

 

vCloud Director 8.10.1, best way to learn cloud AND… – Part 2
vSphere 6.5 Auto Deploy (EFI based) on (Lab) Nested ESXi – Part 1

Leave a Reply

Your email address will not be published / Required fields are marked *