How to Create, Deploy and Launch Virtual Machines in OpenStack

In this guide we will learn how to create images and launch an instance of an image (virtual machine) in OpenStack and how to gain control over an instance via SSH.

Requirements

  1. Install OpenStack in RHEL and CentOS 7
  2. Configure OpenStack Networking Service

Step 1: Allocate Floating IP to OpenStack

1. Before you deploy an OpenStack image, first you need to assure that all pieces are in place and we’ll start by allocating floating IP.

Floating IP allows external access from outside networks or internet to an Openstack virtual machine. In order to create floating IPs for your project, login with your user credentials and go to Project -> Compute -> Access & Security -> Floating IPs tab and click on Allocate IP to The Project.

Choose external Pool and hit on Allocate IP button and the IP address should appear in dashboard. It’s a good idea to allocate a Floating IP for each instance you run.

Allocate Floating IP to Project in OpenStack
Allocate Floating IP to Project in OpenStack
Allocate Floating IP to External Pool
Allocate Floating IP to External Pool
Confirmation of Adding Floating IP
Confirmation of Adding Floating IP

Step 2: Create an OpenStack Image

2. OpenStack images are just virtual machines already created by third-parties. You can create your own customized images on your machine by installing an Linux OS in a virtual machine using a virtualization tool, such as KVM, VirtualBox, VMware or Hyper-V.

Once you have installed the OS, just convert the file to raw and upload it to your OpenStack cloud infrastructure.

To deploy official images provided by major Linux distributions use the following links to download the latest packaged images:

  1. CentOS 7http://cloud.centos.org/centos/7/images/
  2. CentOS 6http://cloud.centos.org/centos/6/images/
  3. Fedora 23https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/
  4. Ubuntuhttp://cloud-images.ubuntu.com/
  5. Debianhttp://cdimage.debian.org/cdimage/openstack/current/
  6. Windows Server 2012 R2https://cloudbase.it/windows-cloud-images/#download

Official images additionally contain the cloud-init package which is responsible with SSH key pair and user data injection.

On this guide we’ll deploy a test image, for demonstration purposes, based on a lightweight Cirros cloud image which can be obtained by visiting the following link http://download.cirros-cloud.net/0.3.4/.

The image file can be used directly from the HTTP link or downloaded locally on your machine and uploaded to OpenStack cloud.

To create an image, go OpenStack web panel and navigate to Project -> Compute -> Images and hit on Create Image button. On the image prompt use the following settings and hit on Create Image when done.

Name: tecmint-test
Description: Cirros test image
Image Source: Image Location  #Use Image File if you’ve downloaded the file locally on your hard disk
Image Location: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img 
Format: QCOWW2 – QEMU Emulator
Architecture: leave blank
Minimum Disk: leave blank
Minimum RAM: leave blank
Image Location: checked
Public: unchecked
Protected: unchecked
Create Images in OpenStack
Create Images in OpenStack
Add OpenStack Image Details
Add OpenStack Image Details
OpenStack Images
OpenStack Images

Step 3: Launch an Image Instance in OpenStack

3. Once you’ve created an image you’re good to go. Now you can run the virtual machine based on the image created earlier in your cloud environment.

Move to Project -> Instances and hit on Launch Instance button and a new window will appear.

Launch Image Instance in Openstack
Launch Image Instance in Openstack

4. On the first screen add a name for your instance, leave the Availability Zone to nova, use one instance count and hit on Next button to continue.

Choose a descriptive Instance Name for your instance because this name will be used to form the virtual machine hostname.

Add Hostname to OpenStack Instance
Add Hostname to OpenStack Instance

5. Next, select Image as a Boot Source, add the Cirros test image created earlier by hitting the + button and hit Next to proceed further.

Select-OpenStack Instance Boot Source
Select OpenStack Instance Boot Source
Add Cirros Text Image
Add Cirros Text Image

6. Allocate the virtual machine resources by adding a flavor best suited for your needs and click on Next to move on.

Add Resources to OpenStack Instance
Add Resources to OpenStack Instance

