OpenStack Ussuri : Add VM Images2020/06/08 |
Add Virtual Machine images in Glance.
For example on here, add a CentOS 8 virtual machine image. |
|
[1] |
Install KVM HyperVisor, refer to here.
It's unnecessarry to set Bridge networking on the section [2] of the link. |
[2] | Create a CentOS 8 image on Glance service Host. |
# download official image [root@dlp ~(keystone)]# virt-builder centos-8.0 --format qcow2 --size 10G -o /var/kvm/images/centos8.qcow2 --root-password password
# install [root@dlp ~(keystone)]# virt-install \
--name centos-8.0 \ --ram 2048 \ --disk path=/var/kvm/images/centos8.qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel8.0 \ --network network=default \ --graphics none \ --serial pty \ --console pty \ --boot hd \ --import # after starting VM, login and configure some necessary settings
CentOS Linux 8 (Core)
Kernel 4.18.0-80.7.1.el8_0.x86_64 on an x86_64
localhost login: root
# replace the interface name [enp1s0] to your own environment [root@localhost ~]# passwd root [root@localhost ~]# useradd centos [root@localhost ~]# passwd centos
[root@localhost ~]#
vi /etc/sysconfig/network-scripts/ifcfg-enp1s0 # disable the [UUID] line and also set [dhcp] for [BOOTPROTO] line #UUID="3ebe29b4-b7a3-49d6-997a-ee8b78749840" BOOTPROTO="dhcp"[root@localhost ~]# dnf -y install cloud-init openssh-server
[root@localhost ~]#
vi /etc/cloud/cloud.cfg # line 5: if you'd like to allo SSH password auth, change to [1] ssh_pwauth: 1 # line 57, 58: change to [centos] as default user # if you'd like to allow SSH password auth to the user, chage like follows system_info: default_user: name: centos lock_passwd: false[root@localhost ~]# systemctl enable cloud-init sshd [root@localhost ~]# shutdown -h now |
[3] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# openstack image create "CentOS8" --file /var/kvm/images/centos8.qcow2 --disk-format qcow2 --container-format bare --public +------------------+--------------------------------------------------------------------------------+ | Field | Value | +------------------+--------------------------------------------------------------------------------+ | checksum | b5bb096cd717a540340318448af3523c | | container_format | bare | | created_at | 2020-06-05T02:10:07Z | | disk_format | qcow2 | | file | /v2/images/9e7034a0-c825-4990-8834-4a01ee920cf5/file | | id | 9e7034a0-c825-4990-8834-4a01ee920cf5 | | min_disk | 0 | | min_ram | 0 | | name | CentOS8 | | owner | 9cffeca6beec4a39ab6b076ec2bdd0c9 | | properties | os_hash_algo='sha512', os_hash_value='a4417b559c3a4a974a1b0942223407060dba0... | | protected | False | | schema | /v2/schemas/image | | size | 9665380352 | | status | active | | tags | | | updated_at | 2020-06-05T02:11:00Z | | visibility | public | +------------------+--------------------------------------------------------------------------------+[root@dlp ~(keystone)]# openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | 9e7034a0-c825-4990-8834-4a01ee920cf5 | CentOS8 | 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 |