instance image

Creating instances on different compute nodes

Before you start

This tutorial assumes you've got the CLI tools running. If you don't, please visit the Openstack command-line interface (CLI) installation commands tutorial.

When building a cluster of instances on Fuga, you want to ensure that these instances are created on separate compute nodes in order to ensure the highest availability. When creating the instances via the Fuga dashboard, you have no way to control on which compute node your instance will be created and cluster nodes can be created on the same compute node. When creating instances via the OpenStack commandline tools, you can supply hints to the Nova Scheduler to ensure the instances are created on separate compute hosts. The Nova Scheduler is the process in OpenStack that determines on which compute node an instance will be created. The Nova Scheduler uses filters to see which of the compute nodes can be used to create the instance. The Nova Scheduler assigns a weight to each of the available compute nodes and the node with the highest weight will receive the instance. The Nova Scheduler has filters for disk space, memory, available CPUs etc. Some of these filters accept hints that can be supplied by the users when creating an instance. The filters ServerGroupAffinityFilter and ServerGroupAntiAffinityFilter can be used to make sure instances run on the same or on different compute nodes.

To accomplish this, we will create a server group with the anti-affinity set. When creating a new instance in this server group the Nova Scheduler will give a higher priority to compute nodes with no other instances in this server group. When this rule can't be met, it will choose the compute node with the least amount of instances in this server group. First, we will create a new server group with the anti affinity policy.

nova server-group-create --policy anti-affinity server-group-1
| Id                                   | Name           | Policies           | Members | Metadata |
| 27a5df2e-6494-44af-8dbb-8a1d56536c09 | server-group-1 | [u'anti-affinity'] | []      | {}       |

Now we can create instances in this server group. Hints can only be supplied when creating the instance via the API or CLI.

nova boot --image 46bc5367-d0c5-408f-acf0-ca6d1fd505fc --flavor c1.micro --nic net-id=50f8c57e-ecfe-4792-82f8-acf5196d15fa --hint group=27a5df2e-6494-44af-8dbb-8a1d56536c09 instance-1
| Property                             | Value                                                                                              |
| OS-DCF:diskConfig                    | MANUAL                                                                                             |
| OS-EXT-AZ:availability_zone          | ams                                                                                                |
| OS-EXT-STS:power_state               | 0                                                                                                  |
| OS-EXT-STS:task_state                | scheduling                                                                                         |
| OS-EXT-STS:vm_state                  | building                                                                                           |
| OS-SRV-USG:launched_at               | -                                                                                                  |
| OS-SRV-USG:terminated_at             | -                                                                                                  |
| accessIPv4                           |                                                                                                    |
| accessIPv6                           |                                                                                                    |
| adminPass                            | ########                                                                                           |
| config_drive                         |                                                                                                    |
| created                              | 2015-11-16T15:58:42Z                                                                               |
| flavor                               | c1.micro (1dae391a-d48f-4bf5-9a55-3b73d1585f55)                                                    |
| hostId                               |                                                                                                    |
| id                                   | 0d03eb3b-153b-4a93-978b-c897f5fbddad                                                               |
| image                                | CirrOS 0.3.3 - Minimalist - 64-bit - Fuga Cloud Based Image (46bc5367-d0c5-408f-acf0-ca6d1fd505fc) |
| key_name                             | -                                                                                                  |
| metadata                             | {}                                                                                                 |
| name                                 | instance-1                                                                                         |
| os-extended-volumes:volumes_attached | []                                                                                                 |
| progress                             | 0                                                                                                  |
| security_groups                      | default                                                                                            |
| status                               | BUILD                                                                                              |
| tenant_id                            | 3739912e772d47ffbe8948e112a7ebb8                                                                   |
| updated                              | 2015-11-16T15:58:42Z                                                                               |
| user_id                              | 6636cdc36d70452dab268bf8d09c6343                                                                   |

The members in a server group can be listed with nova server-group-get:

nova server-group-get 27a5df2e-6494-44af-8dbb-8a1d56536c09
| Id                                   | Name           | Policies           | Members                                                                            | Metadata |
| 27a5df2e-6494-44af-8dbb-8a1d56536c09 | server-group-1 | [u'anti-affinity'] | [u'9ebe9238-13b2-4845-b9ab-39f1a3911f56', u'0d03eb3b-153b-4a93-978b-c897f5fbddad'] | {}       |

Assigning an instance to a server group can only be done when creating an instance. Existing instances cannot be assigned to a server group.

Was this article helpful?

Next article:

Download OpenRC file

Prerequisites: For this tutorial you'll need to have an active Fuga account. Downloading your Fuga file: On the website, go to the dashboard & login Next, go to Access & Security and then API Access: Finally, click the "Download OpenStack RC File v3 button (Second to last button) Save the file to an easily accessible place from your shell. For example, ~/fuga.