如何将GlanceCloud映像添加到OpenStack

在本教程中,我们将看到如何将VM映像添加到Openstack Glance映像服务。假设您已经运行了Openstack安装程序,并且glance服务已在控制器节点上运行。

什么是Openstack Image Service?

Openstack的角度允许用户发现,注册和检索虚拟机映像。这些图像的默认保存位置 / var / lib / glance /图片/ 后端是一个文件。

Openstack映像服务还提供了REST API,使您可以查询虚拟机的映像元数据以获取实际映像。 通过映像服务提供的虚拟机映像可以存储在从简单文件系统到对象存储系统(例如OpenStack对象存储)的各种位置。

您是否要获得Glance图片?

获得与OpenStack兼容的虚拟机映像的最简单方法是下载别人已经创建的内容。大多数映像都包含一个支持SSH密钥对和用户数据注入的cloud-init软件包。

了解如何下载他人创建的内容以及如何为不同的操作系统添加映像。当然,您可以创建自己的图像,但是获取现成图像的速度更快。

默认登录凭证

下面是从不久后添加的映像创建的实例的默认登录用户名。

Debian: debian
Fedora: fedora
Ubuntu: ubuntu
RHEL: cloud-user
CentOS: centos
coreos: core
Arch Linux: arch
Gentoo: gentoo
OpenSUSE: root
Fedora CoreOS: core
Cirros:
    username: cirros
    Password: cubswin:)

例:

1.将Cirros Cloud图像添加到Glance

wget http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img

openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file cirros-0.5.1-x86_64-disk.img 
    Cirros-0.5.1

2.将Fedora云映像添加到Openstack

wget http://fedora.mirror.liquidtelecom.com/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2
openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file  Fedora-Cloud-Base-32-1.6.x86_64.qcow2 
    Fedora-32

3.将CentOS云映像添加到Openstack

CentOS 8:

wget https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.3.2011-20201204.2.x86_64.qcow2
openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file  CentOS-8-GenericCloud-8.3.2011-20201204.2.x86_64.qcow2 
    CentOS-8

CentOS 7:

$ wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2

$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file CentOS-7-x86_64-GenericCloud.qcow2 
    CentOS-7

3.将Ubuntu云映像添加到Openstack

Ubuntu 20.04

wget http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img

openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file focal-server-cloudimg-amd64.img 
    Ubuntu-20.04

Ubuntu 18.04:

$ wget http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img

$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file bionic-server-cloudimg-amd64.img 
    Ubuntu-18.04

4.将Debian云映像添加到Openstack

Debian 10:

wget http://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-amd64.qcow2

openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file debian-10-openstack-amd64.qcow2 
    Debian-10

Debian 9:

$ wget http://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2
$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file debian-9-openstack-amd64.qcow2 
    Debian-9

5.将CoreOS云映像添加到Openstack

$ wget https://stable.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2
$ bunzip2 coreos_production_openstack_image.img.bz2
$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file coreos_production_openstack_image.img 
    CoreOS

6.将ArchLinux云映像添加到Openstack

$ wget https://linuximages.de/openstack/arch/arch-openstack-LATEST-image-bootstrap.qcow2
$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file arch-openstack-LATEST-image-bootstrap.qcow2 
    Arch-Linux

7.将Gentoo云映像添加到Openstack

$ wget https://linuximages.de/openstack/gentoo/gentoo-openstack-LATEST-image-bootstrap.qcow2
$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file gentoo-openstack-LATEST-image-bootstrap.qcow2 
    Gentoo-Linux

8.将Fedora CoreOS映像添加到OpenStack

下载图片

wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/33.20201201.3.0/x86_64/fedora-coreos-33.20201201.3.0-openstack.x86_64.qcow2.xz -O fedora-coreos-qemu.qcow2.xz

提取图像。

unxz fedora-coreos-qemu.qcow2.xz

上载提取的图像:

openstack image create 
  --container-format bare 
  --disk-format qcow2 
  --file fedora-coreos-qemu.qcow2 
  fcos

9.添加Windows Server 2012映像

从https://cloudbase.it/windows-cloud-images/#download下载图像

$ gunzip -cd windows_server_2012_r2_standard_eval_kvm_20170321.qcow2.gz
$ openstack image create 
    --container-format bare 
    --disk-format qcow2 
    --file windows_server_2012_r2_standard_eval_kvm_20170321.qcow2 
    Windows-Server-2012-R2-Std

查看Glance中可用的图像列表。

$ openstack image list
+--------------------------------------+---------------------+--------+
| ID                                   | Name                | Status |
+--------------------------------------+---------------------+--------+
| 0850ee38-1bdf-4379-9c69-0cf73e8b7c65 | Arch-Linux-x86_64   | active |
| e98445b6-f14f-488c-a18a-1f66c6de15c7 | CentOS-7-x86_64     | active |
| 7b4b616e-71f3-4419-9777-7aee66fad62c | Cirros-0.4.0-x86_64 | active |
| 98bbd9e6-abbc-45fa-ac95-b91b7b18ba0a | Debian-9-amd64      | active |
| 113b90b6-4e1e-4715-b9ab-456c191a82b3 | Fedora-30-x86_64    | active |
| 06c17e8a-0d4c-428a-89b5-b0eb2489f403 | Ubuntu-16.04-x86_64 | active |
+--------------------------------------+---------------------+--------+

图像选项选项设置

现在让我们将所有图像设置如下 看起来很公开 并保护他们免受意外删除。

IMAGE_IDS=`openstack image list | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' -o`
for i in ${IMAGE_IDS[@]}; do
    openstack image set --public $i
    openstack image set --protected $i
done

转到Horizo​​n仪表板并进行检查 项目>计算>图像..请注意,在所有图像上,保护标志都设置为yes,可见性也设置为Public。

参考:

OpenStack文档

还要检查:

Sidebar