0% found this document useful (0 votes)
20 views

Deploy OpenStack

This document provides a guide to networking in OpenStack. It describes creating a private network and router to connect instances. It also covers allocating and assigning floating IPs to make instances publicly accessible

Uploaded by

ankur thaper
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Deploy OpenStack

This document provides a guide to networking in OpenStack. It describes creating a private network and router to connect instances. It also covers allocating and assigning floating IPs to make instances publicly accessible

Uploaded by

ankur thaper
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

How to Get Started with

OpenStack
Docs » Manuals » OpenStack User’s Manual » How to Get Started with
OpenStack

To get started using OpenStack, you will need to log in to Horizon,


OpenStack’s browser-based dashboard. Your administrator should
provide you with the details you need to log in. If you do not have these
details, reach out to your OpenStack administrator.
Once logged in, you are presented with the main dashboard of your
OpenStack project. From here you can see a number of links on the left
under the Project and Identity tabs as well as a summary of the cloud
usage in the center. You will do most of your work out of the Project tab,
where you can spin up instances, create networks and such.
The Identity tab is where you will find user-based information, such as
what project your user is associated with or details about your user.

Log in to Horizon
This section demonstrates how to log in to Horizon.
Step 1 — Navigate to Horizon
Pull up the domain name provided for Horizon from your administrator in
a browser to load the Horizon login page.
Horizon Login Page:
Step 2 — Log in to Horizon
From here, enter in the provided credentials to log in.
Initial Horizon Dashboard:
Next Steps
The next guide in this series explains how to create a private network, a
basic building block of an OpenStack cloud.

Networking in
OpenStack
Docs » Manuals » OpenStack User’s Manual » Networking in OpenStack

This guide explains networking in OpenStack including how to create a


private network, a router, and allocate and assign floating IPs.
You will learn how to create a private network on which instances will be
deployed. The network created in this guide will be used later when
creating an instance.
Note — Private networks should be used where possible. Only expose
the portions of your cloud to a public network when needed.
Neutron is the name of the service that manages networking in
OpenStack. It provides “network connectivity as a service” between
interfaces and uses the OpenStack Networking API.
Neutron allows networks, routers, floating IPs, and security groups to be
created.

Table of Contents
1. Create a Network and Router
2. Floating IPs

Create a network and router


This section demonstrates creating a private network and router. The
router is important as it will allow you to create a route between
networks, such as from the private network to the Internet.

Create a network
Step 1 — Getting started
In Horizon, notice the sections on the left called Project and Identity.
Components of an OpenStack cloud, like a private network, are created
through the Project tab.

To create a network, under Project on the left, find Network, then


navigate to Networks. Finally, locate the Create Network button near
the top right.
Step 2 — Create network

• Network Name — This is the name of the network. In this example,


the network is called network-1.
• Enable Admin State — This enables the network and should
remain checked.
• Create Subnet — Leave checked to create a subnet.
• Availability Zone Hints — This option’s default is sufficient for this
guide.

Fill out any other needed details and navigate to the Subnet tab.
Step 3 — Create subnet

• Subnet Name — Specify a name for the subnet, this example is


called subnet-1
• Network Address — Choose a network in CIDR notation. This
example uses 192.168.0.1/24.
• Gateway IP — Optionally choose the gateway IP for this network. If
the gateway IP is not filled out, one will be chosen by the neutron
service. The final tab is called Subnet Details. This tab does not
need to be filled out to create the network and subnet. This
example will stop here, however on this page you can enable or
disable DHCP, specify specific IPs to be allocated, set DNS name
servers, and set Host Routes.

Step 4 — Confirm network creation


With the previous steps done, the network has been created. Loading
the Network -> Networks tab will display the new network:
Create a Router
With a network created, the next step is to create a router which will
bridge the connection from the External or provider network to the
private network.

Step 1 — Getting started


To make a router in Horizon, under Project, find the Network section,
then Routers under that. This page will list current routers and allows
you to create a router.
To create a new router, click the Create Router button near the top
right.

Step 2 — Create a router


• Router Name — Choose a name for the router. This example router
will be called router-1.
• Enable Admin State — Leave checked to enable the router.
• External Network — The External network will be used
• Availability Zone Hints — This option’s default is sufficient for this
guide.

The router will need to be connected to an external network, which will


be the provider network. The network called External will be used.

Step 3 — Confirm the router has been created


Once created it will show in the list of routers, under Network ->
Routers.
Step 4 — Connect router to private network
To allow the router to communicate with the External and the network-
1 network, the network-1 network will need to be attached. Connecting
the router to a network is called attaching an interface.
First, pull up the newly created router from the Network ->
Routers section of Horizon.
Next, to add an interface to this router, click the router’s name in the
listing of routers, then click the Add Interface button near the top right.

In the following choose the subnet-1 subnet to connect the router to


and optionally choose an IP address for the interface. If you don’t
choose an IP, the gateway IP of the subnet will be used.

Step 5 — Confirm the networks are connected


With the interface added to the router, the External and network-
1 networks are now connected. This can visually be seen by navigating
to the Network tab on the left, then the Network Topology tab under
that.

Floating IPs
Floating IPs in OpenStack are publicy routable IP addresses that can be
attached and detached to instances. For example if there’s an instance
associated with a private network but needs to be accessed from the
Internet, a floating IP can be associated with the instance, allowing
communication from the Internet.
Allocate and Assign Floating IPs
To use Floating IPs they will first need to be allocated from the provider
network’s pool of IPs.

Allocate floating IP
To allocate floating IPs in Horizon, navigate to the Network tab on the
left, and find Floating IPs.

Click Allocate IP To Project to allocate a new IP.

Next, fill out needed details in the IP allocation form.

The IP will be obtained from the External provider network. This is the
only network floating IPs can be assigned from.
Once the IP is added, it will appear in the floating IP list.

This floating IP address will be used later to access an instance over


SSH.

Next Steps
The next guide goes over images in OpenStack, which are bootable
operating systems.

Working with Images


Docs » Manuals » OpenStack User’s Manual » Working with Images

Images in OpenStack are what powers instances. In this guide, you will
learn how to view images, upload your own, and make snapshots of
images.
An image is a file that contains a bootable operating system. Many
different cloud image sources are available for download from major
operating system providers like CentOS, Ubuntu, and Debian to name a
few. You can also make your own images from scratch or create them
from volumes or running instances. Snapshots of instances can be
created which can serve both as a backup and also a template for other
instances.

List and Upload Images


List images
To begin, you will need to know where to find images in OpenStack.
In Horizon, images are found on the left through Project -> Compute ->
Images.

Upload images
To upload an image into OpenStack, the image needs to first exist on
your machine, and then you can use Horizon to upload it.
This section will walk you through uploading the CirrOS image.

Step 1 — Download the CirrOS image


To start, first download the CirrOS image to your machine.
The latest version of CirrOS is available from their download page.
Ensure the latest version of the CirrOS image is downloaded.

Step 2 — Upload the image into OpenStack


To upload an image navigate to Project -> Compute -> Images. From
there, click the Create Image button.

Next, fill in the required details.


• Image Name – This is what you want to call this image in
OpenStack
• Image Description – This is an optional description for the image
• File – Where is the file located on your machine?
• Format – The format should be QCOW2 – QEMU Emulator

Optionally, you can specify requirements, like minimum disk space and
RAM, for the image under the Image Requirements heading.
Click the ? icon for assistance with specifics.

Next Steps
With this guide complete, move on to the next guide, which
explains how to create an Instance in Horizon.

How to Create an
Instance
Docs » Manuals » OpenStack User’s Manual » How to Create an Instance

Instances in OpenStack comprise the cloud’s computing power. This


guide demonstrates how to make an instance using Horizon.
You will also learn how to upload or create an SSH key pair, assign
storage using a volume, and create a security group. Each of these
components will be added to the instance.
Table of Contents
1. Before Creating an Instance
2. SSH Key Pairs
3. Security Groups
4. Add a Volume
5. Create an Instance

Before Creating an Instance


Before creating an instance, several pieces need to be in place.
Generally speaking, these items should exist before creating an
instance:

• An SSH public key — The public portion of an SSH key pair


• A security group — Defines network traffic rules
• A flavor — Defines resources, like vCPUs, RAM, and disk storage
• An image — This is a bootable operating system
• A network — This is typically a private network

Each item will be explained throughout this guide.

SSH Key Pairs


An SSH key pair is required to access any instances over SSH. Password
authentication is by default disabled in the operating system images.
You can either have an SSH key created or you can upload the public key
of your SSH key pair.
This section explains how to create an SSH key pair within OpenStack
and also how to upload your own SSH public key.
Create an SSH key pair
To create an SSH key pair, locate Project -> Compute -> Key Pairs in
Horizon.
Next, click Create Key Pair near the top and to the right.

