Skip to main content

OpenStack: DevStack - Deploy a Single-Node OpenStack Playground with Heat Plugin, OpenStack CLI Commands

1343 words·
OpenStack DevStack OpenStack Heat Ubuntu
Table of Contents
OpenStack - This article is part of a series.
Part 1: This Article

Overview
#

I’m using a Ubuntu 22.04.3 VM, with LVM and an ext4 filesystem based on VMware Workstation. The VM 8 has CPU cores, 32 GB RAM and 200 GB Storage. Much less storage would have been enough though.

192.168.30.40 # Ubuntu 22.04.3 Serve
192.168.30.224/27 # Floating IP range for OpenStack VMs (192.168.30.224-192.168.30.255)
10.8.15.0/24 # Subnet for OpenStack VMs

Nested virtualization:

  • Make sure the “Virtualize Intel VT-x/EPT or AMD-V/RVI” option is enabled, in the “Virtual Machine Settings” > “Processor” section of the VM.

  • The following Windows features must be unchecked: Hyper-V, Windows Hypervisor Platform and Virtual Machine Platform. I happed to me that Windows Update enabled them.

Note: In the first view examples I have manually assigned a floating IP to the VM deployments. For the scripted version check out example “Heat Manifest with Cloud-Init based on Ubuntu”.


DevStack Installation
#

Prerequisites
#

# Install prerequisites
sudo apt install git -y

DevStack User
#

# Create a "stack" user for DevStack: With "/opt/stack" home directory
sudo useradd -s /bin/bash -d /opt/stack -m stack

# Change "stack" user home directory permissions
sudo chmod +x /opt/stack

# Add the "stack" user to sudo with the nopasswd option
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack

Install DevStack
#

Clone Git Repository
#

# Switch to "stack" user
sudo -u stack -i

# Clonde DevStack repository
git clone https://opendev.org/openstack/devstack.git /opt/stack/devstack && cd /opt/stack/devstack

local.conf File
#

An example for local.conf can be found here: /opt/stack/devstack/samples/local.conf

The following configuration is for a testing environment, the admin password is also used for the database, RabbitMQ and other OpenStack services. Feel free to define different passwords for each service.

The floating range is from 192.168.30.224 to 192.168.30.255 in the same subnet as the Ubuntu host itself.

# Create a local.conf file
vi local.conf
DevStack Default Installation
[[local|localrc]]
FLOATING_RANGE=192.168.30.224/27
FIXED_RANGE=10.8.15.0/24
ADMIN_PASSWORD=my-secure-password
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
DevStack with Heat Plugin
[[local|localrc]]
FLOATING_RANGE=192.168.30.224/27
FIXED_RANGE=10.8.15.0/24
ADMIN_PASSWORD=my-secure-password
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD

#Enable heat plugin
enable_plugin heat https://opendev.org/openstack/heat

Install DevStack
#

# Start the DevStack installation: (This takes a while)
./stack.sh
# Shell output:
This is your host IP address: 192.168.30.40
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.30.40/dashboard
Keystone is serving at http://192.168.30.40/identity/
The default users are: admin and demo
The password: my-secure-password

DevStack Overview
#

Horizon Webinterface
#

# Access the DevStack / Horizon webinterface
http://192.168.30.40/dashboard

# Default user
admin

# Password as defined in local.conf

Services Overview
#

  • Keystone OpenStack authentication

  • Glance: Image service for OpenStack. Discovery, registration, and delivery services for disk and server images.

  • Nova: Primary computing engine behind OpenStack. Provision and managing of virtual machines and other instances to handle computing tasks.

  • Placement: Service that tracks resource inventories and usages to assist Nova in making scheduling decisions, ensuring efficient allocation of compute resources such as CPU and RAM.

  • Cinder: Block storage service for OpenStack. Provides persistent block-level storage devices for use with OpenStack compute instances.

  • Neutron: Networking capability for OpenStack, including services such as defining networks, subnets, and routers, and enabling IPs, firewalls, and more.

  • Horizon: Horizon is the dashboard and the official web-based user interface for OpenStack.


Start & Stop DevStack
#

Stop DevStack
#

# CD into "stack" user home directory
cd ~/devstack

# Stop DevStack
./unstack.sh

Start DevStack
#

# Switch to "stack" user
sudo -u stack -i

# CD into "stack" user home directory
cd ~/devstack

# Start DevStack (This takes a while)
./stack.sh

OpenStack CLI
#

Source Openrc / Login
#

# Switch to "stack" user
sudo -u stack -i

# CD into "stack" home directory
cd ~/devstack

# Verify the openrc file
ls *openrc*

# Loads the environment variables set in openrc into current shell: Admin user & project
source openrc admin admin

Verify User & Project
#

# Output current user
echo $OS_USERNAME

# Output current project
echo $OS_PROJECT_NAME



OpenStack CLI Commands
#

Command Syntax
#

# CLI syntax
openstack [service] [action] [options]

# Command Help: Append "--help" to a command
openstack server create --help

List Resources
#

List VMs & VM Details
#

# List VMs
openstack server list

