MicroStack is a single-machine, snap-deployed OpenStack cloud. Here are some MicroStack common commands. OpenStack commands can be executed in MicroStack by accessing the Snap Container.
Setup
Check Available Versions
sudo snap info microstack
...
channels:
latest/stable: –
latest/candidate: –
latest/beta: ussuri 2021-05-01 (233) 405MB -
latest/edge: ussuri 2021-09-07 (237) 422MB -
rocky/stable: –
rocky/candidate: –
rocky/beta: –
rocky/edge: rocky 2019-12-06 (195) 398MB classic
Install MicroStack Snap
sudo snap install microstack --devmode --beta
microstack (beta) ussuri from Canonical✓ installed
Automatic MicroStack initial setup (Single node: Control and Compute)
sudo microstack.init --auto --control
Custom MicroStack initial setup, for clustering (Define as Control or Compute Node)
sudo microstack.init
Would you like to configure clustering? (yes/no) [default=no] > yes
Which role would you like to use for this node: "control" or "compute"? >
Servers/VMs
List Servers
sudo microstack.openstack server list
+--------------------------------------+----------+--------+-----------------------------------+---------------+-------------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+----------+--------+-----------------------------------+---------------+-------------+
| f19d07f9-e58e-4c54-9a51-f66ada3f367a | ddpt-1 | ACTIVE | test=192.168.222.69, 10.20.20.196 | ubuntu-bionic | ddpt.xlarge |
+--------------------------------------+----------+--------+-----------------------------------+---------------+-------------+
Start Server by ID (or by name)
sudo microstack.openstack server start f19d07f9-e58e-4c54-9a51-f66ada3f367a
Stop Server by Name (or by ID)
sudo microstack.openstack server stop ddpt-1
Images
MicroStack container only has access to users home directory, to avoid problems execute commands from the folder the image is located at.
Upload Cloud Image
sudo microstack.openstack image create "ubuntu-bionic" \
--container-format bare \
--disk-format qcow2 \
--public \
--file ./bionic-server-cloudimg-amd64.img
List images
sudo microstack.openstack image list
Download image/snapshot (Create first using Horizon)
sudo microstack.openstack image save --file herd_proto-compute.raw 785be5ff-cc9b-4afa-99a6-3f5f72182c79
Upload Snapshot
sudo microstack.openstack image create "herd-compute" \
--container-format bare \
--disk-format qcow2 \
--public \
--file ./herd_compute.raw
Flavors
List Flavors
sudo microstack.openstack flavor list
+--------------------------------------+-------------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+-------------+-------+------+-----------+-------+-----------+
| b6198a8d-3167-49f7-aa6a-7600757226fe | ddpt.xlarge | 32768 | 80 | 0 | 16 | True |
+--------------------------------------+-------------+-------+------+-----------+-------+-----------+
Create flavor
sudo microstack.openstack flavor create --ram 2048 --disk 16 --vcpus 1 herd.tiny
sudo microstack.openstack flavor create --ram 4098 --disk 20 --vcpus 2 herd.small
sudo microstack.openstack flavor create --ram 4098 --disk 28 --vcpus 4 herd.xsmall
sudo microstack.openstack flavor create --ram 8196 --disk 28 --vcpus 4 herd.medium
sudo microstack.openstack flavor create --ram 8196 --disk 64 --vcpus 4 herd.xmedium
sudo microstack.openstack flavor create --ram 16392 --disk 44 --vcpus 8 herd.large
sudo microstack.openstack flavor create --ram 32784 --disk 76 --vcpus 16 herd.xlarge
sudo microstack.openstack flavor create --ram 65568 --disk 140 --vcpus 32 herd.xxlarge
sudo microstack.openstack flavor create --ram 1024 --disk 12 --vcpus 2 herd.base
Key Management
MicroStack will automatically create a base key, used by all machines when no key is specified.
Create key
$ ssh-keygen -f herd-key
Import existing .pub key
sudo microstack.openstack keypair create --public-key herd-key.pub herd-key
List keys
sudo microstack.openstack keypair list
Launching
In MicroStack, always used the provided private network named test.
Launch instance from MicroStack, will create new key “microstack” and floating IP
sudo microstack.launch -n "test" \ #vm name
-f m1.small \ #flavor
herd_proto-compute #image name
Launch instance from MicroStack, with provided key named “herd-key”, will generate floating IP
sudo microstack.launch -n "proto" \
-f m1.small \
-k herd-key \ #key name
ubuntu-bionic
Launch instance from MicroStack, with provided private network named “test”
sudo microstack.launch -n "test-2" \
-f herd.small \
-t test \ #network
-k herd-key \
herd_proto-compute
Network Management
sudo microstack.openstack network list
+--------------------------------------+----------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+----------+--------------------------------------+
| 1b3cc495-a3b8-47bb-ad43-4cbde181b9c6 | test | 23dcfed8-a3cd-4739-850f-2176a1593b73 |
| 2322b312-c5e8-455d-ba44-fa2a807bdd62 | external | 9e06abb6-9073-475e-b660-52850215c8c4 |
+--------------------------------------+----------+--------------------------------------+
Selecting Availability Zone when Clustering
In MicroStack
sudo microstack.launch -n "herd-1" \
-f herd.small \
-t test \
-k herd-key \
--availability-zone nova:aegonar-g750jx \ #hostname of a compute node
herd-compute
In OpenStack
openstack server create \
--flavor herd.small \
--nic net-id=6db59ff5-9724-490d-a899-6c47c4fb42e4 \
--key-name microstack \
--availability-zone nova:aegonar-asus \ #hostname of a compute node
--image ubuntu-bionic \
"test-2"
Cloud Init
cloud-init is a software package that automates the initialization of cloud instances during system boot. You can use cloud-init to run scripts to configure the VM at creation time.
sudo microstack.openstack server create \
--flavor herd.xmedium \ #VM flavor/config
--network test \ #private network
--key-name herd-key \ #key
--availability-zone nova:aegonar-g750jx \ #compute node hostname
--image ubuntu-bionic \ #image
--user-data image_setup.sh \ #cloud-init script
"herd-proto" #VM name
Accessing MicroStack Snap Container
Access MicroStack’s OpenStack shell
$ sudo snap run --shell microstack.init
$ source $SNAP_COMMON/etc/microstack.rc
# edit this file if Horizon password has been changed^
root@aegonar-asus:/var/snap/microstack/common#
Troubleshooting
Manage services inside the MicroStack Snap container from outside (all nodes):
#For OpenStack Stein:
sudo service snap.microstack.external-bridge restart;
sudo service snap.microstack.glance-api restart;
sudo service snap.microstack.horizon-uwsgi restart;
sudo service snap.microstack.keystone-uwsgi restart;
sudo service snap.microstack.libvirtd restart;
sudo service snap.microstack.memcached restart;
sudo service snap.microstack.mysqld restart;
sudo service snap.microstack.neutron-api restart;
sudo service snap.microstack.neutron-dhcp-agent restart;
sudo service snap.microstack.neutron-l3-agent restart;
sudo service snap.microstack.neutron-metadata-agent restart;
sudo service snap.microstack.neutron-openvswitch-agent restart;
sudo service snap.microstack.nginx restart;
sudo service snap.microstack.nova-api-metadata restart;
sudo service snap.microstack.nova-api restart;
sudo service snap.microstack.nova-compute restart;
sudo service snap.microstack.nova-conductor restart;
sudo service snap.microstack.nova-scheduler restart;
sudo service snap.microstack.nova-uwsgi restart;
sudo service snap.microstack.ovs-vswitchd restart;
sudo service snap.microstack.ovsdb-server restart;
sudo service snap.microstack.rabbitmq-server restart;
sudo service snap.microstack.registry restart;
sudo service snap.microstack.virtlogd restart;
If Cinder/Horizon is high CPU, from the Control node, reconfigure Nova DB (from snap shell):
sudo snap run --shell microstack.init
source $SNAP_COMMON/etc/microstack.rc
nova-manage db sync
exit
Restart Services
#on compute nodes
sudo systemctl restart "snap.microstack.nova-*"
sudo systemctl stop "snap.microstack.cinder-*"
#on control nodes
sudo systemctl restart "snap.microstack.horizon-*"
If Cinder CPU usage is still high:
sudo systemctl stop "snap.microstack.cinder-*"