In the following form, input the key pair name and the type of key it will
be. Once done, you will be prompted to download the private key which
needs to be stored in a safe place. Only you should have access to your
private SSH key pair! The public key portion of the key pair now exists in
Horizon.
Upload an SSH key pair
Should you already have an SSH key pair you want to use, you can
instead upload your public key. This can be done in the same Key
Pairs section.

Locate the Import Key Pair button near the top right of the screen. Fill
out the name of the key pair, specify the type of key it is, and finally
choose the public key from your computer or paste the public key in.

Confirm SSH key pair upload


To confirm success, navigate back to the SSH key pair listing and
confirm the key pair was uploaded.
Security Groups
A security group in OpenStack controls inbound and outbound network
access. OpenStack, by default, assigns a security group to each
instance that restricts all incoming traffic. It is up to you to determine
what traffic should or should not be allowed to or from an instance. This
can be accomplished by creating the required security groups for your
instance traffic.
This section demonstrates creating a security group allowing inbound
SSH traffic for a specific IP address.

Step 1 — List security groups


To list security groups, find Project -> Network -> Security Groups in
Horizon on the left.

Step 2 — Create SSH security group


Fill out the name and description of the group. Once done, you will be
taken to a page where you can define egress (outbound) and ingress
(inbound) rules for the group.

When the rule is created, two egress rules allowing all outbound traffic
are added to it by OpenStack. You can see these as follows:

Step 3 — Add ingress SSH rule


To add the rule for SSH, click the Add Rule button near the top right,
which loads this form:
From this page you can define a custom rule or choose from options
created for you, such as SSH or HTTPS.
For this example, choose the SSH option from the first drop down.
Note! — You may notice that all traffic is allowed through when choosing
the SSH option. This is same thing as having port 22 open for all SSH
traffic to come through and may not be desired.
To allow traffic for a single host, in the CIDR field add the IP allowed to
connect over SSH. Similarly if a range of IPs needs to be allowed, allow
the range using CIDR notation.

With the new rule added you will see it listed like so:
Add a Volume
Additional disk space can be added to instances through volumes. A
volume in OpenStack is like a removable USB drive that can be attached
to instances as seen fit. Cinder is the OpenStack block storage service
that allows volumes to be created. A volume can also be used to boot an
instance.
This section explains how to create a volume in Horizon by creating a
5GB example volume. This is an optional step should your instance not
require additional storage through a volume.

Create and attach a volume


Step 1 — List volumes
In Horizon, look to the left for Project -> Volumes -> Volumes to pull up
the page to manage and create volumes.

Step 2 — Create a volume


To create a volume, click Create Volume, then fill out the form details.

Specify a name and size for the volume. The remaining options are not
required to create the volume.
After creating the volume you will be taken back to the volume listing
page. The Status column will read “Available” if the volume is ready to be
used.
Create an Instance
An instance is another name for a virtual machine in OpenStack.
Instances are created by the Nova service and contribute to the
processing power of the cloud.
With the previous steps followed, you have everything needed to make
an instance.
This section will explain how to create a volume-backed instance.

How to Create an Instance


Step 1 — List Instances
To get started, in Horizon find Project -> Compute -> Instances.

Step 2 — Launch Instance -> Details


Next, use Launch Instance near the top right, which loads this form:
Fill out a name for the instance and optionally a description. Specify the
number of instances to spawn using the Count drop down. Take note of
the available instances to your project in this screen as well.

Step 3 — Launch Instance -> Source


After the Details section is filled out, move on to the Source tab on the
left. Here you will specify a source to boot from, which is typically going
to be an image.
• Select Boot Source: Select Image from the drop down.
• Create New Volume: Select Yes
• Volume Size: Set an appropriate amount of disk space
• Delete Volume on Instance Delete: Leave the default
of No selected

You should see a variety of operating systems images to choose from.


This example will use the CentOS 8 Stream image. Select the
appropriate image using the up arrow on the right. After doing so, you
will see the image listed in the Allocated section.
This example demonstrates one way to create an instance, which is a
volume-backed instance, and is useful for persistent storage.

Step 4 — Launch Instance -> Flavor


With the Source section done, it is time to set a flavor. A flavor is a way
to define resource allocation to an instance. The number of vCPUs,
RAM, and disk space are defined using flavors.
Flavors are listed in the same way images are. Select the flavor required
for the instance workload using the up arrow on the right. Once set, you
will see the flavor listed in the Allocated portion.

Step 5 — Launch Instance -> Networks


With a flavor set, move on to the Networks section to specify a network
the instance will be associated with.

Note! — Place all cloud infrastructure on private networks and only


expose what is needed to the Internet, such as a load balancer, or front-
end web servers.
This example uses the private network created from the networking
guide.
Step 6 — Launch Instance -> Security Groups
Next, a security group should be set. Note that security groups can later
be added to an existing instance. OpenStack by default disables all
incoming network traffic to instances so the traffic you want to allow
needs to specified using security groups.

Choose from the list the security group to apply to this instance. This
example applies the ssh security group, allowing SSH access.

Step 7 — Launch Instance -> Key Pair


The last step is to add your SSH key pair.

Choose from the key pair listing the SSH key to add. You can also create
a key pair or upload a public key using this form.

Step 8 — Launch Instance


This concludes all steps required to create an instance. Use Launch
Instance to spin up the instance.
As the instance is spawning you will see it appear like so:

Once the instance creation is complete, it will show like so and


the Status column will display Active and Power State will be Running:

How to Access the Instance over SSH


Since this instance is on a private network, it is only possible to access
it over SSH from the OpenStack hardware nodes, which is not a feasible
way to access it.
To access this instance over SSH, assign a floating IP to it. This can be
done from the instance listing page using the drop down on the right.

This floating IP can now be used to access the instance over the
Internet. The default username of the instance is typically the same as
the name of the operating system.
In this example the CentOS 8 Stream image was used so the default user
is centos. The Ubuntu’s image default user is ubuntu. Debian’s
is debian.
Next Steps
Navigate to the next guide in this series to learn how to back up and
restore instance data.

How to Make Backups


in OpenStack
Docs » Manuals » OpenStack User’s Manual » How to Make Backups in
OpenStack

Having a solid backup strategy is important in the event where data is


lost and you need to recover it. In this guide, you will learn how to make
backups of instance data, volumes, and how to store backups outside of
the OpenStack cloud.

Considerations for Testing Backups


Backups should not only be created, but should be confirmed they
contain all data as well as be restored and tested as part of a polished
backup strategy. Consider a disaster recovery scenario where you have
known backups, however they were never tested, and are not usable
due to some circumstance.

Instance Backups
How to Create an Instance Backup
This section demonstrates how to create an instance backup using
Horizon by creating a snapshot.

Step 1 — Create Instance Backup


To create a backup of an instance, navigate to Project -> Compute ->
Instances.
From there, find the instance in question and click the Create
Snapshot button. This starts the process of backing up the instance
data and may take some time to complete.

Step 2 — Confirm Backup Completion


To confirm the snapshot was created successfully, navigate to Project -
> Compute -> Images, then find the snapshot in the list.
How to Recover an Instance Backup
This section explains how to recover an instance backup using Horizon.

Step 1 — Recover snapshot


To recover the instance snapshot, navigate to Project -> Compute ->
Instances and launch a new instance. When filling out the form, ensure
you select as the boot source Instance Snapshot and choose the
snapshot to restore.

Step 2 — Confirm restoration


To confirm the snapshot has restored list the instances in Horizon and
check the status column. Check to ensure everything still works as
expected within that instance.

Volume Backups
How to Create a Volume Backup
In addition to creating instance snapshots, you can also create backups
of volumes in Horizon. This is important when a persistent volume is
used and you want to create backup copies of it.

Step 1 — Create volume backup


To back up a volume, navigate to Project -> Volumes -> Volumes, then
to the volume in you are working with, select from the drop down on the
right, Create Backup.

Fill out the following form with at least the name of the backup and any
other fields needed.
Step 2 — Confirm volume backup creation
To confirm the backup created successfully, navigate to Project ->
Volumes -> Backups, then locate the backup in the list, and take note of
the Status column. You should see Available indicating the backup is
complete and ready to use.
How to Recover a Volume Backup
This section will explain the steps needed to recover a volume backup
using Horizon.

Step 1 — Find the volume backup


To find the volume backups, navigate to Project -> Volumes ->
Backups and confirm the backup is in the list.

Step 2 — Restore volume backup


To restore this backup, choose from the listing drop down on the right,
the Restore Backup option.
Choose the Create a New Volume option to recover this backup into a
new volume, that can be later attached to an instance as needed.

Get Started with


