Key | Value |
---|---|
Summary | Run OpenStack on Kubernetes in minutes with MicroStack and Sunbeam. |
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 cloud implementation.
What is MicroStack?
MicroStack is an OpenStack flavour designed for the edge and small-scale data centre deployments, that can be installed and maintained with minimal effort. MicroStack abstracts the complexity behind OpenStack, providing an opinionated approach to its architecture design and straightforward installation instructions.
What is Sunbeam?
Sunbeam is a collection of libraries for writing Kubernetes operators for OpenStack services. Together with MicroStack, Sunbeam delivers distilled OpenStack excellence with native K8s experience.
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 amd64 processor and at least 8 GB of RAM
- The machine will require a free network interface if access to VMs from other hosts on the network is required
MicroStack has been tested on a physical machine running either Ubuntu 20.04 LTS or Ubuntu 22.04 LTS.
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.
Install MicroStack (QuickStart)
Duration: 20:00
These instructions outline how to install microstack with no customisation.
Prerequisites:
- Server can query 8.8.8.8 for dns. If this is not the case then please follow the instructions in the " Install MicroStack (Configurable)" section.
sudo snap install microstack --channel sunbeam/beta
microstack install-script | bash -x
â VM Access
Using this method any VM launched in OpenStack will only be accessable via the host on which microstack has been installed.
Microstack is now installed and configured. See the âInteract with OpenStackâ section for next steps.
Install MicroStack (Configurable)
Install Microk8s
Duration: 10:00
Install the microk8s
snap:
sudo snap install microk8s --channel 1.25-strict/stable
sudo microk8s status --wait-ready
Configure microk8s dns.:
â DNS
The IP addresses to use for DNS resolution (here8.8.8.8
and8.8.4.4
) should be changed if the server does not have access to these.
sudo microk8s enable dns:8.8.8.8,8.8.4.4
Configure microk8s storage:
sudo microk8s enable hostpath-storage
Configure loadbalancer:
â MetalLB
The range of IP addresses in thesudo microk8s enable metallb
command (here10.20.21.1-10.20.21.10
) should come from the same subnet as your primary network interface if you want to access the OpenStack APIs from another machine. Please reserve at least 10 IP addresses in the range you specify.
sudo microk8s enable metallb 10.20.21.1-10.20.21.10
When the last command has completed give your user permissons to use microk8s:
sudo usermod -a -G snap_microk8s $USER
sudo chown -f -R $USER ~/.kube
newgrp snap_microk8s
Prevent microk8s from restarting:
touch /var/snap/microk8s/current/var/lock/no-cert-reissue
Install Juju
sudo snap install juju --channel 3.1/stable
mkdir -p .local/share
Install Microstack and hypervisor snaps
Now it is time to install the microstack
snap from the sunbeam
channel:
sudo snap install microstack --channel sunbeam/beta
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 yoga/beta 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
If this command results in an error, refer to the âCollecting debug informationâ part of this tutorial for more information.
Once this completes (15 - 20 minutes) your OpenStack cloud will be up and running!
The next step microstack configure
will setup networking to the guests and setup OpenStack artifacts like images, flavors and networks. There are two options for accessing guests local or remote. If local is chosen then access to the guests is only possible via the host that microstack is installed on. If remote is chosed then access to guests is only possible from other hosts on the same network and not from the host microstack is installed on. In addition, if remote is chosen then microstack will require a second interface which it can configure for remote access.
microstack configure -o demo_openrc
Once the confiugation step completes microstack with place credentials into the demo_openrc
file 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:
microstack openrc > admin_openrc
Web UI
To get the address of the webUI
juju status -m openstack 2>/dev/null | grep horizon | head -n 1 | awk '{print $9}'
http://10.20.20.2:80/openstack-horizon
So to interact with the webUI visit http://10.20.20.2:80/openstack-horizon
Log in using credentials from the demo_openrc
file. For example:
User Name: demo
Password: ********
Domain: users
If everything goes fine you should see the landing page:
You can now start managing your OpenStack cloud (e.g. 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.
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 Ubuntu image, run the following:
Set environment variables with access information:
source demo_openrc
Upload the an public key to use for accessing guests.
openstack keypair create --public-key /home/$USER/.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 created may be different in your environment.
fip=$(openstack floating ip create external-network -f value -c floating_ip_address)
openstack server add floating ip test-server ${fip}
In order to connect to the instance run the command from the output:
ssh -i /home/$USER/.ssh/id_rsa ubuntu@${fip}
â VM Access
Remember where the VM can be accessed from depends on the choice or remote or local during the configuration phase.
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
).
Collecting debug information
If there are any problems with installing and configuring microk8s see Microk8s Troubleshooting Guide
If the microstack bootstrap
or microstack configure
steps fails the try running them again with the -v
flag. The output from this can then be included when raising a bug.
e.g.
microstack -v bootstrap
The deployment information below will be useful when diagagnosing any issues.
To collect the Juju overview of the control plane deployment and Juju logs from the deployment:
microstack inspect
Status of the pods:
microk8s.kubectl describe -n openstack pods > pods.txt
Status of microk8s:
microk8s.status > microk8s_status.txt
To collect information from a specific OpenStack service the logs for the service can be collected directly from the container. For example to collect the glance logs:
juju ssh --model openstack --container glance-api glance/0 "tar cvf /tmp/glance-logs.tar var/log"
juju scp --model openstack --container glance-api glance/0:/tmp/glance-logs.tar ./glance-logs.tar
Next steps
Learn more by reading the MicroStack documentation.
Thatâs all folks!
Duration: 1:00
Congratulations! You have made it!
Where to go from here?
- Something broken? Report a bug
- Liked snaps? Try MicroK8s
- Install OpenStack with Juju: Charmed OpenStack