Resizing Instances
When working with your instance you might get to the point where you need more resources for your services running within your instance. Since tearing down your instance and setting everything up in a new and larger instance is not always an option, OpenStack provides a way to change the flavor of an running instance.
Changing the flavor
The actual process of changing an instance's flavor depends on whether or not you are using a regular flavor or a flavor that passes through a PCIe device like a GPU.
Regular flavors
If you are using regular flavors you can simply change them either via the web dashboard or the CLI
Head over to Project Compute Instances. Here select Resize Instance from the Actions dropdown of the instance you want to change the flavor of.
In the following dialog select the flavor you want to change to and confirm your choice with the Resize
button. This dialog will also show you the current quota usage and upon selecting a new flavor the impact
on the quota after the resize.
After the resize has been completed you need to confirm the change. For this simply click the Confirm Resize/Migrate button that is now shown in the Actions column.
If you have not set up CLI access before, follow this guide and then return here. To resize
an instance via CLI use the openstack server resize
command as follows.
- You can find a list of available flavors with the
openstack flavor list
command - Add the
--wait
flag so you do not need to manually check when the resize has completed
When the instance was successfully resized to the new flavor you need to run the command below to finish the process.
Flavors with PCIe devices
Unfortunately instances that use flavors with PCIe devices cannot simply be resized. You basically have two options on how to change to another flavor while retaining your data.
Option A: Using a Snapshot
Note
Snapshots are a shallow clone of the instances' volume they are created of. Therefore when making use of snapshots you will not be able to delete volumes that have snapshots associated with them.
To create a snapshot navigate to the instance overview (Project Compute Instances) and click the Create Snapshot button next to the instance you want to change the flavor of.
In the following dialog name your snapshot and confirm.
You will automatically be redirected to the Image overview afterwards. Here find your newly created snapshot
and click the Launch
button.
This will open up the instance creation dialog. Here enter the instance details as usual, the source will automatically be set to the previously created snapshot.
Option B: Spawning from previous volume
Note
This only works when you did NOT check the option Delete Volume on Instance Delete when you created your instance. If you did check this option, do NOT use this option, as you will loose the instance's data otherwise! We will NOT help recover your data!
To find out whether the volume is deleted on instance deletion use the CLI command openstack server show <instance_name>
.
In the output look for the volumes_attached
key, here you will either see delete_on_termination='True'
or delete_on_termination='False'
. Only continue when the value is False
!
Before deleting the instance, take note of the instances' root volume name. You can find out the name (usually a UUID) by navigating to Project Volumes Volumes. Here you will find a list of all volumes and their mount points. You are looking for an entry in the Attached To column.
Look for a mount point of /dev/sda
followed by your instances' name. Save the volume name for later.
Afterwards, you can go and delete the instance you want to re-create with a larger flavor. When the instance
has been deleted continue creating a new one as usual, except when selecting the Source. Instead of selecting
Image for Select Boot Source you want to select Volume.
Now move up the volume you noted the name of earlier and continue creating the instance as usual. Now just wait for the instance to be back online and re-attach the previous Floating IPs, if there were any attached.
Note
As cloud-init re-runs, you might need to remove the old SSH host keys from your .ssh/known_hosts
file. To
do so run the ssh-keygen -R <ip or hostname>
command.
Other
In general you can always backup your instances data and then launch a new instance with the desired flavor. The two options above are only examples that are possible with OpenStack directly.