I was recently looking for a step-by-step guide for creating vSphere DRS rules and groups for a customer implementing a vSphere Storage Metro Cluster with EMC VPLEX and had trouble finding a comprehensive article, so I decided to write one. Without further ado:
- Creating virtual machine DRS Groups
- Creating host DRS Groups
Creating Run VMs on Hosts Rules
- Must versus should
- Creating Separate Virtual Machines/Keep Virtual Machines Together Rules
Creating virtual machine DRS Groups
To create a virtual machine DRS Group:
1. Right-click the DRS cluster in question, then click Edit Settings.
Alternatively, select the DRS cluster in the Hosts and Clusters inventory view, then click Edit Settings.
2. Click DRS Groups Manager under vSphere DRS.
3. Here, you’ll see any existing DRS Groups. Click Add under Virtual Machines DRS Groups to add a new virtual machine DRS Group.
4. Select the virtual machines you wish to place in a DRS Group, click the right arrow to add them to the DRS Group, give it a meaningful name, then click OK.
You’ve now created your virtual machine DRS Group.
Creating host DRS Groups
Still in the DRS Groups Manager, to create a host DRS Group:
1. Click Add under Host DRS Groups.
2. Select the hosts you wish to place in a DRS Group, click the right arrow to add them to the DRS Group, give it a meaningful name, then click OK.
You’ve now created a host DRS Group.
Creating Run VMs on Hosts Rules
To create a Run VMs on Hosts rule, you must have added the virtual machines in question to a Virtual Machines DRS Group, as well as added the specified ESXi hosts to a Hosts DRS Group. Please refer to the previous sections for guidance on those two tasks.
1. Click Rules just below the DRS Groups Manager in the Cluster Settings window.
2. Click Add to create a new DRS Rule.
3. In the Type drop-down menu, choose Virtual Machines to Hosts.
4. Choose the appropriate Cluster VM Group, Cluster Host Group, DRS Policy (covered more later), and finally, give it a descriptive name. Click OK when finished.
You’re now finished creating the Run VMs on Hosts DRS Rule. You should see it in your Rules inventory, as below.
Must versus should
When creating a Run VMs on Hosts rule, you’ll be presented with the following options:
- Must run on hosts in group
- Should run on hosts in group
- Must not run on hosts in group
- Should not run on hosts in group
Now, the difference between these rules may seem obvious, but there is a bit of subtlety at play here. The main thing to be cognizant of is that HA will respect Must run or Must not run rules when performing HA restarts after a host failure. For further reading on the topic, see the excellent articles below from Frank Denneman:
Creating Separate Virtual Machines/Keep Virtual Machines Together Rules
Traditionally known as VM affinity/anti-affinity, these rules will do as described, either keep virtual machines together on the same host or keep them separated on different hosts.
1. In vSphere DRS Rules, click Add.
2. In the Type drop-down menu, choose either Keep virtual machines together or Separate virtual machines, depending on your intent.
3. Click Add to add virtual machines to the rule.
4. Select the virtual machines you wish to keep together or separate, then click OK.
5. Give the rule a descriptive name, assure the correct virtual machines are in the list, then click OK.
6. You should now see the new rule in your Rules list. Click OK to finish.