Images

From CAC Documentation wiki
Revision as of 18:39, 25 February 2019 by Pzv2 (talk | contribs) (→‎Share an Image)
Jump to navigation Jump to search

OpenStack Images can take several forms, but generally an image consists of a static copy of a virtual machine with an operating system with some amount of storage. Each project starts out with a few base Linux and Windows images from which instances can be created. Images can also be created or uploaded to OpenStack, and then used to launch instances.

Available Images

In OpenStack, there are several stock images from which you can easily launch new instances. Typically you will want to create an instance from one of these stock images. You can view the available images (once logged in) by going to the "Images" tab in the Web Interface.

You would only need to create/upload your own image if you are unhappy with the stock images available, or if you would like to make an image from one of your current instances (to easily launch new instances with the same software and data). Currently, we have images for:

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 by selecting "Shut Off Instance" for the instance from the Instances tab
  2. Create a snapshot of the instance by selecting "Create Snapshot" for 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 on Red Cloud, 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

You can share an image from your project with a collaborator in a different project in OpenStack cloud so you can both launch instances using the same image. As the owner of the image, you can revoke the sharing privilege at any time. You can also use these methods to share an image with yourself in other projects, just think of yourself as the collaborator.

Prerequisites:

  1. Both you and your collaborator need to use the OpenStack CLI
  2. You will need to know the project name or ID of your collaborator.

Share an Image With Another Project

  • Find the project ID of your collaborator. Run
openstack project list | grep <collaborator's project name>
and the first field of the output is the ID of your collaborator's project ID.
  • Find the ID of the image you want to share:
openstack image show <image name>
  • Share the image with your collaborator's project:
openstack image set --shared <image ID>
openstack image add project <image ID> <collaborator's project ID>
  • Verify the image is now shared. The status field should say pending until your collaborator accepts the image.
openstack image member list <image ID>
  • Give the ID of the shared image to your collaborator.

Share an Image with All Projects

  • Currently this action can only be performed by cloud administrators.
  • This generally shouldn't be done unless creating something that is a public resource that is intended to be used with any project.
  • Additionally, don't use such an image from a third party unless you trust the source.
 openstack image set --public <image ID>

Accept a Shared Image

  • Get the ID of the shared image from the owner. Make sure the owner has performed the steps in the Share an Image section above.
  • Accept the shared image:
openstack image set --accept <image ID>
  • Verify the image is now available to your project:
openstack image list
If the image is listed in the output, it should also appear in Openstack web console (Horizon).

Unshare an Image

  • An image's owner can see which projects have access to the image:
openstack image member list <image ID>
  • The owner can unshare an image like this:
openstack image remove project <image ID> <project ID>