Availability zones are logical separations of compute resources, representing groups of hypervisors that a user will be able to select when requesting to launch an instance. If no availability zones have been created, the default called nova will be used. When an instance is launched in most default cases, the scheduler determines which host will run it within that zone. As a user of the OpenStack cloud, you can specify which availability zone to use if more than one is available. This can help you create more resilient applications. By allowing an instance to be spun up in two separate places, we are protecting ourselves against the failure of a complete zone.
Ensure you are logged onto an Ubuntu host that has access to our OpenStack environment on the 192.168.100.0/24 public network. This host will be used to run client tools against the OpenStack environment created. If you are using the accompanying Vagrant environment, as described in the Preface, you can use the controller
node. This node has the python-novaclient
package that provides the nova
command-line client.
If you created this node with Vagrant, you can execute the following command:
vagrant ssh controller
Ensure you have set the following credentials (adjust the path to your certificates and key file to match your environment if not using the Vagrant environment):
export OS_TENANT_NAME=cookbook export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/ export OS_NO_CACHE=1 export OS_KEY=/vagrant/cakey.pem export OS_CACERT=/vagrant/ca.pem
nova boot --flavor $FLAVOR --image $IMAGE --availability-zone $AZ $INSTANCE_NAME
$AZ
comes from nova hypervisor-list
. We use the complete name listed as shown:To launch an instance called myInstance
onto compute-02
, issue the following command:
nova hypervisor-list
This will give you the following output:
+----+----------------------+ | ID | Hypervisor hostname | +----+----------------------+ | 1 | compute-01.cook.book | | 2 | compute-02.cook.book | +----+----------------------+
compute-02
using the following commands:nova boot --flavor 1 --image trusty-image --availability-zone nova:compute-02.cook.book MyInstance
To launch an instance into a specific availability zone, we use the following flag to our nova boot command line:-
-availability-zone $NAME_OF_ZONE
The name of the zone comes from the following command:
nova availability-zone-list
This command lists the Zones available in our environment.