7. Finally, add one of the OpenStack available networks to your instance using the + button and hit on Launch Instance to start the virtual machine.

Add Network to OpenStack Instance
Add Network to OpenStack Instance

8. Once the instance has been started, hit on the right arrow from Create Snapshot menu button and choose Associate Floating IP.

Select one of the floating IP created earlier and hit on Associate button in order to make the instance reachable from your internal LAN.

Add Associate Floating IP to OpenStack Instance
Add Associate Floating IP to OpenStack Instance
Manage Floating IP Associations
Manage Floating IP Associations

9. To test the network connectivity for your active virtual machine issue a ping command against the instance floating IP address from a remote computer in your LAN.

Check Network of Virtual Machine in OpenStack
Check Network of Virtual Machine in OpenStack

10. In case there’s no issue with your instance and the ping command succeeds you can remotely login via SSH on your instance.

Use the instance View Log utility to obtain Cirros default credentials as illustrated on the below screenshots.

Instance View Log Utility
Instance View Log Utility
Instance Login Credentials
Instance Login Credentials

11. By default, no DNS name servers will be allocated from the internal network DHCP server for your virtual machine. This problem leads to domain connectivity issues from instance counterpart.

To solve this issue, first stop the instance and go to Project -> Network -> Networks and edit the proper subnet by hitting the Subnet Details button.

Add the required DNS name servers, save the configuration, start and connect to the instance console to test if the new configuration has been applied by pinging a domain name. Use the following screenshots as a guide.

Shutdown Instance
Shutdown Instance
Modify Instance Network Subnet
Modify Instance Network Subnet
Add DNS Servers to Instance
Add DNS Servers to Instance
Check Instance Network Connectivity
Check Instance Network Connectivity

In case you have limited physical resources in your infrastructure and some of your instances refuse to start, edit the following line from nova configuration file and restart the machine in order to apply changes.

# vi /etc/nova/nova.conf

Change the following line to look like this:

ram_allocation_ratio=3.0
Configure Physical Resources in Nova Configuration
Configure Physical Resources in Nova Configuration

That’s all! Although this series of guides just scratched the surface of OpenStack mammoth, now you have the basic knowledge to start create new tenants and use real Linux OS images in order to deploy virtual machines in your own OpenStack cloud infrastructure.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Matei Cezar
I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

12 thoughts on “How to Create, Deploy and Launch Virtual Machines in OpenStack”

  1. Hello,

    Followed your guide but:

    Error: External network 7ecdd64f-2e91-41d1-b177-46fa7940ea87 is not reachable from subnet f8258c5d-32a3-441d-9e73-a13cd0ab9d81. Therefore, cannot associate Port 3daa43d5-47e0-40e5-bcdd-33f220b39580 with a Floating IP. Neutron server returns request_ids: [‘req-b322718e-56be-4d38-bbe2-bd98d74db8b6’]

    Error: Unable to associate IP address 192.168.176.8.

    Any ideas?

    Reply
  2. Can not create image under test user but only using root. Server error – OpenStack Dashboard

    Something went wrong! An unexpected error has occurred. Try refreshing the page. If that doesn’t help, contact your local administrator.

    Reply
  3. I followed your tutorial to get set up openstack mitaka.

    I create a vm but if I click log here is the error message it gives me Unable to retrieve the log for instance “b2c8fbea-c063-4737-a886-521456f92dbd”.
    help me

    Reply
    • @Sanya,

      Please check with the following command that compute node as enabled and up.

      # nova service-list
      

      If its down, you need to restart the nova-compute service on the compute node and make sure that networking from controller to compute node configured properly. Can you able to ping controller node from compute node?

      Also make that libvirt is up on compute node.

      Reply
  4. Hello, thanks for your tutorial, but i have only question, when we are selecting the network for the instances we must select the “external network” ? (Of course what i want to test is external access but when i select the external network on my log i can see a message like this ” ExternalNetworkAttachForbidden: It is not allowed to create an interface on external network “) but if i select internal net when i am creating the instance there is no error but i can’t access to my instance from lan :(

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.