Now that we have a running OpenStack Compute environment and a machine image to use, it’s now time to spin up our first cloud instance! Let’s see how we can use the information from the nova image-list
and nova flavor-list
commands to reference this on the command line to launch the instance that we want.
The following steps are to be carried out on our network
node under the user that has access to our OpenStack Compute credentials (as created in the Installation of command-line tools on network recipe).
Ensure you are logged in to the network
node and that it has Internet access to allow us to install the required packages in our environment for running OVS and Neutron. If you created this node with Vagrant, you can execute the following command:
vagrant ssh network
Before we spin up our first instance, we must create the default security settings that define the access rights. We do this only once (or when we need to adjust these) using the nova secgroup-add-rule
command under Nova client. The following set of commands gives us SSH access (port 22
) from any IP address and also allows us to ping the instance to help with troubleshooting. Note the default group and its rules are always applied if no security group is mentioned on the command line.
The steps are as follows:
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 secgroup-add-rule default tcp 22 22 0.0.0.0/0 nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
If there are no images available yet, follow the steps of the recipe Managing images with OpenStack Image Service in Chapter 2, Glance – OpenStack Image Service.
Now that our environment is set up correctly, we carry out the following steps to launch our first instance:
nova image-list
This should produce an output like this:
nova flavor-list
Available flavors for our OpenStack installation will be listed like this:
We can specify flavor either by its ID or name.
neutron net-list
The available networks will be displayed like this:
trusty-image
and cookbook_network_1
:nova boot myInstance --image 5bfb4a6d-da77-4502-ba52-2e8e40597e96 --flavor 2 --nic net-id=0375e772-b021-425c-bc17-5a3263247fb8 --key_name demokey
You should see output like the following screenshot when you launch an instance:
nova list nova show 5971ab77-9d91-40d8-9961-d86da0945f26
network
node, you will be able to connect to the instance using network space and SSH private key. First, get a list of network spaces using the following command:ip netns
This will show the following example output:
qdhcp-0375e772-b021-425c-bc17-5a3263247fb8
Now, connect to the instance using the following command:
sudo ip netns exec qdhcp-0375e772-b021-425c-bc17-5a3263247fb8 ssh -i demokey [email protected]
Congratulations! We have successfully launched and connected to our first OpenStack cloud instance.
After creating the default security settings, we made a note of our machine image identifier, UUID value, and then called a tool from Nova client to launch our instance. Part of that command line refers to the key pair to use. We then connect to the instance using the private key as part of that key pair generated.
How does the cloud instance know what key to use? As part of the boot scripts for this image, it makes a call back to the meta-server
, which is a function of the nova-api
and nova-api-metadata
services. The meta-server
provides a go-between that bridges our instance and the real world that the Cloud init
boot process can call. In this case, it downloads a script to inject our private key into the Ubuntu user’s .ssh/authorized_keys
file. We can modify which scripts are called during this boot process, and this will be covered later on.
When a cloud instance is launched, it generates a number of useful metrics and details about that instance. This is presented by the nova list
and nova show
commands. The nova list
command shows a convenient short version listing the ID, name, status, and IP addresses of our instance.
The type of instance we chose was specified as an ID of 2
when using the nova boot
command. The instance types supported can be listed by running the following command:
nova flavor-list
These flavors (specification of instances) are summarized as follows:
Type of instance |
Memory |
VCPUS |
Storage |
Version |
---|---|---|---|---|
|
512 MB |
1 |
1 GB |
32-bit and 64-bit |
|
2048 MB |
1 |
20 GB |
32-bit and 64-bit |
|
4096 MB |
2 |
40 GB |
64-bit only |
|
8192 MB |
4 |
80 GB |
64-bit only |
|
16384 MB |
8 |
160 GB |
64-bit only |