In this post I’m going to run through how you can deploy a load balanced server farm in VMM 2012 SP1. My example will be using the Citrix NetScaler VPX virtual load balancing appliance. The Brocade ADX and F5 Big-IP also have support for this functionality – there may be more but I’m not aware of them.
I got a demo of this appliance. The install is easy enough; unzip the files, place them on a host, register the machine in place (Hyper-V Manager), refresh the host in VMM, assign and record a static MAC address for the legacy network adapter. Power it up, assign an IP config when prompted. The default user name and password are nsroot and nsroot. In the email from Citrix there is a product key – which is useless by itself. Log into www.citrix.com/account (I had to use Chrome because the site didn’t like IE10), go to Activate And Allocate Licenses, click Don’t See Your Product, enter the product key and the recorded static MAC of the VPX appliance, and now a license file should appear under View Licenses. Download that file. Now browse to the IP that you assigned to the NetScaler. During the mini-setup wizard, you’ll see a link to manage licenses. Click that and upload your license file. Your NetScaler appliance will reboot. Log back into the NetScaler via your browser, right-click Load Balancing on the left, and Enable Load Balancing Feature. Phew!
By the way, your browser will require … Java. Oh! The horror! My advice: have an admin VM that you never venture online with. Dell storage requires Java too. Jeez!
Load Balancer Provider
The next step is to download the VMM provider for your load balancer. This provider gives VMM and interface to integrate with the load balancer. You will install this on your VMM server. The Citrix one is a bit of a next-next-next installer.
Note: VMM will not be able to use this provider until you start the VMM service on your VMM server.
Run As Account
VMM will require a run-as account to log into and manage the load balancer. You create that in Settings > Security > Run As Accounts
Name it after your LB, and enter the user name and password.
Virtual IP Address Pool
Your LB will require virtual IPs (VIPs). A VIP is used by a client (user or application) to access the load balanced service which actually spans multiple obscured IP addresses. That means you only need to register the VIP in DNS for the load balanced service.
Identify the logical network, network site (and thus the IP pool) that will be used y your service. Note that you might need to update many IP pools if your LB will work with services across multiple subnets.
Edit the properties of the IP pool and reserve some of the IPs for your LB to use as VIPs. Note that the reserved IPs must be a part of the range defined in the pool. Here I have defined several IPs for use as VIPs. They will be checked out (used) and checked in (recycled) as I deploy and remove services that use the load balancer.
Fabric > Load Balancer
Into the Fabric to define a new load balancer. Note that you must restart the VMM service on your VMM server to make use of the provider you installed earlier.
Once that’s done, right-click Load Balancers and hit Add Load Balancer. Select the Run As Account you just created. Pick the Host Group(s) that you will permit to use this LB. Select the manufacturer and model from the drop down box (populated by the provider). Enter the IP address and port for managing the LB.
Under Logical Network Affinity you enter the VMM logical networks that will be used for:
- Client comms (front end)
- Server comms (back end)
My network is rather simple because it’s a lab. I’m using a single logical network for testing and demos so I check both boxes for it in this setting.
In Provider you can test the new load balancer:
Now you have a load balancer. It’s time to start to define how VMM managed services will make use of it.
Fabric > VIP Template
The VIP Template will be used by a Service Template to define how the load balancing will be done. You’ll be asked for a number of bits of information, such as:
- A label (make this something useful that describes the function and planned usage of the template)
- A template type: specify the load balancer that you’ve added to VMM
- Specify the protocol that will be load balanced (HTTP, HTTPS Passthrough, HTTPS Terminate, Custom)
- Client connection persistence to the application server (on or off)
- Load balancing method (least connections, round robin, fast response time, custom)
- Add custom health monitors (optional)
Now you have all of the required load balancer ingredients.
Update The Cloud
Your cloud that will host the new VMs (the service) must be permitted to use the LB and the VIP Template. Open the properties and check the box for the LB, and then the box(es) for the VIP Template(s) that you will be deploying.
You will need a VM template. Confirm three things:
- You capability profile matches the cloud in question
- You have configured the template to connect to the server logical network you defined in the LB object (Logical Network Affinity) in Fabric.
- The virtual NIC that will be load balanced has a static IP/MAC configuration
You’ll have all sorts of “fun” in the Service Template and deployment if you don’t confirm that stuff.
I’m using IIS 8.0 for my testing so my VM template also enables IIS, the management console, and the default document. This allows me to re-use a single VHDX and get multiple server types from it.
Time to start designing.
In reality you’d be working with Web Deploy 3.0 and creating Web Deploy packages. You’d use this Web Deploy package to automatically install your web app to the new servers as you scale out the web server tier in your Service Template. I’m doing lab stuff here and I’m sticking to the default web site. Anywho, there’s enough in this post to keep you busy for now
In Library > Templates > Service Templates, create a new Service Template. I’m choosing the Single Machine one (“single machine” refers to a single tier which might be made up of lots of identical servers) for my demo. Maybe you need a two or three tier service template?
Click the application at the top, rename it to describe the template and give it a meaningful version number. You can create new versions to update your deployed apps based on this mechanism.
I drag my VM template onto the machine in the service template. A warning with alerts appears – save and validate (in the Ribbon) the configuration and that’ll sort itself out if your VM template is OK. Select the VM. In the bottom you can configure scalability for this server, thus turning it into a tier of 1 or more servers. I’ve set my example to start out by deploying 2 VMs from this template. It will allow the tier to scale out to 10 VMs (inheriting all of the Service Template configurations), and shrink down to a minimum of 1 VM.
Now I click Add Load Balancer in the Ribbon. The VIP profile, a Client Connection, and a Server Connection appear. My demo example is simple with everything on a single Logical Network. I need to connect the LB connections to the logical network. Do that by creating Connectors (the Ribbon) and dragging to connect:
- The Client Connection to the logical network
- The Server Connection to the relevant NIC in the application server
Hit Save And Validate once again. Now any machines in this tier will be automatically be configured to use the LB. This tier will use a single VIP for client connections. OK time to play!
Deploy The Web Servers
You can hit Configure Deployment in the Ribbon of the Service Template Designer to test it out. Give the service instance that you are creating a name, and select the cloud it will be deployed to. There may be some warnings. Click Refresh Preview in the Ribbon. Everything is checked against the targeted cloud. If all is well, the errors will disappear.
If you got the LB config wrong then it won’t appear. You can see mine in the bottom right in the above screenshot and how it’s connected to a logical network (named after my hand-built converged fabric on the WS2012 Hyper-V hosts).
When you’re ready to commit, click Deploy Service.
A new job starts. Here’s what’s happening:
- 2 new VMs (based on my scalability config for this tier in the service template) are being deployed in parallel
- Configure the roles/services to customize the VM
- It would drop on a web app if I’d attached a Web Deploy package to the tier in the Service Template
- VMM will use the LB and Run As account to configure load balancing for both of these servers using the VIP Template
All I have to do is sit back and be patient *tick* *tick* *tick*
Tip: Your VM deployments will timeout if you forget to complete the OS configuration, e.g. a valid product key. I strongly suggest that you test your VM Template deployment before including them in a Service Template. Monitor the running VM during deployment from a Hyper-V Connect window to look for deployment, config, or timeout issues.
The Deployed Load Balanced Service
Once the template is deployed you can poke around. The service appears in VMs And Services in the Services (Ribbon) view:
In the NetScaler console, I can see a Virtual Server was created with one of my VIPs:
My two VMs are identified as servers in the NetScaler:
And all that appears to be tied together in a Service Group by the NetScaler (this Service Group is selected in the Virtual Server):
All I did was fire up the NetScaler, give it an IP config, license it, and enable load balancing. VMM did all the rest using the Service Template via the LB provider. Nice!
You can test by doing the following:
- Set up different web pages on the web servers
- Browse to the VIP of the Virtual Server (192.168.1.161 in my example)
- If you selected round robin as the load balancing method of the VIP Template then the web pages should alternate.
- Try powering down a VM and the web app should stay operational.
And the nice stuff continues:
- Right-click on the service tier in VMM. You can Scale Out the tier. VMM will deploy a VM according to the Service Template. The LB will be reconfigured to include the new VM in the NetScaler Service Group.
- You can manually delete VMs and VMM will tidy up the LB.
- You can remove the service entirely and VMM will tidy up the LB and recycle the VIP.
When you’re done, you can optionally delegate access to this Service Template for your cloud tenants by editing the tenant properties:
And that’s Service Templates and Load Balancers. There’s a bit of work to get it up and running, but once you have, you can see just how easy it is to deploy new applications. And keep in mind that I’ve only scratched the surface of Service Templates!
Credit: Thanks to Hans Vredevoort MVP for some help on the Citrix end of things.