OpenStackClient
Docs » Manuals » OpenStack User’s Manual » Get Started with
OpenStackClient

OpenStack offers a way to administer your cloud over the command line
using OpenStackClient.
The purpose of this guide is to introduce you to managing your cloud
using the command line. You will learn how to install OpenStackClient,
authenticate, and run introductory commands. Everything that can be
done using Horizon, can also be accomplished using OpenStackClient.

Installing OpenStackClient
OpenStackClient is available as a Python pip package.
For more information about this package, see OpenStackClient’s pip
project page.
Note! — There exist two OpenStackClient
packages: openstackclient and python-openstackclient. This guide
recommends using openstackclient as it comes with many more
OpenStack service command line clients. You can use either package,
but if you want to interact with a specific service’s command line client,
you may have to install that separately.

How to Install OpenStackClient


Note! — These instructions are meant for a Linux environment.
Before getting started, make sure Python 3 and pip are installed to your
machine.
The first step is to create a Python virtual environment. This is useful in
that this environment will not interfere with your system’s Python
installation.

Step 1 — Create Python virtual environment


The following demonstrates creating a virtual environment in the
path ~/venv/openstackclient.
Create the environment:
$ python3 -m venv ~/venv/openstackclient

Activate the environment using source:


$ source ~/venv/openstackclient/bin/activate
(openstackclient) :~$

Notice the shell now has (openstackclient) where commands are


entered. This indicates the virtual environment is active.

Step 2 — Update pip


Pip may need to be updated before installing OpenStackClient.
To do so, use:
python3 -m pip install -U pip

Step 3 — Download OpenStackClient


With the virtual environment prepared, use pip to download the
OpenStackClient package:
$ pip3 install openstackclient

Step 4 — Download OpenStack RC and clouds.yaml files


Next, you will need to obtain two files from Horizon:

• OpenStack RC
• clouds.yaml

These are located under the Project tab, then API Access.
From here, click the Download OpenStack RC File drop-down, and then
download both files.
The clouds.yaml file needs to exist in ~/.config/openstack for
OpenStackClient to function. When downloaded, ensure it can be
located as ~/.config/openstack/clouds.yaml.
Multiple clouds: If you are working with multiple clouds, add the cloud
entry to the existing clouds.yaml and the cloud can be specified
using OS_CLOUD=$cloud_name or --os-cloud=$cloud_name,
where $cloud_name is the name of the cloud you’re working with.
Example clouds.yaml with two cloud entries, cloud-1 and cloud-2:
clouds:
cloud-1:
auth:
auth_url: http://50.50.50.1:5000
username: "admin"
project_id: b93259ca0a5b4541b30e4e16ae1d699d
project_name: "Apples"
user_domain_name: "Default"
region_name: "iad3"
interface: "public"
identity_api_version: 3
cloud-2:
auth:
auth_url: http://50.50.50.2:5000
username: "admin"
project_id: 6d0ef671c4b2413d920b61e3777fe2ab
project_name: "Oranges"
user_domain_name: "Default"
region_name: "iad3"
interface: "public"
identity_api_version: 3

Step 5 — Finish preparing environment


Next, load the OpenStack RC file into your shell using source:
$ source ~/Downloads/user-openrc.sh

This action sets needed environment variables and will also ask you to
authenticate as your OpenStack user:
(openstackclient):~$ source ~/Downloads/user-openrc.sh
Please enter your OpenStack Password for project User Cloud Test as user
user1:

Enter in the password for your user, and you are now set to use
OpenStackClient.

Note! — In addition to OpenStackClient, there are other command line


clients for various OpenStack services that can be used. For
example, Nova and Cinder each have their own command line client, as
well as other services.
In later releases of OpenStack use of service-specific command line
interfaces will be deprecated. When using the command line to
administer OpenStack it is recommended to use OpenStackClient where
possible as opposed to individual service’s command line interfaces
such as nova‘s CLI.
First Time Using
OpenStackClient
For users using OpenStackClient for the first time, follow this section to
learn how to list and show the details of the project associated with your
OpenStack user.
As a first command, try listing the project your user is associated with,
using openstack project list:
$ openstack project list
+----------------------------------+-----------------+
| ID | Name |
+----------------------------------+-----------------+
| a7f3c46fb8b3404c89dd94b0c33301e0 | User Cloud Test |
+----------------------------------+-----------------+

Next, list the details of the project under


ID a7f3c46fb8b3404c89dd94b0c33301e0, using the show subcommand:
$ openstack project show a7f3c46fb8b3404c89dd94b0c33301e0
+-------------+-------------------------------------------------------------------
----+
| Field | Value
|
+-------------+-------------------------------------------------------------------
----+
| description | This is a testing Project used to create documentation for end use
rs. |
| domain_id | default
|
| enabled | True
|
| id | a7f3c46fb8b3404c89dd94b0c33301e0
|
| is_domain | False
|
| name | User Cloud Test
|
| options | {}
|
| parent_id | default
|
| tags | []
|
+-------------+-------------------------------------------------------------------
----+

Note! — Entering only openstack and running that will take you into the
OpenStackClient shell allowing commands to be run without needing to
prefix them with openstack:
(openstackclient) user@host:~$ openstack
(openstack) network list
+--------------------------------------+----------+-------------------------------
-------+
| ID | Name | Subnets
|
+--------------------------------------+----------+-------------------------------
-------+
| 5cc755c9-41fc-44c2-87e7-642dfdfb0208 | External | a52754dd-13d9-4a36-bab6-10058f
4887f5 |
+--------------------------------------+----------+-------------------------------
-------+
(openstack) exit
(openstackclient) user@host:~$

Type exit to leave the OpenStackClient shell.

Next Steps
Navigate to the next guide in this series to learn how to create networks
in OpenStack.
Create a Network
Docs » Manuals » OpenStack User’s Manual » Create a Network

This guide explains networking in OpenStack including how to create a


private network, a router, and allocate and assign floating IPs.
You will learn how to create a private network on which instances will be
deployed. The network created in this guide will be used later when
creating an instance.
Neutron is the service that manages networking in OpenStack and
allows for networks, routers, floating IPs, and security groups to be
created. It provides “network connectivity as a service” between
interfaces and uses the OpenStack Networking API.

Table of Contents
1. Create a Network and Router
2. Floating IPs

Create a Network and Router


This section demonstrates creating a private network and router. The
router is important as it will allow you to create a route between
networks, such as from the private network to the Internet.
This section explains how to make a network and router using the
command line with OpenStackClient.
Create a network
Listed are the steps needed to create a private network. Variables are
presented in all capital and should be replaced accordingly. Note the
output of most of the commands has been truncated.
Note! — Private networks should be used where possible. Only expose
the portions of your cloud to a public network when needed.

Step 1 — Create private network


Use this command to create a network,
replacing NETWORK_NAME with the name of the network:
$ openstack network create NETWORK_NAME

Create a network called network-1:


$ openstack network create network-1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2021-05-19T20:13:29Z |
| description | |
| dns_domain | None |
| id | 0a193fa1-2019-4fbc-a862-6f6ced157c1e |

Step 2 — Create subnet


Next, a subnet will need to be created.
Use this command to create a subnet,
replacing NETWORK_NAME and SUBNET_NAME with the respective
names of the network and subnet and replace SUBNET_RANGE with the
subnet to use. An example subnet range could be 10.0.0.0/24:
$ openstack subnet create --subnet-range SUBNET_RANGE --network NETWORK_NAME
SUBNET_NAME

Create a subnet called subnet-1 with subnet range of 10.0.0.0/24:


$ openstack subnet create --subnet-range 10.0.0.0/24 --network network-1 subnet-1
+----------------------+--------------------------------------+
| Field | Value |
+----------------------+--------------------------------------+
| allocation_pools | 10.0.0.2-10.0.0.254 |
| cidr | 10.0.0.0/24 |
| created_at | 2021-05-19T20:22:03Z |
| description | |
| dns_nameservers | |
| dns_publish_fixed_ip | None |
| enable_dhcp | True |
| gateway_ip | 10.0.0.1 |

Step 3 — Show network details


You can list the network and subnet and show more information about
each.
List networks using:
$ openstack network list
+--------------------------------------+-----------+------------------------------
--------+
| ID | Name | Subnets
|
+--------------------------------------+-----------+------------------------------
--------+
| 0a193fa1-2019-4fbc-a862-6f6ced157c1e | network-1 | df4d6183-9c3b-4bb9-a686-cf1fc
7d60f7f |
| 5cc755c9-41fc-44c2-87e7-642dfdfb0208 | External | a52754dd-13d9-4a36-bab6-10058
f4887f5 |
+--------------------------------------+-----------+------------------------------
--------+

List subnets using:


