VMware ESXi and vSphere Cluster Management
Create a VM-to-Host DRS Rule in VMware vSphere
Learn how to create VM and host DRS groups, configure VM-to-host affinity rules, validate placement, and troubleshoot VMware vSphere DRS rules.
A VM-to-host Distributed Resource Scheduler (DRS) rule controls where selected virtual machines may run inside a vSphere DRS cluster. You can require virtual machines to run on designated ESXi hosts, prefer those hosts, or prevent the virtual machines from using a selected host group.
This article assumes familiarity with vSphere inventory objects, cluster membership, DRS automation modes, vMotion, and vSphere Client navigation. For background, review vSphere admission control, vSphere permissions, and VMware ESXi administration.
What a VM-to-host DRS rule does
Distributed Resource Scheduler (DRS) is a vSphere cluster capability that balances workloads by recommending or performing virtual machine migrations. A VM-to-host rule adds a placement relationship to that scheduling process.
The rule applies at the cluster level and requires DRS to be available and configured for the cluster. It connects a named group of virtual machines with a named group of ESXi hosts.
- Required placement: Covered virtual machines must run on members of the selected host group.
- Preferred placement: DRS attempts to keep covered virtual machines on members of the selected host group, but the preference is not an absolute requirement.
- Required exclusion: Covered virtual machines must not run on members of the selected host group.
- Preferred exclusion: DRS attempts to keep covered virtual machines away from members of the selected host group.
When a VM is outside its allowed placement, DRS evaluates the rule and may recommend or perform a vMotion migration, depending on the cluster's automation mode and whether the migration is feasible.
DRS groups required by the rule
VM-to-host rules use two DRS group types:
- VM DRS group: A named collection of one or more virtual machines.
- Host DRS group: A named collection of one or more ESXi hosts.
Groups simplify administration. Instead of creating and maintaining a separate relationship for every VM and host, you maintain membership in two groups and apply one rule between them. If a new VM belongs to the same workload tier, add it to the VM group. If an approved ESXi host is added, add it to the host group.
Placement behavior: mandatory versus preferred
Before you begin
- Select the correct vSphere cluster rather than an individual host or virtual machine.
- Confirm that DRS is enabled and that your account has permission to configure cluster DRS settings.
- Identify the virtual machines that need controlled placement.
- Identify eligible ESXi hosts and verify their capacity and compatibility.
- Consider how vSphere HA will recover the VMs if an allowed host fails.
A strict rule that allows a VM to run on only one host can conflict with availability goals. Before using one, determine whether another compliant host is available for maintenance and host-failure recovery.
Create a VM DRS group
- Select the target DRS cluster in the vSphere inventory.
- Open Manage > Settings > DRS Groups. In some vSphere Client versions, the labels or nesting may differ slightly.
- Select Add to create a group.
- Enter a meaningful group name, such as
Linux-App-VMs. - Choose the VM DRS Group type.
- Add the virtual machines that the rule will control.
- Review the membership and save the group.
Cluster > Manage > Settings > DRS Groups
Add > VM DRS Group
Name: Linux-App-VMs
Members: app-vm-01, app-vm-02
Use names that describe purpose rather than a temporary host location. Clear names make later rule review and troubleshooting easier.
Create a Host DRS group
- Remain in the same cluster's DRS Groups area.
- Select Add again.
- Enter a meaningful name, such as
Approved-App-Hosts. - Choose the Host DRS Group type.
- Add one or more eligible ESXi hosts.
- Confirm the host membership and save the group.
Cluster > Manage > Settings > DRS Groups
Add > Host DRS Group
Name: Approved-App-Hosts
Members: esxi-01, esxi-02
Do not add a host merely because it is in the cluster. Check that it has the required compute capacity, datastores, port groups, processor compatibility, and vMotion connectivity.
Create the VM-to-host DRS rule
- Open the target cluster's Manage > Settings > DRS Rules area.
- Select Add to create a rule.
- Enter a meaningful name, such as
Linux-App-VMs-on-Approved-App-Hosts. - Choose the Virtual Machines to Hosts rule type.
- Select the previously created VM DRS group.
- Select the previously created Host DRS group.
- Choose the placement behavior. For a strict requirement, select Must run on hosts in group.
- Save the rule and verify that it is enabled.
Cluster > Manage > Settings > DRS Rules
Add
Name: Linux-App-VMs-on-Approved-App-Hosts
Rule type: Virtual Machines to Hosts
VM group: Linux-App-VMs
Host group: Approved-App-Hosts
Behavior: Must run on hosts in group
Enabled: Yes
For an exclusion rule, use the same VM and host group concepts but select the applicable “must not run” or “should not run” behavior. This is useful when sensitive VMs must avoid a selected set of hosts.
Example: constrain a Linux application VM
Suppose linux-app-01 requires hosts with a particular network connection. Create a VM DRS group containing that VM and a Host DRS group containing esxi-01 and esxi-02. Then create a Virtual Machines to Hosts rule with Must run on hosts in group.
If the VM is running on esxi-03, DRS identifies a migration toward esxi-01 or esxi-02 when the destination is eligible. With automatic DRS automation, DRS may carry out the vMotion. With manual automation, an administrator reviews and applies the recommendation.
Validate the rule
- Open Cluster > Monitor > vSphere DRS.
- Review DRS recommendations and recent actions.
- Check whether a VM outside its required host group has a migration recommendation.
- Confirm that the recommended destination is a member of the designated host group.
- After the action completes, verify the VM's current host and confirm that it is compliant with the rule.
For a manual DRS mode, a recommendation can remain visible until an administrator applies it. For an automated mode, check recent tasks and events to confirm whether DRS performed the migration.
Validation path:
Cluster > Monitor > vSphere DRS
Operational considerations
- Capacity: Ensure the designated host group can accommodate all covered VMs during normal operation, maintenance, and a host failure.
- HA recovery: A strict rule can limit the hosts available for vSphere HA restart. Check admission control and failure-planning assumptions; see vSphere HA admission control policy.
- Maintenance mode: Review rules before evacuating a host. If all allowed hosts are being placed in maintenance mode, VMs may be unable to migrate without violating the rule.
- Membership changes: Update VM DRS groups when VMs are added, removed, retired, or repurposed.
- Host lifecycle: Update Host DRS groups when hosts are replaced, decommissioned, or temporarily unavailable.
- Migration prerequisites: A rule does not override vMotion requirements. The destination still needs compatible processors, reachable networks, accessible storage, and a suitable host state.
- Rule scope: Rules are evaluated within their cluster. A VM cannot satisfy a host-group rule by moving to a host in another cluster.
Troubleshooting
DRS groups or rules are unavailable
Likely causes: The selected object is not a cluster, DRS is not enabled or available, or the account lacks cluster configuration permissions.
- Confirm that the selected inventory object is the intended cluster.
- Verify the cluster's DRS configuration and automation settings.
- Use an account with sufficient vSphere privileges, or contact the administrator responsible for cluster configuration.
A VM cannot migrate to satisfy a strict rule
Likely causes: No host in the group has enough CPU or memory, vMotion compatibility is not satisfied, storage or networking is unavailable, or too few hosts are in the group.
- Check host capacity and the VM's resource requirements.
- Verify vMotion networking, datastore access, processor compatibility, and host connectivity.
- Check whether hosts are connected, online, and eligible for migration.
- Add suitable hosts to the group or revise the rule design only when the availability and security policy permits it.
The VM remains outside the intended host group
Likely causes: The VM or host is missing from its DRS group, the rule is disabled, the rule uses a preferred rather than mandatory behavior, DRS is in manual mode, or migration is blocked.
- Review VM DRS group and Host DRS group membership.
- Confirm that the rule is enabled and uses the intended placement option.
- Review and apply the recommendation when DRS is configured for manual automation.
- Investigate migration blockers in tasks, events, host state, networking, storage, and compatibility checks.
Maintenance mode causes placement conflicts
Likely causes: The rule allows the affected VMs to run only on hosts being evacuated, or the remaining allowed hosts cannot accommodate them.
- Plan host maintenance around the rule's constraints.
- Confirm that alternate compliant hosts have adequate capacity before entering maintenance mode.
- Temporarily adjust group membership or rule settings only when operational policy permits and the resulting placement is understood.
Summary
To create a VM-to-host DRS rule, create a VM DRS group, create a Host DRS group, and link them with a Virtual Machines to Hosts rule. Choose a mandatory behavior when placement must be enforced, or a preferred behavior when flexibility and availability are more important. Finally, use the vSphere DRS monitoring view to verify recommendations, migration actions, and final VM placement.