如何將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