$ openstack subnet list
+--------------------------------------+----------+-------------------------------
-------+-------------------+
| ID | Name | Network
| Subnet |
+--------------------------------------+----------+-------------------------------
-------+-------------------+
| a52754dd-13d9-4a36-bab6-10058f4887f5 | Internet | 5cc755c9-41fc-44c2-87e7-642dfd
fb0208 | 173.231.217.64/28 |
| df4d6183-9c3b-4bb9-a686-cf1fc7d60f7f | subnet-1 | 0a193fa1-2019-4fbc-a862-6f6ced
157c1e | 10.0.0.0/24 |
+--------------------------------------+----------+-------------------------------
-------+-------------------+

To get more information about each, use the show subcommand and
specify the UUID for the network and subnet:
$ openstack network show 0a193fa1-2019-4fbc-a862-6f6ced157c1e
$ openstack subnet show df4d6183-9c3b-4bb9-a686-cf1fc7d60f7f

Create a Router
With a network created, the next step is to create a router which will
bridge the connection from the External or provider network to the
private network.

Step 1 — Create router


To make a router, use this base command,
replacing ROUTER_NAME with the name of the router:
$ openstack router create ROUTER_NAME

Create a router called router-1:


$ openstack router create router-1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2021-05-19T20:35:14Z |

Step 2 — Attach interfaces


With the router created, the External and subnet-1 interfaces need to
be attached to it.
To add a subnet, use this command,
replacing ROUTER_NAME and SUBNET_NAME with the names of the
respective router and subnet:
$ openstack router add subnet ROUTER_NAME SUBNET_NAME

Attach subnet:
Add subnet subnet-1 to the router called router-1:
$ openstack router add subnet router-1 subnet-1

The command to add the subnet to the router returns no output if


successful.

Attach External network:


To finish setting up the router, attach the External network to it.
Use this command to add the external network,
replacing EXTERNAL_NETWORK_UUID with the UUID of the network:
$ openstack router set --external-gateway EXTERNAL_NETWORK_UUID
ROUTER_NAME

Obtain the UUID of the External network by running openstack network


list. The UUID will be listed in the first column.

Add the external network to the router called router-1:


$ openstack router set --external-gateway
5cc755c9-41fc-44c2-87e7-642dfdfb0208 router-1

Step 4 — Confirm router details


With these steps completed, you have a router that connects the
external network to the private network.
You can see the details of the router by running the following,
replacing ROUTER_NAME with the name of the router:
$ openstack router show ROUTER_NAME

Show the details for the router called router-1, including the interfaces
that were previously attached:
$ openstack router show router-1 --fit-width
+-------------------------+-------------------------------------------------------
----------------------------------------------+
| Field | Value
|
+-------------------------+-------------------------------------------------------
----------------------------------------------+
| admin_state_up | UP
|
| availability_zone_hints |
|
| availability_zones | nova
|
| created_at | 2021-05-19T20:35:14Z
|
| description |
|
| external_gateway_info | {"network_id": "5cc755c9-41fc-44c2-87e7-642dfdfb0208",
"external_fixed_ips": [{"subnet_id": |
| | "a52754dd-13d9-4a36-bab6-10058f4887f5", "ip_address":
"173.231.217.74"}], "enable_snat": true} |
| flavor_id | None
|
| id | d5b0eb30-8b2a-4f2e-a9df-4ad7ee792cec
|
| interfaces_info | [{"port_id": "fa1f794f-5101-4df4-b83a-3c260d0a65fa", "
ip_address": "10.0.0.1", "subnet_id": |
| | "df4d6183-9c3b-4bb9-a686-cf1fc7d60f7f"}]
|
| name | router-1
|

Floating IPs
Floating IPs in OpenStack are publicly routable IP addresses that can be
attached and detached to instances. For example if there’s an instance
associated with a private network but needs to be accessed from the
Internet, a floating IP can be associated with the instance, allowing
communication from the Internet.

Allocate and Assign Floating IPs


To use Floating IPs they will first need to be allocated from the provider
network’s pool of IPs. The following is a list of commands used to
manage floating IPs.
Step 1 — Allocate floating IP
Allocate additional floating IPs where NETWORK is the UUID of the network
to allocate IPs from:
$ openstack floating ip create NETWORK

You will need to first obtain the External network’s UUID


using openstack network list.

Allocate a floating IP from the External network:


$ openstack floating ip create 5cc755c9-41fc-44c2-87e7-642dfdfb0208
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2021-05-19T20:54:19Z |
| description | |
| dns_domain | None |
| dns_name | None |
| fixed_ip_address | None |
| floating_ip_address | 173.231.217.75 |

Step 2 — List floating IPs


Make use of openstack floating ip list to view floating IPs. You will
see the IP allocated from the previous section.

List floating IPs:


$ openstack floating ip list
+--------------------------------------+---------------------+------------------+-
-----+--------------------------------------+----------------------------------+
| ID | Floating IP Address | Fixed IP Address |
Port | Floating Network | Project |
+--------------------------------------+---------------------+------------------+-
-----+--------------------------------------+----------------------------------+
| 99d58cc0-1b27-4171-aa44-6c15d15718fa | 173.231.217.75 | None |
None | 5cc755c9-41fc-44c2-87e7-642dfdfb0208 | fece7ddb8663497bb99ee0988719143c |
+--------------------------------------+---------------------+------------------+-
-----+--------------------------------------+----------------------------------+

This floating IP will be used later to access an instance over SSH.

Next Steps
The next guide goes over images in OpenStack, which are bootable
operating systems.

Manage OpenStack
Images
Docs » Manuals » OpenStack User’s Manual » Manage OpenStack Images

Images in OpenStack are what powers instances. In this guide, you will
learn how to view images, upload your own, and make snapshots of
images.
An image is a file that contains a bootable operating system. Many
different cloud image sources are available for download from major
operating system providers like CentOS, Ubuntu, and Debian to name a
few. You can also make your own images from scratch or create them
from volumes or running instances. Snapshots of instances can be
created which can serve both as a backup and also a template for other
instances.
List and Upload Images
List images
To begin, you will learn how to list images using OpenStackClient.

Step 1 — List images


To list available images, use:
$ openstack image list
+--------------------------------------+------------------------------------------
------------+--------+
| ID | Name
| Status |
+--------------------------------------+------------------------------------------
------------+--------+
| 02609270-b2d7-4ee2-9e7b-450163362b57 | Amphora (x64-haproxy-ubuntu-focal)
| active |
| 1d6ab32b-a305-403b-9d44-5981890beccf | CentOS 7 (el7-x86_64)
| active |
| f2d17cda-b84d-4600-8473-111e180a5452 | CentOS 8 (el8-x86_64)
| active |
| d5a101ff-0870-435f-bf76-c3309e542a53 | CentOS 8 Stream (el8-x86_64)
| active |
| 8c8e0a35-61dd-4540-b9fd-ca36ca0ef181 | Debian 10 (buster-amd64)
| active |
| 00468d54-84fd-4e03-9935-aabb6b0fa60f | Debian 9 (stretch-amd65)
| active |
| be44af12-aa34-4b25-b4af-60a66599f442 | Fedora CoreOS (fedora-coreos-33.20210412.
3.0-stable) | active |
| 9a5937ff-9474-4dbe-84b4-ba452024446c | Ubuntu 18.04 (bionic-amd64)
| active |
| c005b6f3-9d34-4f91-94b6-1ff50c174750 | Ubuntu 20.04 (focal-amd64)
| active |
+--------------------------------------+------------------------------------------
------------+--------+
To get more information about an image, use openstack image show
ID:

$ openstack image show ID

ID is the Name or the ID column in the above output.

Show image details


Example showing the details of an image:
$ openstack image show fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a --fit-width
+------------------+--------------------------------------------------------------
------------------------------------+
| Field | Value
|
+------------------+--------------------------------------------------------------
------------------------------------+
| checksum | 1d3062cd89af34e419f7100277f38b2b
|
| container_format | bare
|
| created_at | 2020-09-09T20:50:25Z
|
| disk_format | qcow2
|
| file | /v2/images/um_fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a/file
|
| id | fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a
|
| min_disk | 0
|
| min_ram | 0
|
| name | cirros
|
| owner | 5ad1f9e795604f4390d274d7388c4b9f
|
Upload an image
To upload an image into OpenStack, the image needs to first exist on
your machine, and then you can use OpenStackClient to upload it.
This section will walk you through uploading the CirrOS image.

Step 1 — Download the CirrOS image


To start, first download the CirrOS image to your machine.
The latest version of CirrOS is available from their download page.
Ensure the latest version of the CirrOS image is downloaded. You can
use wget to download the image:
$ wget https://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img

Step 2 — Upload the image into OpenStack


