Creating VMs to host affinity rules
In this recipe, the objective is to restrict the VMs to run on specific groups of hosts.
Getting ready
A prerequisite to setting an affinity is creating the DRS groups for the respective VMs and hosts.
How to do it...
- Select a cluster, and navigate to
Configure
|VM/Host Rules
. Provide a name for the rule and ensure it's enabled. - Choose the affinity
Type
—Virtual Machines to Hosts.
Choose aVM group
from the available groups.
- Choose the rule from the drop-down menu—
Should run on hosts in group
. Choose theHost Group
where the VMs ought to have the affinity, the setting should reflect the following screenshot:

How it works...
The following rules are available for the VM-host affinity rules:
Must run on hosts in a group
Must not run on hosts in a group
Should run on hosts in a group
Should not run on hosts in a group
The key difference is that for a must rule, it is mandatory to adhere to it, immaterial of the availability situation in the cluster. For instance, if...