Skip to content

OpenStack Basics

Brandon Elam Barker edited this page Feb 26, 2019 · 2 revisions

Introduction to OpenStack

OpenStack is an open-source cloud stack (a collection of software which runs a cloud of Virtual Machines) that is currently running on Aristotle. Also, for more information, see the Official Documentation for OpenStack. This page is intended as a quick walk-through of the most-used features of OpenStack, so it is not comprehensive, but links to supporting documentation for more thorough explanations and advanced topics.

The Basic Idea

A cloud acts like a black box in which you can create virtual computers and access these computers remotely, or have them shut down (or altogether deleted) on-command. These computers are virtual machines (VMs), but in nearly all cases you can think of them as computers which aren't near you, which you have to access remotely. The cloud stack — OpenStack, for us — manages the creation, operation, maintenance, shut down, etc. of the VMs. We will introduce a few key OpenStack terms which will be referenced repeatedly:

Terminology

  • Volume: a collection of data but typically has the functionality of a formatted hard drive and can host a file system. It can be the root partition of a VM that can be booted, or could act like an extra disk that can be mounted by a VM. Volumes are charged for according to their size and for how long they are stored.
  • Snapshot: a copy-in-time (or state save) of a volume. If it is a bootable volume, this can be registered as an image. A snapshot is associated with a volume, so each snapshot is billed as a volume.
  • Image: an entity which corresponds to a bootable snapshot which has been registered as an image, which means you can ask the cloud controller to boot it up. As the registration is really just telling OpenStack that the snapshot can be made into a VM, an image is only billed for its underlying volume (i.e., the volume corresponding to the snapshot which was registered as the image). Images can be set for availability only within a given Aristotle project, or more generally.
  • Instance: an instantiation of an image, i.e., the VM you get when you request an image be booted. Instances are charged for the core-hours they are running: note that unless they are shelved in OpenStack, they are still billed even if you shut them down using shutdown functionality by logging into the VM itself because OpenStack doesn't release the hardware devoted to them — the cores and RAM — unless it is specifically told to release them (by shelving the instance).

You will mostly be working with instances, but understanding the terminology is necessary if you are to create and manage instances.

Resource Mangement

Web Interface

Much of the management of your images can be done via the web interface, where you log in with:

  • Username: this is your CAC username (which is likely your netID if you are a Cornell person, or specYYY if you are an external user)
  • Password: this is your CAC password (not the Cornell password associated with CIT services).

Once logged in, you can access the functionality to create volumes, make snapshots of your volumes, register images and launch instances.

CAC OpenStack Web Interface

Command-Line Interface (CLI)

A more powerful, but also more complex, method for accessing your instances is via the OpenStack CLI, which, when set up with the right credentials exposes the same functionality as the web interface via intuitive shell commands. For example, openstack image list will list the available images. Run openstack command help to get a list of available commands.

Instances