Use this command to upload the image, replacing variables
appropriately:
openstack image create IMAGE_NAME --container-format bare --disk-format
qcow2 --file PATH_TO_CIRROS_IMAGE

Upload the CirrOS image:


$ openstack image create cirros --container-format bare --disk-format
qcow2 --file ~/Downloads/cirros-0.5.2-x86_64-disk.img

Note that PATH_TO_CIRROS_IMAGE should be the path to the image


file.

Step 3 — Confirm successful upload


To confirm the image uploaded into the cloud, use openstack image
list.
List the newly uploaded image:
$ openstack image list
+--------------------------------------+--------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+--------------------------------+--------+
| fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a | cirros | active |
+--------------------------------------+--------------------------------+--------+

Create an Instance
Docs » Manuals » OpenStack User’s Manual » Create an Instance

Instances in OpenStack comprise the cloud’s computing power. This


guide demonstrates how to make an instance using OpenStackClient.
You will also learn how to upload or create an SSH key pair, assign
storage using a volume, and create a security group. Each of these
components will be added to the instance.

Table of Contents
1. Before Creating an Instance
2. SSH Key Pairs
3. Security Groups
4. Add a Volume
5. How to Create an Instance
Before Creating an Instance
Before creating an instance, several pieces need to be in place.
Generally speaking, these items should exist before creating an
instance:

• An SSH public key — The public portion of an SSH key pair


• A security group — Defines network traffic rules
• A flavor — Defines resources, like vCPUs, RAM, and disk storage
• An image — This is a bootable operating system
• A network — This is typically a private network

Each item will be explained throughout this guide.

SSH Key Pairs


An SSH key pair is required to access any instances over SSH. Password
authentication is by default disabled in the operating system images.
You can either create an SSH key pair within OpenStack or upload your
public key.

Create an SSH key pair


SSH keys can be managed, created, and uploaded through the command
line using OpenStackClient.
This section will explain the steps needed to create an SSH key pair
within OpenStack.

To make a key pair, use:


$ openstack keypair create KEY_NAME

KEY_NAME is the name of the SSH key pair.

Create key pair called ssh-1:


$ openstack keypair create ssh-1

This generates a key pair and returns the private key. The private key
should be kept somewhere safe and be inaccessible to others.

Upload SSH Key


If you have an existing SSH key pair to use, you can upload it to the cloud
instead of making a new one. This section demonstrates how to do this.

To upload your public key, use:


$ openstack keypair create --public-key PATH_TO_PUBLIC_KEY KEY_NAME

KEY_NAME is the name of the SSH key pair


and PATH_TO_PUBLIC_KEY is the path on the filesystem to the public
key.

Here’s an example uploading an SSH public key:


$ openstack keypair create --public-key ~/.ssh/ssh_key.pub ssh_key_2
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | ff:a4:81:c7:59:07:aa:54:43:39:52:cd:b2:12:aa:fb |
| name | ssh_key_2 |
| user_id | 43317575cccc440fbcb38a1f23b45125 |
+-------------+-------------------------------------------------+
Security Groups
A security group in OpenStack controls inbound and outbound network
access. OpenStack, by default, assigns a security group to each
instance that restricts all incoming traffic. It is up to you to determine
what traffic should or should not be allowed to or from an instance. This
can be accomplished by creating the required security groups for your
instance traffic.
This section demonstrates creating a security group allowing inbound
SSH traffic for a specific IP address.

Step 1 — Create a security group


There are several steps needed to create a security group using
OpenStackClient. The group first needs to be created, then additional
commands are used to add rules to it. Finally, you can list the security
group’s details to ensure it has been configured appropriately.
The command to create a security group is:
$ openstack security group create SECURITY_GROUP

SECURITY_GROUP is the name of the security group.

Create an SSH security group:


$ openstack security group create ssh

Step 2 — Add rules


Next, rules need to be added to allow SSH access.
The base command to do this is:
$ openstack security group rule create SECURITY_GROUP --remote-ip
REMOTE_IP --dst-port 22:22 --ingress --protocol tcp

SECURITY_GROUP is the name of the group, which in this case is


called ssh. REMOTE_IP is the IP address for which traffic should be
allowed. The remaining flags specify the rule is for ingress TCP traffic
over port 22.

Create rule allowing SSH from 192.168.1.20 (arbitrary IP):


$ openstack security group rule create ssh --remote-ip 192.168.1.20
--dst-port 22:22 --ingress --protocol tcp

Step 3 — Confirm security group details


Finally, confirm the previous steps were successful by listing the details
of the ssh security group.

List security groups


List security groups using:
$ openstack security group list
+--------------------------------------+---------+------------------------+-------
---------------------------+------+
| ID | Name | Description | Projec
t | Tags |
+--------------------------------------+---------+------------------------+-------
---------------------------+------+
| 42989271-94b4-4209-8a81-5b7f370cbb22 | default | Default security group | fece7d
db8663497bb99ee0988719143c | [] |
| cdf392cd-0f8a-409c-837b-b8409981da93 | ssh | ssh | fece7d
db8663497bb99ee0988719143c | [] |
+--------------------------------------+---------+------------------------+-------
---------------------------+------+

Show details
Show the details of the group:
$ openstack security group show cdf392cd-0f8a-409c-837b-b8409981da93
+-----------------+---------------------------------------------------------------
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
---------------------+
| Field | Value
|
+-----------------+---------------------------------------------------------------
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
---------------------+
| created_at | 2021-05-19T21:38:19Z
|
| description | ssh
|
| id | cdf392cd-0f8a-409c-837b-b8409981da93
|
| name | ssh
|
| project_id | fece7ddb8663497bb99ee0988719143c
|
| revision_number |
4
|
| rules | created_at='2021-05-19T21:38:19Z', direction='egress', etherty
pe='IPv4', id='4a0d26d8-7e9d-4eac-9e19-94cb66cda54f', updated_at='2021-05-19T21:38
:19Z'
|
| | created_at='2021-05-19T21:38:19Z', direction='egress', etherty
pe='IPv6', id='80fcfd69-bc4e-44ad-bbdc-c5049b1a7472', updated_at='2021-05-19T21:38
:19Z'
|
| | created_at='2021-05-19T21:47:46Z', direction='ingress', ethert
ype='IPv4', id='ba39298c-7713-4975-a882-2335bdded8c1', port_range_max='22', port_r
ange_min='22', protocol='tcp', remote_ip_prefix='192.168.1.20/32', updated_at='202
1-05-19T21:47:46Z' |
| stateful | Tru
e
|
| tags | [
]
|
| updated_at | 2021-05-19T21:47:46
Z
|
+-----------------+---------------------------------------------------------------
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
---------------------+

In the above output, the rule allowing SSH traffic from 192.168.1.20 is
visible.

Add a Volume
Additional disk space can be added to instances through volumes. A
volume in OpenStack is like a removable USB drive that can be attached
to instances as seen fit. Cinder is the OpenStack block storage service
that allows volumes to be created. A volume can also be used to boot an
instance.
This section explains how to create a volume using OpenStackClient by
creating a 5GB example volume. This is an optional step should your
instance not require additional storage through a volume.

Create and Attach a Volume


Step 1 — Create volume
Use the following to create volumes:
$ openstack volume create VOLUME_NAME --save SIZE

VOLUME_NAME is the name of the volume and SIZE is the numeric size
in gigabytes.

Create a volume with size 5GB:


$ openstack volume create volume-1 --size 5
Step 2 — List volume
List the newly created volume using:
$ openstack volume list
+--------------------------------------+----------+-----------+------+------------
-+
| ID | Name | Status | Size | Attached to
|
+--------------------------------------+----------+-----------+------+------------
-+
| e6d6242e-3fa5-47fa-8eaa-2f85e8165144 | volume-1 | available | 5 |
|
+--------------------------------------+----------+-----------+------+------------
-+

This volume will later be attached to the instance.

How to Create an Instance


An instance is another name for a virtual machine in OpenStack.
Instances are created by the Nova service and contribute to the
processing power of the cloud.
With the previous steps followed, you have all the parts needed to make
an instance.
This section will explain how to create a volume-backed instance.

Steps for Creating an Instance


When creating an instance in OpenStack using the command line, there
are several pieces needed first. This section walks you through
obtaining each part and then brings them all together to explain how to
create an instance.
To begin you will need to obtain UUIDs for:

• Boot source (image, volume)


• Flavor
• Network
• Security Group
• SSH Key Pair

Step 1 — Obtain boot source UUID


