The most fundamental tasks that can be performed with instances are life cycle tasks. In this recipe, we will show you how to start or boot an instance.
To start an instance, you will need the following:
openstack
command-line clientopenrc
file containing appropriate credentialsThe instance we will boot will have the following attributes:
cookbook.test
openstack.cookbook
Ubuntu 16.04 amd64
(UUID)public
(UUID)cookbook_key
ssh
To start an instance, use the following steps:
openstack server list
openstack image list
This will bring back a list of images available:
openstack network list
This will list the networks that we can attach an instance to:
ssh-keygen -q -N ""
Also, upload this with the following command:
openstack keypair create --public-key ~/.ssh/id_rsa.pub cookbook_key
This will bring back an output showing the fingerprint of your key:
openstack server create --flavor openstack.cookbook --image 08b822ba-be44-4639-b577-45e8dd37c06d --nic net-id=6cb5a4ce-1ea5-4817-9c34-a2212a66f394 --security-group ssh --key-name cookbook_key cookbook.test
This produces a table of output showing that the instance is booting (not shown here for brevity).
openstack server show cookbook.test
This gives an output like the following:
After noting a number of required values we will be supplying as input, such as the UUID of the image that we want to boot and the UUID of the network we want to attach the instance to, we then called a tool from OpenStack Client to launch our instance. Part of that command line refers to the keypair to use. We then connect to the instance using the private key as part of that keypair 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 metaserver, which is a function of the nova-api
and nova-api-metadata
services. The metaserver provides a go-between that bridges our instance and the real world, which the cloud-init boot process can call and in this case, it downloads a script to inject our private key into the Ubuntu user's .ssh/authorized_keys
file.
When a cloud instance is launched, it generates a number of useful metrics and details about that instance. This is presented by the openstack server list
and openstack server show
commands. The openstack server list
command shows a convenient short version listing the ID, name, status, and IP addresses of our instance.
3.149.243.18