6.11. Affinity Groups


Virtual machine affinity allows you to define sets of rules that specify whether certain virtual machines run together on the same host or hosts in a group, or run separately on different hosts. This allows you to create advanced workload scenarios for addressing challenges such as strict licensing requirements, workloads demanding high availability, and failover and failback for disaster recovery.
Virtual machine affinity is applied to virtual machines by adding virtual machines to one or more affinity groups. An affinity group is a group of two or more virtual machines for which a set of identical parameters and conditions apply. These parameters include positive (run together) affinity that ensures the virtual machines in an affinity group run on the same host or hosts in a group, and negative (run independently) affinity that ensures the virtual machines in an affinity group run on different hosts.

Important

Affinity groups will only take effect when the VmAffinityGroups or VmToHostsAffinityGroups filter module or weights module is enabled in the scheduling policy applied to clusters in which affinity groups are defined. The two modules are complementary and can be used together. For more information about scheduling policies see Scheduling Policies in the Administration Guide.
A further set of conditions can then be applied to these parameters in the associated scheduling policy.
  • Hard enforcement - ensures that virtual machines in the affinity group run on a specified host or hosts in a group regardless of external conditions. The filter modules in the scheduling policy implement hard enforcement.
  • Soft enforcement - indicates a preference for virtual machines in an affinity group to run on the specified host or hosts in a group when possible. The the weights modules in the scheduling policy implement soft enforcement.
The combination of an affinity group, its parameters, and its conditions is known as an affinity policy. Affinity policies are applied to running virtual machines immediately, without having to restart.

Note

Affinity groups are applied to virtual machines on the cluster level. When a virtual machine is moved from one cluster to another, that virtual machine is removed from all affinity groups in the source cluster.

6.11.1. Creating an Affinity Group

You can create new affinity groups in the Administration Portal.

Procedure 6.18. Creating Affinity Groups

  1. Click the Virtual Machines tab and select a virtual machine.
  2. Click the Affinity Groups tab in the details pane.
  3. Click New.
  4. Enter a Name and Description for the affinity group.
  5. From the VM Affinity Rule drop-down, select Positive to apply positive affinity or Negative to apply negative affinity. Select Disable to disable the affinity rule.
  6. Select the Enforcing check box to apply hard enforcement, or ensure this check box is cleared to apply soft enforcement.
  7. Use the drop-down list to select the virtual machines to be added to the affinity group. Use the + and - buttons to add or remove additional virtual machines.
  8. Click OK.

6.11.2. Editing an Affinity Group

Procedure 6.19. Editing Affinity Groups

  1. Click the Virtual Machines tab and select a virtual machine.
  2. Click the Affinity Groups tab in the details pane.
  3. Click Edit.
  4. Change the VM Affinity Rule drop-down and Enforcing check box to the preferred values and use the + and - buttons to add or remove virtual machines to or from the affinity group.
  5. Click OK.

6.11.3. Removing an Affinity Group

Procedure 6.20. Removing Affinity Groups

  1. Click the Virtual Machines tab and select a virtual machine.
  2. Click the Affinity Groups tab in the details pane.
  3. Click Remove.
  4. Click OK.
The affinity policy that applied to the virtual machines that were members of that affinity group no longer applies.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.