To obtain the image UUIDs, you will need to list images using
OpenStackClient by using openstack image list:
+--------------------------------------+------------------------------------------
------------+--------+
| ID | Name
| Status |
+--------------------------------------+------------------------------------------
------------+--------+
| 02609270-b2d7-4ee2-9e7b-450163362b57 | Amphora (x64-haproxy-ubuntu-focal)
| active |
| 1d6ab32b-a305-403b-9d44-5981890beccf | CentOS 7 (el7-x86_64)
| active |
| f2d17cda-b84d-4600-8473-111e180a5452 | CentOS 8 (el8-x86_64)
| active |
| d5a101ff-0870-435f-bf76-c3309e542a53 | CentOS 8 Stream (el8-x86_64)
| active |

For this example, the CentOS 8 Stream image will be used which is
associated with UUID d5a101ff-0870-435f-bf76-c3309e542a53. This
UUID is later used to build this instance.

Step 2 — Get flavors


Next, list available flavors using openstack flavor list:
+-------------+-------------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+-------------+-------------+-------+------+-----------+-------+-----------+
| c1.large | c1.large | 4096 | 50 | 0 | 8 | True |
| c1.medium | c1.medium | 4096 | 50 | 0 | 4 | True |
| c1.micro | c1.micro | 2048 | 25 | 0 | 2 | True |

Choose the appropriate flavor the instance will require. This example
will use the c1.micro flavor.

Step 3 — Choose network


List networks in OpenStack using openstack network list:
+--------------------------------------+-----------+------------------------------
--------+
| ID | Name | Subnets
|
+--------------------------------------+-----------+------------------------------
--------+
| 29aa8aec-36ec-416d-9828-4a3b6bb10f4b | network-1 | 163e197c-6fcd-4219-bc55-96229
9691206 |
| 5cc755c9-41fc-44c2-87e7-642dfdfb0208 | External | a52754dd-13d9-4a36-bab6-10058
f4887f5 |
| 76a19c4e-f9c7-4c03-8e4d-6862da139cbb | network1 | b5ee016d-70e6-4930-bac0-4af71
c23efde |
+--------------------------------------+-----------+------------------------------
--------+

This example will use network-1 as the network, which is associated


with UUID 29aa8aec-36ec-416d-9828-4a3b6bb10f4b. This UUID will later
be used to create this instance.

Step 4 — Security groups


List security groups using openstack security group list:
+--------------------------------------+---------+------------------------+-------
---------------------------+------+
| ID | Name | Description | Projec
t | Tags |
+--------------------------------------+---------+------------------------+-------
---------------------------+------+
| 44668612-1a18-4289-b5fb-f24de8e20c09 | ssh | | b93259
ca0a5b4541b30e4e16ae1d699d | [] |
| c132bb35-bdc6-4161-b64c-440ab6b631bf | default | Default security group | b93259
ca0a5b4541b30e4e16ae1d699d | [] |
+--------------------------------------+---------+------------------------+-------
---------------------------+------+

The ssh security group will be associated with this instance via
UUID 44668612-1a18-4289-b5fb-f24de8e20c09.

Step 5 — SSH key pair


Lastly, obtain the name of the SSH key pair using openstack keypair
list:

+-------+-------------------------------------------------+------+
| Name | Fingerprint | Type |
+-------+-------------------------------------------------+------+
| key-1 | a7:ab:bd:9c:78:85:e1:a1:c4:07:0f:6d:e9:36:0b:68 | ssh |
| ssh-1 | 53:0e:0f:19:9f:21:5f:7e:36:96:28:31:25:1b:52:af | ssh |
+-------+-------------------------------------------------+------+

This instance will use the SSH key pair called key-1.

Step 6 — Create instance


With the collected information, the instance can be created.
This is the base command needed to make an instance:
$ openstack server create

For the full list of options to make an instance, run:


$ openstack help server create

The full command to make this instance, including variable


placeholders, is:
$ openstack server create --image IMAGE_UUID
--flavor FLAVOR --boot-from-volume VOLUME_SIZE
--network NETWORK_UUID --key-name SSH_KEY_NAME
--security-group SECURITY_GROUP_UUID
INSTANCE_NAME

The following explains what each variable in the above command is for:

• IMAGE_UUID — UUID of the image you want to use


• FLAVOR — The name of the flavor
• VOLUME_SIZE — Size in GB of boot volume
• NETWORK_UUID — UUID of the network to be associated with the
instance
• SSH_KEY_NAME — Name of the SSH key
• SECURITY_GROUP_UUID — UUID of the security group to use
• INSTANCE_NAME — Name of the instance

NOTE — By default, the instance creation will occur in the background.


You can add --wait to the flags to have the command wait until the
instance creation is done which will show you the status of instance
creation.

Create the Instance


Here are the collected details to make an instance from the previous
section:

• Image UUID: d5a101ff-0870-435f-bf76-c3309e542a53


• Flavor: c1.micro
• Network UUID: 29aa8aec-36ec-416d-9828-4a3b6bb10f4b
• Security Group UUID: 44668612-1a18-4289-b5fb-f24de8e20c09
• SSH Key: key-1

Create an instance called instance-1 booted from a 20GB volume:


$ openstack server create --image d5a101ff-0870-435f-bf76-c3309e542a53
--flavor c1.micro --boot-from-volume 20
--network 29aa8aec-36ec-416d-9828-4a3b6bb10f4b
--key-name key-1 --security-group 44668612-1a18-4289-b5fb-f24de8e20c09
instance-1
This starts the process of creating the instance and takes a small
amount of time to complete.
After creating the instance, verify the build process by running $
openstack server show INSTANCE_NAME,
replacing INSTANCE_NAME with the actual name of the instance:
$ openstack server show instance-1 | grep status
| status | ACTIVE
|

The status column indicates the instance status. Seeing ACTIVE in the
status column indicates the instance successfully spawned.
See the Nova compute API documentation for a list of instance status
meanings and additional commands that can be used to troubleshoot
any issues.

Troubleshooting Instance Error


Status
Sometimes, instance creation will not succeed which can be for a
variety of reasons. Running openstack server list will show
the Status of an instance.
Here’s an example of an instance with Status, “ERROR”:
$ openstack server list
+--------------------------------------+-----------------------------+---------+--
-----------------------+----------------------------+------------+
| ID | Name | Status | N
etworks | Image | Flavor |
+--------------------------------------+-----------------------------+---------+--
-----------------------+----------------------------+------------+
| 35d624fe-785d-4915-aa7e-4bb580b29325 | centos_instance_2 | ERROR |
| CentOS 8 (ce8-x86_64) | hc1.micro |
--------------------------------------+-----------------------------+---------+---
----------------------+----------------------------+------------+

Get more information on the error status by running:


$ openstack server show $INSTANCE_UUID --fit-width

Look for the fault row for the reason as to why the instance failed to
create.
For assistance with instance errors, consider consulting with your
OpenStack administrator.

Next Steps
The next guide in this series is regarding backing up and restoring your
instance data.

Managing Backups in
OpenStack
Docs » Manuals » OpenStack User’s Manual » Managing Backups in
OpenStack

Having a solid backup strategy is important in the event where data is


lost and you need to recover it. In this guide, you will learn how to make
backups of instance data, volumes, and how to store backups outside of
the OpenStack cloud.

Considerations for Testing Backups


Backups should not only be created, but should be confirmed they
contain all data as well as be restored and tested as part of a polished
backup strategy. Consider a disaster recovery scenario where you have
known backups, however they were never tested, and are not usable
due to some circumstance.

Instance Backups
How to Create an Instance Backup
This section demonstrates how to create an instance backup using
OpenStackClient.
To begin, ensure you have prepared your OpenStackClient environment
before issuing commands.
Depending on how the instance was spawned will determine how to
create a backup. If the instance is volume-backed, you will have to back
up the volume. If the instance is image-backed, you can back up the
instance itself, which creates an image backup. Each method is
described below.

Volume-backed Instance
To create a backup of a volume-backed instance using
OpenStackClient, you will need to create a backup of the volume, by first
obtaining the volume’s UUID, then use openstack volume backup
create VOLUME_UUID.
In addition, if the volume is in use by an instance, the --force flag is
required to create the volume backup.

Step 1 — Create Backup


Create a backup of a volume-backed instance by first listing volumes
then issuing the command to back up that volume:
$ openstack volume list
+--------------------------------------+-------------------+-----------+------+---
-----------------------------------------+
| ID | Name | Status | Size | At
tached to |
+--------------------------------------+-------------------+-----------+------+---
-----------------------------------------+
| 9887730c-e804-4353-af2d-a92b750ed6b5 | | in-use | 17 | At
tached to instance-2-volume on /dev/vda |
| 9a1dfde3-9113-400c-b06e-80d67c636ef9 | | in-use | 25 | At
tached to wordpress-1 on /dev/vda

This example demonstrates creating a backup of instance-2-volume by