An instance corresponds to an underlying volume which has been registered as an image (remember that this means a snapshot of a volume has been made — which is, itself, a volume — and it's then been registered as an image). When you shut down that instance, it can be restarted, at which time you can also change the number of cores associated with that instance.

The instance_id of an instance persists through shutdowns and restarts. If you terminate your instance, by default the root volume will not be deleted unless you specifically select that it should during setup. To change this when launching the instance, go to the "Source" tab before launch and select Yes for "Delete Volume on Instance Delete" for the root volume.

Once an instance is set so that its volume is not deleted when the instance is terminated, obviously this can result in higher storage costs; the root volume will remain until you specifically delete it. For those volumes you no longer want, you can delete them through the "Volumes" tab of the OpenStack Web Interface, or else use the OpenStack CLI to delete them.

Types of Instances

These are the types of instances currently available on Aristotle OpenStack:

Launch an Instance

  1. Create a Key Pair
  2. Create a Security Group and be sure that you select the appropriate rule for connecting to your instance (SSH for Linux Instances and RDP for Windows Instances)
  3. Select "Launch Instance" on the top right side of the Instances page
  4. Under the "Details" tab:
    • Enter a name for your instance
    • Count is the number of identical instances you would like to create (typically 1).
      • Note that if you create multiple instances this way, the names will be identical with a dash and number added at the end.
      • For example, if you set Instance Name to "my_instance" and you set Count to 3, you would start instances named "my_instance-1", "my_instance-2", and "my_instance-3".
  5. On the "Source" tab:
    • You must Select Boot Source, which is described on the page as "the template used to create an instance."
      • It is generally a good idea to start with an image as the source, unless you want to create an instance from a pre-existing source.
      • For more information on the other options, see Creating an Image.
    • You can select a specific source under the "Available" list by selecting the up arrow on the right-hand side.
    • Get more details about the specific source by selecting the right-arrow on the left-hand side next to the name.
    • You will have the option to Create New Volume if you have selected either "Image" or "Instance Snapshot" as the source (default is "Yes"):
      1. Yes: If selected, a volume will be created to be the instance's root disk. You will have the options of extending the size of the volume beyond the image size, and keeping the volume when the instance is deleted (by selecting No in the Delete Volume on Instance Delete field).
        • Volume Size is the size of your root volume. The default number will match the size of the image you select, and can be increased.
        • Delete Volume on Instance Delete determines whether or not your root volume will be deleted when you terminate the instance. By default, this option is set to "No" to prevent accidental deletion of your data. However, if you do not intend to re-use the root volume, you could unintentionally incur excess storage usage. You can either delete the root volume manually later (it will show up in the list of volumes with the ID the same as the name), or select "Yes" on this option to automatically delete it when you terminate your instance later.
        • You can also customize the name of the volume under Device Name.
      2. No: If selected, the instance will boot off a root disk the same size as the image. The root disk will be deleted when the instance is deleted.
  6. The "Flavor" tab is where you select the VM configuration (number of cores and RAM).
    • You can select a configuration by selecting the up arrow on the right-hand side.
    • Get more details about the configuration by selecting the right-arrow on the left-hand side next to the name.
    • The "Total Disk" will show "0 GB" because the disk size will match the image you selected on the "Source" tab.
  7. For the "Networks" tab, two options are available:
    1. You can make the instance available on the public net. This is the simplest and most common selection.
    2. You can select your own private network, which has to be set up before you launch an instance.
  8. On the "Security Groups" tab, select the security group you already created.
  9. On the "Key Pairs" tab, select the key pair you already created.

Images

Creating an Image

This section details how to create images from existing resources such as instances and volumes. If you are looking to create an image from some other source, see the Upload an Image section.

From an Instance

Snapshots in OpenStack can be used like images, so the simplest way to create an image from an instance is to create a snapshot:

  1. Shut Off the instance
  2. Create a snapshot of the instance
  3. You will have to give the snapshot a name (this will be the name of your image)
  4. Wait for the snapshot to finish being created, and it will show up on the "Images" tab

You can now launch new instances or create a volume from the snapshot.

Note: You should not take a snapshot of a file system that's mounted. You will lose all the info that's still in Linux's write cache. So if you want to take a snapshot of the root file system, the OS cannot be running.

From a Volume

Create an image from the volume:

  1. Select "Upload Volume to Image" for the volume from the "Volumes" tab
  2. Give the image a name and select "Upload"
  3. Wait for the image to finish being created, and it will show up on the "Images" tab

You can now launch new instances from the image.

If you have a volume snapshot that you would like to create an image from, create a volume from the snapshot, then follow the above steps.

Upload an Image

Images can be uploaded if you already have an image file that you would like to use. For example, if you are unsatisfied with the stock image options available, you can Get Images from elsewhere. Images can be uploaded via the Web Interface:

  1. Go to the "Images" tab
  2. Select the "Create Image" option
  3. Give the image a name
  4. Select the file of the source image to upload
  5. Select "Raw" for the Format
  6. Optional: Select "Yes" under Protected to ensure that the image cannot be changed or deleted accidentally (this setting can be changed later)
  7. Select "Create Image"

Share an Image

If you are interested in sharing an image, please see the documentation on how to Share An Image In OpenStack.

Volumes

Create and Attach a Volume

Volume creation is useful or attaching a data volume or a volume with users' home directories to an instance, as it is often good to separate the concerns of an operating system and user data. This makes it relatively easy to switch operating systems and maintain the same data, and to archive the more important parts of the project (the data) if needed.

Create

  1. Go to the "Volumes" tab in the OpenStack Web Interface
  2. Click the "Create Volume" button
  3. Enter a name and size
  4. Click "Create Volume"

Attach

  1. Go to the "Volumes" tab in the OpenStack Web Interface
  2. On the "Actions' dropdown menu for the volume you want to attach, select "Manage Attachments"
  3. Select the instance you wish to attach to and click "Attach Volume"
    • Note that the device name specified is usually not important and not always adhered to

Once You Have Attached The Volume

For Linux
  1. Login to your instance
  2. Run lsblk to see which /dev/vdX is the likely candidate (for some character 'X')
  3. Follow the instructions for initializing and mounting your volume (replace vdb with the vdX discovered in the previous step)
For Windows
  1. Login to your instance
  2. Follow the instructions for initializing and mounting your volume

Snapshots

Snapshots of volumes (and of instances, in which case the volume is implicitly the root volume of the instance) create a state save of the existing volume, so you can easily get back to a certain state in the future. This is most useful for OS volumes to create safe checkpoints of working operating system configuration states. It may be less useful for larger data volumes; a more efficient solution might be to use ZFS snapshots on Linux Instances.

Snapshots can be created from the "Actions" dropdown menu. Note that if you are creating a snapshot of a root volume for an instance, it should not be running. You should first stop the instance, and then take the snapshot.

Clone this wiki locally