# List VM details
openstack server show vm-name

List Images & Volumes
#

# List ISO images
openstack image list

# Lists block storage volumes
openstack volume list

List Flavors
#

# List flavors
openstack flavor list

# Shell output:
+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 1  | m1.tiny   |   512 |    1 |         0 |     1 | True      |
| 2  | m1.small  |  2048 |   20 |         0 |     1 | True      |
| 3  | m1.medium |  4096 |   40 |         0 |     2 | True      |
| 4  | m1.large  |  8192 |   80 |         0 |     4 | True      |
| 42 | m1.nano   |   128 |    1 |         0 |     1 | True      |
| 5  | m1.xlarge | 16384 |  160 |         0 |     8 | True      |
| 84 | m1.micro  |   192 |    1 |         0 |     1 | True      |
| c1 | cirros256 |   256 |    1 |         0 |     1 | True      |
| d1 | ds512M    |   512 |    5 |         0 |     1 | True      |
| d2 | ds1G      |  1024 |   10 |         0 |     1 | True      |
| d3 | ds2G      |  2048 |   10 |         0 |     2 | True      |
| d4 | ds4G      |  4096 |   20 |         0 |     4 | True      |
+----+-----------+-------+------+-----------+-------+-----------+

Manage Servers (VMs)
#

# Start VM
openstack server start SERVER_ID

# Stop VM
openstack server stop SERVER_ID

# Delete VM
openstack server delete SERVER_ID

# List logs
openstack console log show SERVER_ID

SSH Keys
#

Create SSH Key
#

# Create SSH key: Syntax
openstack keypair create key-name > key-file

# Create SSH key: Example
openstack keypair create key_vm-1 > id_rsa_vm-1

# Change key permissions: Syntax
chmod 600 key-file

# Change key permissions: Example
chmod 600 id_rsa_vm-1

List & Delete SSH Keys
#

# List SSH keys
openstack keypair list

# Delete SSH key
openstack keypair delete key-name

Networking
#

Create Network & Subnet
#

# Create network
openstack network create network-name
# Create a subnet in for the network
openstack subnet create --network network-name --subnet-range 10.8.5.0/24 \
--allocation-pool start=10.8.5.11,end=10.8.5.254 --dns-nameserver 1.1.1.1 \
--gateway 10.8.5.1 subnet-name

List Networks & Subnets
#

# Lists networks
openstack network list

# List subnets
openstack subnet list

Delete Network & Subnet
#

# Delete the Subnet
openstack subnet delete subnet-name

# Delete the Network
openstack network delete network-name

Create Security Group
#

# Create a security group
openstack security group create jkw-sg-01

# Add Rule: Allow SSH
openstack security group rule create --proto tcp --dst-port 22 --remote-ip 0.0.0.0/0 jkw-sg-01

# Add Rule: Allow Ping
openstack security group rule create --proto icmp jkw-sg-01

List Security Groups
#

# List security groups
openstack security group list

# List security group of specific VM
openstack security group list --server vm-name

List Routers
#

# Verify routers
openstack router list

List Floating IPs
#

# List floating IPs
openstack floating ip list

Verify Hypervisor Status
#

# List hypervisors & status
openstack hypervisor list

# Shell output:
+--------------------------------------+---------------------+-----------------+---------------+-------+
| ID                                   | Hypervisor Hostname | Hypervisor Type | Host IP       | State |
+--------------------------------------+---------------------+-----------------+---------------+-------+
| e87f8c2e-6391-42a4-afed-453eae272418 | ubuntu-ds           | QEMU            | 192.168.30.40 | up    |
+--------------------------------------+---------------------+-----------------+---------------+-------+
# List hypervirsor details
openstack hypervisor show e87f8c2e-6391-42a4-afed-453eae272418

# Shell output:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| aggregates          | []                                   |
| cpu_info            | None                                 |
| host_ip             | 192.168.30.40                        |
| host_time           | 12:33:45                             |
| hypervisor_hostname | ubuntu-ds                            |
| hypervisor_type     | QEMU                                 |
| hypervisor_version  | 6002000                              |
| id                  | e87f8c2e-6391-42a4-afed-453eae272418 |
| load_average        | 0.35, 0.41, 0.36                     |
| service_host        | ubuntu-ds                            |
| service_id          | 793a5bc8-e9de-4094-9d65-7d03e65c9629 |
| state               | up                                   |
| status              | enabled                              |
| uptime              | 1:24                                 |
| users               | 3                                    |
+---------------------+--------------------------------------+

Links #

# Official Documentation
https://docs.openstack.org/devstack/latest/

# local.conf examples
https://docs.openstack.org/devstack/latest/_downloads/d6fbba8d6ab5e970a86dd2ca0b884098/local.conf
# OpenStack Heat Plugin
https://docs.openstack.org/heat/latest/getting_started/on_devstack.html
# Debian Cloud Images
https://cdimage.debian.org/images/cloud/

# RedHat Cloud Images
https://access.redhat.com/downloads/content/rhel
OpenStack - This article is part of a series.
Part 1: This Article