Tear down your OpenStack lab environment

Key Value
Summary Tear down your OpenStack lab environment.
Categories openstack
Difficulty 1
Author Tytus Kurek tytus.kurek@canonical.com

Overview

Duration: 3:00

Before you get started!

Welcome to OpenStack!

In this series of tutorials, we will walk you through all the necessary steps to install, configure and get started with OpenStack. Using just a single machine, you will learn how to use OpenStack for cloud infrastructure implementation purposes, from a single-node installation to large-scale clusters.

This tutorial is the twelfth in the ā€œPhase I - Learn OpenStackā€ series.

Explore other tutorials >

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 cloud implementation.

What is Sunbeam?

Sunbeam is an upstream project under the governance of the OpenInfra Foundation (OIF), which was created to lower the barrier to entry for OpenStack, simplify its adoption process, and set the foundation for an autonomous private cloud. Sunbeam uses cloud-native architecture and total bottom-up automation to make OpenStack more accessible to newcomers and to help users get to grips with the platform immediately.

What is MicroStack?

MicroStack (based on Sunbeam) is an OpenStack distribution designed for small-scale cloud environments. While it is available with full commercial support from Canonical, it can also be self-deployed with no friction, effectively eliminating the need for a paid consulting engagement. MicroStack currently includes core OpenStack services only, but is expected to evolve quickly to ensure full feature parity with Canonicalā€™s Charmed OpenStack soon.

In this tutorial, you will learn how to:

  • Stop and start Sunbeam
  • Disable and enable Sunbeam
  • Uninstall Sunbeam

You will only need:

One fresh physical or virtual machine with:

Stop and Sunbeam

Duration: 5:00

Sunbeam can be stopped when not being used and started when needed again.

To stop Sunbeam, execute the following commands:


$ sudo snap stop microk8s
$ sudo snap stop openstack-hypervisor

To start Sunbeam, execute the following command:


$ sudo snap start openstack-hypervisor
$ sudo snap start microk8s

Disable and enable Sunbeam

Duration: 5:00

Sunbeam is set to start automatically on a reboot.

To disable Sunbeam, execute the following commands:


$ sudo snap disable microk8s
$ sudo snap disable openstack-hypervisor

To enable Sunbeam, execute the following command:


$ sudo snap enable microk8s
$ sudo snap enable openstack-hypervisor

Uninstall Sunbeam

Duration: 5:00

In case you no longer need it, you can completely uninstall Sunbeam.

To uninstall Sunbeam, execute the following commands:


$ sudo snap remove --purge microk8s 
$ sudo snap remove --purge juju 
$ sudo snap remove --purge openstack
$ sudo snap remove --purge openstack-hypervisor
$ sudo /usr/sbin/remove-juju-services
$ sudo rm -rf /var/lib/juju
$ rm -rf ~/.local/share/juju
$ rm -rf ~/snap/openstack
$ rm -rf ~/snap/openstack-hypervisor
$ rm -rf ~/snap/microstack/
$ rm -rf ~/snap/juju/
$ rm -rf ~/snap/microk8s/
$ sudo init 6

Next steps

Duration: 2:00

Congratulations! You have reached the end of this tutorial and the end of the ā€œPhase I - Learn OpenStackā€ series.

In this tutorial, you have learnt how to:

  • Stop and start MicroStack
  • Disable and enable MicroStack
  • Uninstall MicroStack

Where to go from here?

2 Likes

Hi, I followed the instructions on this page and the instructions on how to install the basic sunbeam openstack on one node (not guided). However, after trying to install openstack with the ā€œsunbeam cluster bootstrapā€ command once more I encountered an error. This is what the error is saying:

Sunbeam Cluster not initialized
Error bootstrapping Juju
Traceback (most recent call last):
  File "/snap/openstack/182/lib/python3.10/site-packages/sunbeam/commands/juju.py", line 228, in run
    process = subprocess.run(cmd, capture_output=True, text=True, check=True)
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/snap/openstack/182/juju/bin/juju', 'bootstrap', 'sunbeam', 'sunbeam-controller']' returned non-zero exit status 1.
Creating Juju controller "sunbeam-controller" on sunbeam/default
Looking for packaged Juju agent version 3.2.0 for amd64
Located Juju agent version 3.2.0-ubuntu-amd64 at https://streams.canonical.com/juju/tools/agent/3.2.0/juju-3.2.0-linux-amd64.tgz
ERROR failed to bootstrap model: machine is already provisioned