backing up its associated volume, referenced by 9887730c-e804-4353-
af2d-a92b750ed6b5.

Create backup of instance-2-volume:


$ openstack volume backup create 9887730c-e804-4353-af2d-a92b750ed6b5
--force
+-------+--------------------------------------+
| Field | Value |
+-------+--------------------------------------+
| id | bc8d29c4-be51-4675-b290-bd0bdc8c9be7 |
| name | None |
+-------+--------------------------------------+

Take note of the id of the backup as this will be used next to determine
the backup status.

Step 2 — Confirm Backup Completion


The backup will take some time to complete. After a period of time,
check the status by using openstack volume backup show
VOLUME_BACKUP_UUID, replacing VOLUME_BACKUP_UUID with the actual
UUID of the volume backup:
$ openstack volume backup show bc8d29c4-be51-4675-b290-bd0bdc8c9be7
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| availability_zone | None |
| container | backups |
| created_at | 2021-05-24T16:04:49.000000 |
| data_timestamp | 2021-05-24T16:04:49.000000 |
| description | None |
| fail_reason | None |
| has_dependent_backups | False |
| id | bc8d29c4-be51-4675-b290-bd0bdc8c9be7 |
| is_incremental | False |
| name | None |
| object_count | 0 |
| size | 17 |
| snapshot_id | None |
| status | available |
| updated_at | 2021-05-24T16:05:35.000000 |
| volume_id | 9887730c-e804-4353-af2d-a92b750ed6b5 |
+-----------------------+--------------------------------------+

Image-backed Instance
To create a backup of an image-backed instance, use openstack server
backup create INSTANCE_UUID.

Step 1 — Create Backup


First list instances to obtain the UUID, or you can specify the instance
name to the backup command:
$ openstack server list
+--------------------------------------+-------------------+--------+-------------
----------------------------+------------------------------+----------+
| ID | Name | Status | Networks
| Image | Flavor |
+--------------------------------------+-------------------+--------+-------------
----------------------------+------------------------------+----------+
| 226ebf42-f58d-4149-8393-dd4f241c33aa | image-backed | ACTIVE | network-1=19
2.168.0.199 | CentOS 8 Stream (el8-x86_64) | c1.micro |

Next, create a backup of the instance called image-backed using:


$ openstack server backup create image-backed
+------------------+--------------------------------------------------------------
----------+
| Field | Value
|
+------------------+--------------------------------------------------------------
----------+
| container_format | bare
|
| created_at | 2021-05-24T16:45:17Z
|
| disk_format | qcow2
|
| file | /v2/images/um_f3f2bf61-c699-43ce-9db5-4bb3343cbfad/file
|
| id | f3f2bf61-c699-43ce-9db5-4bb3343cbfad
|
| min_disk | 25
|
| min_ram | 0
|
| name | image-backed
|

Note the id column from the output. This is the UUID of the backup and
will be used to verify backup completion.

Step 2 — Confirm Backup Completion


When a backup of an image-backed instance is created, it is created as
an image.
To confirm the status of the backup, use openstack image show UUID:
$ openstack image show f3f2bf61-c699-43ce-9db5-4bb3343cbfad --fit-width
+------------------+--------------------------------------------------------------
----------+
| Field | Value
|
+------------------+--------------------------------------------------------------
----------+
| container_format | bare
|
| created_at | 2021-05-24T16:45:17Z
|
| disk_format | raw
|
| file | /v2/images/um_f3f2bf61-c699-43ce-9db5-4bb3343cbfad/file
|
| id | f3f2bf61-c699-43ce-9db5-4bb3343cbfad
|
| min_disk | 25
|
| min_ram | 0
|
| name | image-backed
|
| owner | b93259ca0a5b4541b30e4e16ae1d699d
|
| properties | [truncated]
|
| protected | False
|
| schema | /v2/schemas/image
|
| size | 26843545600
|
| status | active
|
| tags |
|
| updated_at | 2021-05-24T16:45:50Z
|
| visibility | private
|
+------------------+--------------------------------------------------------------
----------+

Look for the status column to indicate the status of the backup. If the
backup is complete, the status will show as active.

How to Recover an Instance Backup


This section explains how to recover an instance backup using
OpenStackClient.
To recover an instance backup, the process involves creating a new
instance based on the image or volume backup.

Volume-backed Instance
This section demonstrates how to recover an instance using a volume
backup.
To restore an instance from a volume backup, the volume backup needs
to first be restored into a new volume, then an instance can be booted
using that new volume.

Step 1 — Create new volume


First create a volume of appropriate size to restore the volume backup
into, using openstack volume create --size SIZE:
$ openstack volume create wordpress-1-backup-1 --size 25
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-05-24T17:57:29.000000 |
| description | None |
| encrypted | False |
| id | 1810a215-67e4-48b5-ba51-feef9d263660 |
| multiattach | False |
| name | wordpress-1-backup-1 |

Take note of the id, 1810a215-67e4-48b5-ba51-feef9d263660, as this


will be used in the next section to recover.

Step 2 — Restore volume backup


The volume backup can be restored now, but first you will need the UUID
of the backup created previously. This can be listed by using openstack
volume backup list:

$ openstack volume backup list


+--------------------------------------+--------------------------+-------------+-
----------+------+
| ID | Name | Description |
Status | Size |
+--------------------------------------+--------------------------+-------------+-
----------+------+
| f8440441-92b8-4522-9dfe-18868e089d6e | None | None |
available | 25 |
| bc8d29c4-be51-4675-b290-bd0bdc8c9be7 | None | None |
available | 17 |
| 1ae23283-e43f-4a67-97a1-0b7f7afaaff2 | wordpress-media-1-backup | |
available | 5 |
+--------------------------------------+--------------------------+-------------+-
----------+------+

This example will recover the volume backup under UUID f8440441-
92b8-4522-9dfe-18868e089d6e.

Restore the volume backup into the new volume using openstack
volume backup restore BACKUP_UUID VOLUME_UUID,
replacing BACKUP_UUID and VOLUME_UUID with the UUIDs of the
backup and the new volume:
$ openstack volume backup restore f8440441-92b8-4522-9dfe-18868e089d6e 1810a215-67
e4-48b5-ba51-feef9d263660
+-------------+--------------------------------------+
| Field | Value |
+-------------+--------------------------------------+
| backup_id | f8440441-92b8-4522-9dfe-18868e089d6e |
| volume_id | 1810a215-67e4-48b5-ba51-feef9d263660 |
| volume_name | wordpress-1-backup-1 |
+-------------+--------------------------------------+

Step 3 — Confirm volume


Confirm the volume backup restored into the new volume by listing
volumes and note the Status column:
$ openstack volume list
+--------------------------------------+----------------------+-----------+------+
--------------------------------------------+
| ID | Name | Status | Size |
Attached to |
+--------------------------------------+----------------------+-----------+------+
--------------------------------------------+
| 1810a215-67e4-48b5-ba51-feef9d263660 | wordpress-1-backup-1 | available | 25 |
|

If the backup is ready to use, the Status column will show as available.

Step 4 — Create new instance


A new instance can now be created using this volume. For help with how
to create an instance see the Create an Instance guide.
The following builds an instance booted from the previously restored
volume backup:
$ openstack server create --volume 1810a215-67e4-48b5-ba51-feef9d263660
--flavor c1.micro
--network 29aa8aec-36ec-416d-9828-4a3b6bb10f4b
--key-name key-1
--security-group 44668612-1a18-4289-b5fb-f24de8e20c09
wordpress-2-volume-restored

Step 5 — Confirm instance restoration


Show the details of the instance to confirm it is active:
$ openstack server show wordpress-2-volume-restored | grep status
| status | ACTIVE
|
Image-backed Instance
This section explains how to recover an instance using an image
backup.

Step 1 — List images


First, acquire the UUID of the image you wish to restore using openstack
image list:

$ openstack image list


+--------------------------------------+------------------------------------------
------------+--------+
| ID | Name
| Status |
+--------------------------------------+------------------------------------------
------------+--------+
| d5a101ff-0870-435f-bf76-c3309e542a53 | CentOS 8 Stream (el8-x86_64)
| active |
| 8c8e0a35-61dd-4540-b9fd-ca36ca0ef181 | Debian 10 (buster-amd64)
| active |
| be44af12-aa34-4b25-b4af-60a66599f442 | Fedora CoreOS (fedora-coreos-33.20210412.
3.0-stable) | active |
| c005b6f3-9d34-4f91-94b6-1ff50c174750 | Ubuntu 20.04 (focal-amd64)
| active |
| f3f2bf61-c699-43ce-9db5-4bb3343cbfad | image-backed
| active |
| d589995e-7425-42fd-8a6a-3bf98783e0cc | wordpress-1-snap
| active |
| ec4c8f61-6f44-4360-99b3-47b3022d177d | wordpress-2-snap
| active |
+--------------------------------------+------------------------------------------
------------+--------+

