OpenStack segregation with availability zones and host aggregates
When a new OpenStack cloud born, usually all servers run over the same hardware and specifications, often, all servers are in the same building, room, rack, even a chassis when the cloud is in the first growth paces.
After a while, workloads increase and the current hardware is not enough to process that workloads. At this point, your hardware is old and new hardware is bought. This hardware has different storage disks, CPU, RAM and so on. You passed from 10\'s of servers to 100\'s. DataCenter racks, rooms and buildings are too small and the growing cloud needs redundancy between cities or countries.
OpenStack offers a few solutions for that purpose, called Regions, Cells, Availability Zones and Host Aggregates. | Now, we are going to focus on Availability Zones and Host Aggregates, which are the way to segregate computational workloads.
Host Aggregates:
Host Aggregates represent a logical set of
properties/characteristics a group of hosts owns in the form of
metadata. Imagine some of your servers have SSD disks and the
other ones SATA, you can map those properties SSD/SATA to a
group of hosts, when a image or flavor with the metaparameter
associated is launched, Nova Scheduler will filter the available
hosts with the meta parameter value and boot the instance on
hosts with the desired property. Host Aggregates are managed by
OpenStack admins.
Availability Zones
Availability Zones represent a logical partition of the
infrastructure(not necessary but is the common use case) in the
form of racks, rooms, buildings, etc. Customers can launch
instances in the desired Availability Zone.
Usually, Host Aggregates are mapped to Availability Zones allowing customers to use the desired set of hardware or characteristics to boot instances.
At the end of this guide you will know how to:
Create Availability Zones and Host Aggregates.
Adding hosts to Host Aggregates and Availability Zones.
Launch instances directly to Availability Zones.
Configure nova scheduler for Host Aggregates usage.
Configure Images and Flavors for scheduling to Host Aggregates.
Launch instances based on flavors and image parameters.
Let's start: \00/
| Create two Host Aggregate called "az1-ag"/"az2-ag", this command also, will create two Availability Zones called "az1"/"az2". | By default, when a Host Aggregate is created with an Availability Zone, a metadata key called "availability_zone=NAME_OF_AZ" will be created.
# nova aggregate-create az1-ag az1
+----+--------+-------------------+-------+-------------------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+-------+-------------------------+
| 2 | az1-ag | az1 | | 'availability_zone=az1' |
+----+--------+-------------------+-------+-------------------------+
# nova aggregate-create az2-ag az2
+----+--------+-------------------+-------+-------------------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+-------+-------------------------+
| 3 | az2-ag | az2 | | 'availability_zone=az2' |
+----+--------+-------------------+-------+-------------------------+
Add one or more compute nodes to Host Aggregates.
# nova aggregate-add-host 2 compute1az
Host compute1az has been successfully added for aggregate 2
+----+--------+-------------------+--------------+-------------------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+--------------+-------------------------+
| 2 | az1-ag | az1 | 'compute1az' | 'availability_zone=az1' |
+----+--------+-------------------+--------------+-------------------------+
# nova aggregate-add-host 3 compute2az
Host compute2az has been successfully added for aggregate 3
+----+--------+-------------------+--------------+-------------------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+--------------+-------------------------+
| 3 | az2-ag | az2 | 'compute2az' | 'availability_zone=az2' |
+----+--------+-------------------+--------------+-------------------------+
Details about a Host Aggregate can be reviewed with:
# nova aggregate-details az1-ag
+----+--------+-------------------+--------------+-------------------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+--------------+-------------------------+
| 2 | az1-ag | az1 | 'compute1az' | 'availability_zone=az1' |
+----+--------+-------------------+--------------+-------------------------+
# nova aggregate-details az2-ag
+----+--------+-------------------+--------------+-------------------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+--------------+-------------------------+
| 3 | az2-ag | az2 | 'compute2az' | 'availability_zone=az2' |
+----+--------+-------------------+--------------+-------------------------+
Launch two instances using "--availability-zone AZ" option, you can even select the compute node to use, just use "--availability-zone AZ:COMPUTE_NODE".
Update the images with custom properties, i use "availability_zone" because is the default meta parameter a Host Aggregate owns when is inside Availability Zones.
Boot two instances, now we use images with custom properties, those properties will map to Availability Zones(you can use other type of parameters mapping to Host Aggregates characteristics).
# nova boot --flavor m1.tiny --image imageaz1 --nic net-id=6d62149e-74d3-4e52-9813-53ad207309f4 instanceimageaz1
# nova boot --flavor m1.tiny --image imageaz2 --nic net-id=6d62149e-74d3-4e52-9813-53ad207309f4 instanceimageaz2
Ensure the instances booted in the desired Availability Zone.
# nova show instanceimageaz1 | grep OS-EXT-AZ | awk '{print$2":"$4}'
OS-EXT-AZ:availability_zone:az1
# nova show instanceimageaz2 | grep OS-EXT-AZ | awk '{print$2":"$4}'
OS-EXT-AZ:availability_zone:az2
| Other method to launch instances is with parameters in flavors. | Create two flavors.