Error: Command '['/snap/openstack/182/juju/bin/juju', 'bootstrap', 'sunbeam', 'sunbeam-controller']' returned non-zero exit status 1.

I found the way to resolve the issue: reinstall the operating system. Nevertheless, I believe there is a better way to resolve this issue. Thanks in advance

Hi @leozaur1808, thanks for trying this out. At the moment a crucial step is missing, but something better is coming.

Instead of reinstalling the operating system, you can execute as root /usr/sbin/remove-juju-services. That should do the trick.

1 Like

Hi @gboutry thank you for your response. Unfortunately, the command still fails when bootstrapping Juju on to the machine. I tried my best to summarize the output since it is very long.
Here are the errors that I extracted from the output:

  • subprocess.CalledProcessError: Command ā€˜[ā€™/snap/openstack/182/juju/bin/jujuā€™, ā€˜bootstrapā€™, ā€˜sunbeamā€™, ā€˜sunbeam-controllerā€™]ā€™ returned non-zero exit status 1.
  • ERROR creating controller database schema: table lease_type already exists
  • ERROR failed to bootstrap model: subprocess encountered error code 1
  • Error: Command ā€˜[ā€™/snap/openstack/182/juju/bin/jujuā€™, ā€˜bootstrapā€™, ā€˜sunbeamā€™, ā€˜sunbeam-controllerā€™]ā€™ returned non-zero exit status 1.

It seems like the database is not removed completely.

Hi @gboutry, I see the same error as @leozaur1808.

After a failed install of OpenStack, I attempted to follow the instructions to remove it, including the /usr/sbin/remove-juju-services step; however, I still see the same error.

ERROR creating controller database schema: table lease_type already exists
ERROR failed to bootstrap model: subprocess encountered error code 1

Error: Command '['/snap/openstack/182/juju/bin/juju', 'bootstrap', 'sunbeam', 'sunbeam-controller']' returned non-zero exit status 1.

Here is my set of ā€œcompletely clean and resetā€ instructions that Iā€™ve been using. Might be overdone, but I have been able to re-install multiple times without issue.

sudo snap remove --purge microk8s 
sudo snap remove --purge juju 
sudo snap remove --purge openstack
sudo snap remove --purge openstack-hypervisor
sudo /usr/sbin/remove-juju-services
sudo rm -rf /var/lib/juju
rm -rf ~/.local/share/juju
rm -rf ~/snap/openstack
rm -rf ~/snap/openstack-hypervisor
rm -rf ~/snap/microstack/
rm -rf ~/snap/juju/
rm -rf ~/snap/microk8s/
sudo init 6

the removals of ~/snap dirs are redundant if you use the --purge option at snap remove time ā€¦ they should be fully cleaned alongside in that case (else it would be a snapd bug)

I have updated the tutorial as per @mbeierlā€™s feedback for now. In general, I think that we need a better tear-down story compared to what we have today. Iā€™ll discuss that with the team.

I think Iā€™ve got a snapd bug:

osm-hackfest1@osm-hackfest1:~$ sudo snap remove juju --purge
juju removed
osm-hackfest1@osm-hackfest1:~$ ls -al snap/
total 32
drwxr-xr-x  8 osm-hackfest1 lxd             4096 May 28  2021 .
drwxr-xr-x 22 osm-hackfest1 ubuntu-template 4096 Jul  7 20:22 ..
drwxr-xr-x  4 osm-hackfest1 ubuntu-template 4096 Mar  5  2021 jq
drwxr-xr-x  2 osm-hackfest1 ubuntu-template 4096 Jul  7 20:25 juju

I realized that I did not specify to destroy the model first, which would give a much nicer cleanup story. I donā€™t think the reboot is needed if you do that. If you do this procedure as described without removing the model first, yes the software is removed, but the containers may continue to live onā€¦ I know the cali network interfaces certainly will.

yup, smells very like it ā€¦ ubuntu-bug snapd :wink:

1 Like