This example will use the image called image-backed, which is


associated with UUID f3f2bf61-c699-43ce-9db5-4bb3343cbfad.

Step 2 — Spawn instance


With the image UUID, spawn a new instance called instance-3-image-
backed:
$ openstack server create
--image f3f2bf61-c699-43ce-9db5-4bb3343cbfad
--flavor c1.micro
--network 29aa8aec-36ec-416d-9828-4a3b6bb10f4b
--key-name key-1
--security-group 44668612-1a18-4289-b5fb-f24de8e20c09
instance-3-image-backed

Step 3 — Confirm instance creation


Confirm the instance created successfully by listing instances or
showing the specific details of the instance.
List Instances
List instances using openstack server list:
$ openstack server list
+--------------------------------------+-----------------------------+--------+---
----------------------+------------------------------+----------+
| ID | Name | Status | Ne
tworks | Image | Flavor |
+--------------------------------------+-----------------------------+--------+---
----------------------+------------------------------+----------+
| 98174d7f-53c1-4861-84a5-2517b90ba92e | instance-3-image-backed | ACTIVE | ne
twork-1=192.168.0.176 | image-backed | c1.micro |
| ff205cad-965c-4ae1-9e47-65fa4d1df82b | wordpress-2-volume-restored | ACTIVE | ne
twork-1=192.168.0.226 | N/A (booted from volume) | c1.micro |
| 226ebf42-f58d-4149-8393-dd4f241c33aa | image-backed | ACTIVE | ne
twork-1=192.168.0.199 | CentOS 8 Stream (el8-x86_64) | c1.micro |
| da6591d9-7cbd-47aa-9a46-ff3cb6d52c24 | instance-2-volume | ACTIVE | ne
twork-1=192.168.0.178 | N/A (booted from volume) | c1.micro |
| 72e1e2db-0276-4ddd-85b4-452aa7c449c0 | instance-1 | ACTIVE | ne
twork-1=192.168.0.50 | CentOS 8 Stream (el8-x86_64) | c1.micro |
+--------------------------------------+-----------------------------+--------+---
----------------------+------------------------------+----------+

The first item in the above list is the instance previously created.
The Status column shows ACTIVE indicating the instance is ready to use.
Volume Backups
How to Create a Volume Backup
In addition to creating instance snapshots, you can also create backups
of volumes using OpenStackClient. This is important when a persistent
volume is used and you want to create backup copies of it.

Step 1 — List existing volumes


To create a volume backup, you first need to know the name or UUID of
the volume being backed up.
Determine this by listing volumes, using openstack volume list:
$ openstack volume list
+--------------------------------------+----------------------+-----------+------+
------------------------------------------------------+
| ID | Name | Status | Size |
Attached to |
+--------------------------------------+----------------------+-----------+------+
------------------------------------------------------+
| 1810a215-67e4-48b5-ba51-feef9d263660 | wordpress-1-backup-1 | available | 25 |
|
| 9887730c-e804-4353-af2d-a92b750ed6b5 | | in-use | 17 |
Attached to instance-2-volume on /dev/vda |
| 2a8eb736-9e7b-4ede-9a4e-9a50fc571da2 | | in-use | 25 |
Attached to wordpress-2-volume-restored on /dev/vda |
| 664e09b7-e1f9-46e1-9504-794ff75e7295 | | available | 25 |
|
| 0860845e-ba18-4f1f-84ed-22600ad7bbca | wordpress-media-1 | available | 5 |
|
+--------------------------------------+----------------------+-----------+------+
------------------------------------------------------+

Step 2 — Create volume backup


This example will demonstrate backing up the volume from the above
called wordpress-media-1.
To create a volume backup of this volume, use openstack volume
backup create wordpress-media-1:

$ openstack volume backup create wordpress-media-1


+-------+--------------------------------------+
| Field | Value |
+-------+--------------------------------------+
| id | 3db892b4-809e-400b-9d85-1f3340de49a5 |
| name | None |
+-------+--------------------------------------+

Step 3 — Confirm volume backup completion


You can either list the volume backups and look at the Status column or
show the details of the specific volume backup.
List volume backups using openstack volume backup list:
$ openstack volume backup list
+--------------------------------------+--------------------------+-------------+-
----------+------+
| ID | Name | Description |
Status | Size |
+--------------------------------------+--------------------------+-------------+-
----------+------+
| 3db892b4-809e-400b-9d85-1f3340de49a5 | None | None |
available | 5 |
| f8440441-92b8-4522-9dfe-18868e089d6e | None | None |
available | 25 |
| bc8d29c4-be51-4675-b290-bd0bdc8c9be7 | None | None |
available | 17 |
| 1ae23283-e43f-4a67-97a1-0b7f7afaaff2 | wordpress-media-1-backup | |
available | 5 |
+--------------------------------------+--------------------------+-------------+-
----------+------+

The Status column indicates if the volume backup is ready to use or not
and should report available when the backup is ready.
How to Recover a Volume Backup
This section explains the steps needed to recover a volume backup
using OpenStackClient. The flow for recovering a volume backup is to
find the volume backup UUID, create an empty volume, then recover the
backup into the new volume.

Step 1 — Find the volume backup


First, list the available volume backups using openstack volume backup
list:

$ openstack volume backup list


+--------------------------------------+--------------------------+-------------+-
----------+------+
| ID | Name | Description |
Status | Size |
+--------------------------------------+--------------------------+-------------+-
----------+------+
| 3db892b4-809e-400b-9d85-1f3340de49a5 | None | None |
available | 5 |
| f8440441-92b8-4522-9dfe-18868e089d6e | None | None |
available | 25 |
| bc8d29c4-be51-4675-b290-bd0bdc8c9be7 | None | None |
available | 17 |
| 1ae23283-e43f-4a67-97a1-0b7f7afaaff2 | wordpress-media-1-backup | |
available | 5 |
+--------------------------------------+--------------------------+-------------+-
----------+------+

This example will recover the volume backup called wordpress-media-


1-backup.

Step 2 — Create new volume


Next, create a new volume at least the size of the volume backup
using openstack volume create --size SIZE VOLUME_NAME,
where SIZE is in gigabytes and the VOLUME_NAME is the name of the
volume:
$ openstack volume create --size 5 wordpress-media-1-backup-2
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-05-24T22:04:02.000000 |
| description | None |
| encrypted | False |
| id | 05b1310b-35d0-497f-a150-3ca436b6a969 |

The UUID of this volume is 05b1310b-35d0-497f-a150-3ca436b6a969 and


will be used in the next section.

Step 3 — Recover volume backup


Restore the volume backup into the new volume using openstack
volume backup restore BACKUP_UUID VOLUME_UUID,
replacing BACKUP_UUID and VOLUME_UUID with the UUIDs of the
backup and the new volume:
$ openstack volume backup restore wordpress-media-1-backup 05b1310b-35d0-497f-a150
-3ca436b6a969
+-------------+--------------------------------------+
| Field | Value |
+-------------+--------------------------------------+
| backup_id | 1ae23283-e43f-4a67-97a1-0b7f7afaaff2 |
| volume_id | 05b1310b-35d0-497f-a150-3ca436b6a969 |
| volume_name | wordpress-media-1-backup-2 |
+-------------+--------------------------------------+

Step 4 — Confirm backup recovery


Finally, confirm the backup restored by listing volumes:
$ openstack volume list
+--------------------------------------+----------------------------+-----------+-
-----+------------------------------------------------------+
| ID | Name | Status |
Size | Attached to |
+--------------------------------------+----------------------------+-----------+-
-----+------------------------------------------------------+
| 05b1310b-35d0-497f-a150-3ca436b6a969 | wordpress-media-1-backup-2 | available |
5 | |
| 1810a215-67e4-48b5-ba51-feef9d263660 | wordpress-1-backup-1 | available |
25 | |
| 9887730c-e804-4353-af2d-a92b750ed6b5 | | in-use |
17 | Attached to instance-2-volume on /dev/vda |
| 2a8eb736-9e7b-4ede-9a4e-9a50fc571da2 | | in-use |
25 | Attached to wordpress-2-volume-restored on /dev/vda |
| 664e09b7-e1f9-46e1-9504-794ff75e7295 | | available |
25 | |
| 0860845e-ba18-4f1f-84ed-22600ad7bbca | wordpress-media-1 | available |
5 | |
+--------------------------------------+----------------------------+-----------+-
-----+------------------------------------------------------+

The first item in the above list is the restored backup, wordpress-
media-1-backup-2. Note the Status column
reports available indicating the backup restoration succeeded.

You might also like