How to do it…

The following process can be used to create Virtual Machine to Hosts affinity or anti-affinity rules:

  1. From the cluster's Settings page, access the VM/Host Groups section to manage virtual machine and host groups, as shown in the following screenshot:

Managing VM / Host groups
  1. Select Add to create a new host group and select the hosts to add to the group, as shown in the following screenshot:

Adding a new host group
  1. Select Add to create a new VM group, and select the virtual machines to add to the group, as shown in the following screenshot:

Adding a new VM group
  1. From the DRS Rules menu, create a VM/Host Rule by providing a rule Name, setting the Type to Virtual Machines to Hosts, selecting the VM Group and Host Group to include in the rule, and selecting the required or preferential affinity/anti-affinity rules, as shown in the following screenshot:

Creating a VM / Host rule
  1. Click on OK to create the Virtual Machines to Hosts rule.