Skip to content

Instantly share code, notes, and snippets.

@gnuoy
Created November 10, 2022 12:50
Show Gist options
  • Save gnuoy/244f6c3179e88b237cefe7a48011367d to your computer and use it in GitHub Desktop.
Save gnuoy/244f6c3179e88b237cefe7a48011367d to your computer and use it in GitHub Desktop.
Key Value
Summary Install and run OpenStack on Linux in minutes, using the next generation of MicroStack.
Categories cloud
Difficulty 3
Authors Tytus Kurek tytus.kurek@canonical.com , Liam Young liam.young@canonical.com

Overview

Duration: 1:00

What is OpenStack?

OpenStack is a collection of open source projects designed to work together to form the basis of a cloud. OpenStack can be used for both private and public clouds.

What is MicroStack?

MicroStack provides a single or multi-node OpenStack deployment which can run directly on your workstation. Although made for developers to prototype and test, in the near future it will also be suitable for edge, IoT, and appliances. MicroStack is an OpenStack in a snap which means that all OpenStack services and supporting libraries are packaged together in snaps which can be easily installed, upgraded or removed.

In this tutorial you will learn how to:

  • Get a single-node OpenStack cloud up and running with MicroStack
  • Interact with OpenStack via the web UI and CLI
  • Launch your first VM on OpenStack and access it

You will need:

  • A machine running Linux, a multi-core processor and at least 8 GB of RAM

MicroStack has been tested on a physical machine running either Ubuntu 20.04 LTS or Ubuntu 22.04 LTS.

Originally authored by Tytus Kurek

Install MicroStack

Duration: 10:00

Install MicroStack from the beta channel:

sudo snap install microk8s --channel 1.25-strict/stable
sudo microk8s status --wait-ready
sudo microk8s enable dns hostpath-storage
sudo microk8s enable metallb 10.20.20.1/29

If you are using an older Ubuntu version or some other Linux distribution, you may have to install snapd first. Refer to snapd documentation for more information on installing snapd on your computer.

When the last command has completed give your user permissons to use microk8s:

sudo usermod -a -G snap_microk8s ubuntu
sudo chown -f -R ubuntu ~/.kube
newgrp snap_microk8s

Install Juju:

sudo snap install juju --channel 3.0/edge

Now it is time to install the microstack snap from the sunbeam channel:

sudo snap install microstack --devmode --channel sunbeam/beta

To enable the microstack snap to interact with juju connect them together:

sudo snap connect microstack:juju-bin juju:juju-bin

The control plane will be running inside microk8s but the hypervisor runs outside in its own snap, so install the hypervisor snap:

sudo snap install --channel xena/edge openstack-hypervisor

Note that at the time of writing this tutorial, the installed version of OpenStack was Xena.

Being a snap, MicroStack is published in channels which are made up of a track (or a major version), and an expected level of stability. You can run snap info microstack command to see which versions are currently available.

Initialise MicroStack

Duration: 20:00

MicroStack needs to be initialised, so that networks and databases get configured. To do this, run:

microstack bootstrap

Once this completes (15 - 20 minutes) your OpenStack cloud will be up and running!

At this point images, flavors, networks can be manually setup using the standard OpenStack client commands or microstack configure can do some basic setup for you.

microstack configure

During the configure step microstack will ask a few straight forward questions and then produce credentials that can be used to access the cloud either via the command line or the web UI.

Interact with OpenStack

Duration: 4:00

Admin Credentials

The microstack configure step provides normal user credentials but if admin credentials are required then these can be obtained:

juju run -m openstack keystone/leader get-admin-account

Web UI

To get the address of the webUI

juju status -m openstack horizon | grep -EA1 '^App\s'
App      Version  Status  Scale  Charm        Channel    Rev  Address        Exposed  Message
horizon           active      1  horizon-k8s  xena/edge   10  10.152.183.41  no       

In this case the IP address of the service is 10.152.183.41 so to interact with the webUI visit http://10.152.183.41/openstack-horizon

Type in credentials and press the "Sign In" button:

OpenStack login page

If everything goes fine you should see the landing page:

OpenStack landing page

You can now start playing with your OpenStack installation (i.e. create additional users, launch instances, etc.).

CLI

You can also interact with your OpenStack cloud via the CLI by using the standard openstack commands. For details on the syntax see python-openstackclient package. To install the openstack cli tools:

sudo snap install openstackclients

The client can now be used to interact with microstack. Using the credentials created earlier, to list available OpenStack endpoints run:

openstack catalog list

Launch and access a VM

Duration: 5:00

The following assumes that the default setup was applied using microstack configure


Test launch

To launch your first OpenStack instance (VM) called "test" based on the CirrOS image, run the following:

openstack keypair create --public-key /home/ubuntu/.ssh/id_rsa.pub mykey

Next launch a server:

openstack server create --image ubuntu-jammy --flavor m1.small --key-name mykey --network demo-network test-server --wait

To access the server it needs to have an external IP address assigned, so the next step is to create one and assign it to the server: Note that the floating IP address creeateed may be different in your environment.

openstack floating ip create external-network
openstack server add floating ip test-server 10.20.20.57

In order to connect to the instance run the command from the output:

ssh -i /home/ubuntu/.ssh/id_rsa.pub ubuntu@10.20.20.57

Now that you are connected to the instance you can use normal Linux commands:

$ uptime
 14:51:42 up 4 min,  1 users,  load average: 0.00, 0.00, 0.00

To disconnect from the instance, type exit (or Ctrl-d).

Next steps

Learn more by reading the MicroStack documentation. The clustering feature is particularly interesting.

That’s all folks!

Duration: 1:00

Congratulations! You have made it!

You may wish to temporarily disable your MicroStack installation when not in use. To do so, run:

sudo snap disable microstack

To re-enable it, run:

sudo snap enable microstack

Where to go from here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment