OpenStack Victoria : Add VM images to Glance2021/08/31 |
Add Virtual Machine images to Glance.
|
|
[1] |
Install KVM HyperVisor on Compute Host, refer to here.
It's unnecessarry to set Bridge networking on the section [2] of the link. |
[2] | For example, Create a Virtual Machine image of Debian 11. It uses Debian 11 installation ISO file for it on this example. |
# create a disk image root@dlp ~(keystone)# qemu-img create -f qcow2 /var/kvm/images/debian11.img 10G
# install root@dlp ~(keystone)# virsh net-start default root@dlp ~(keystone)# virt-install \
--name debian11 \
--ram 2048 \ --disk path=/var/kvm/images/debian11.img,format=qcow2 \ --vcpus 2 \ --os-variant debian10 \ --network network=default \ --graphics none \ --console pty,target_type=serial \ --location /home/debian-11.0.0-amd64-DVD-1.iso \ --extra-args 'console=ttyS0,115200n8 serial'
Starting install... # installation starts
# after finishing installation, configure guest system like follows
root@dlp:~#
vi /etc/apt/sources.list # comment out DVD source and add network source # deb cdrom:[Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04]/ bullseye contrib main
deb http://deb.debian.org/debian/ bullseye main contrib
# uncomment it to enable [security] source deb http://security.debian.org/debian-security bullseye-security main contrib # uncomment it to enable [updates] source deb http://deb.debian.org/debian/ bullseye-updates main contrib # add to the end deb http://deb.debian.org/debian/ bullseye-backports main contrib
root@debian:~#
apt update root@debian:~# apt -y install ssh cloud-init pollinate software-properties-common
root@debian:~#
vi /etc/default/grub # line 9 : change GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT=" console=tty1 console=ttyS0 "GRUB_CMDLINE_LINUX="" # line 33,34 : comment out # GRUB_TERMINAL=serial# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stopp=1"
root@debian:~#
update-grub
root@debian:~#
vi /etc/cloud/cloud.cfg # line 13 : add # only the case you'd like to allow SSH password authentication
ssh_pwauth: true
# line 91 : change # only the case if you'd like to allow [debian] user to use SSH password auth
default_user:
name: debian
lock_passwd: False
gecos: Debian
root@debian:~#
vi /etc/network/interfaces # comment out all except loopback interface # allow-hotplug enp1s0# iface enp1s0 inet dhcp
# shutdown to finish settings root@debian:~# shutdown -h now
|
[3] | Add the virtual image to Glance. |
root@dlp ~(keystone)# openstack image create "Debian11" --file /var/kvm/images/debian11.img --disk-format qcow2 --container-format bare --public +------------------+-------------------------------------------------------------+ | Field | Value | +------------------+-------------------------------------------------------------+ | container_format | bare | | created_at | 2021-08-31T01:19:59Z | | disk_format | qcow2 | | file | /v2/images/773971b3-b4be-4b07-aa06-fe8ca76b395d/file | | id | 773971b3-b4be-4b07-aa06-fe8ca76b395d | | min_disk | 0 | | min_ram | 0 | | name | Debian11 | | owner | 14c0b23f6f574380b9687f326debf0fe | | properties | os_hidden='False', owner_specified.openstack.md5='', o..... | | protected | False | | schema | /v2/schemas/image | | status | queued | | tags | | | updated_at | 2021-08-31T01:19:59Z | | visibility | public | +------------------+-------------------------------------------------------------+root@dlp ~(keystone)# openstack image list +--------------------------------------+----------+--------+ | ID | Name | Status | +--------------------------------------+----------+--------+ | 773971b3-b4be-4b07-aa06-fe8ca76b395d | Debian11 | active | +--------------------------------------+----------+--------+ |
[4] | By the way, if you got an image from internet, it's OK to simply add it like follows. |
root@dlp ~(keystone)#
root@dlp ~(keystone)# wget http://cloud-images.ubuntu.com/releases/20.04/release/ubuntu-20.04-server-cloudimg-amd64.img -P /var/kvm/images
openstack image create "Ubuntu2004-Official" --file /var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img --disk-format qcow2 --container-format bare --public +------------------+----------------------------------------------------------------------------------------------+ | Field | Value | +------------------+----------------------------------------------------------------------------------------------+ | checksum | be096b5b3c1a28f9416deed0253ad3e2 | | container_format | bare | | created_at | 2020-06-04T03:43:24Z | | disk_format | qcow2 | | file | /v2/images/ecfb5b90-eb90-436e-b853-16ede5f55bda/file | | id | ecfb5b90-eb90-436e-b853-16ede5f55bda | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu2004-Official | | owner | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e | | properties | os_hash_algo='sha512', os_hash_value='1cbc97f05e9de86ea571dd154b855dd217de51905367e9599c1... | | protected | False | | schema | /v2/schemas/image | | size | 533856256 | | status | active | | tags | | | updated_at | 2020-06-04T03:43:27Z | | visibility | public | +------------------+----------------------------------------------------------------------------------------------+ |
Sponsored Link |
|