Integrate Ceph and OpenStack (Tutorial)

Abdul Rozaqi WAbdul Rozaqi W
3 min read

Disini saya akan membagikan tutorial bagaimana cara mengintegrasikan OpenStack dengan Ceph sebagai backend storagenya.

Environment

10.1.1.10 rz-os-controller
10.1.1.11 rz-os-compute
10.1.1.12 rz-os-network
10.1.1.13 rz-os-storage
10.1.1.14 rz-os-compute-02

Integrasi dengan Glance

1) Buat pool untuk menyimpan image OpenStack

root@rz-os-storage:~# ceph osd pool create images

2) Install ceph client pada node controller

root@rz-os-controller:~# apt install ceph-common

3) Buat autentikasi ke pool images

root@rz-os-storage:~# ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'

4) Tambahkan keyring ke node Controller

root@rz-os-storage:~# ceph auth get-or-create client.glance | ssh rz-os-controller sudo tee /etc/ceph/ceph.client.glance.keyring

5) Konfigurasi file glance

root@rz-os-controller:~# sudo nano /etc/glance/glance-api.conf

Pada bagian [glance_store] tambahkan konfigurasi berikut

[glance_store]
stores = rbd
default_store = rbd
rbd_store_chunk_size = 8
rbd_store_pool = images
rbd_store_user = glance
rbd_store_ceph_conf = /etc/ceph/ceph.conf
show_image_direct_url = true

6) Restart service glance-api

root@rz-os-controller:~# systemctl restart glance-api.service

Verifikasi glance sudah terintegrasi dengan membuat image OpenStack

root@rz-os-controller:~# openstack image create "Ubuntu2004-Official" --file ubuntu-20.04.img --disk-format qcow2 --container-format bare --public

image.png Verifikasi image yang sudah dibuat pada pool images image.png

Integrasi dengan Cinder

1) Buat pool untuk menyimpan volume OpenStack

root@rz-os-storage:~# ceph osd pool create volumes

2) Buat autentikasi ke pool volumes, images, dan vms

root@rz-os-storage:~# ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rwx pool=vms, allow rx pool=images'

3) Tambahkan keyring ke node Compute dan ubah kepemilikan filenya

root@rz-os-storage:~# ceph auth get-or-create client.cinder | tee /etc/ceph/ceph.client.cinder.keyring
root@rz-os-storage:~# chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring

root@rz-os-storage:~# ceph auth get-or-create client.cinder | ssh rz-os-compute tee /etc/ceph/ceph.client.cinder.keyring
root@rz-os-storage:~# ssh rz-os-compute chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring

root@rz-os-storage:~# ceph auth get-or-create client.cinder | ssh rz-os-compute-02 tee /etc/ceph/ceph.client.cinder.keyring
root@rz-os-storage:~# ssh rz-os-compute-02 chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring

4) Konfigurasi file Cinder

root@rz-os-storage:~# sudo nano /etc/cinder/cinder.conf

Tambahkan pada bagian [DEFAULT]

enabled_backends = ceph
glance_api_version = 2

Buat konfigurasi pada baris akhir

[ceph]
volume_driver = cinder.volume.drivers.rbd.RBDDriver
rbd_cluster_name = ceph
rbd_pool = volumes
rbd_user = cinder
rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_flatten_volume_from_snapshot = false
rbd_secret_uuid = a7409211-3874-4922-978c-0d540cbb8e51

value rbd_secret_uuid bisa didapat dengan cara berikut :

root@rz-os-compute:~# uuidgen > uuid.txt

root@rz-os-compute:~# cat > secret.xml <<EOF
<secret ephemeral='no' private='no'>
  <uuid>`cat uuid-secret.txt`</uuid>
  <usage type='ceph'>
    <name>client.cinder secret</name>
  </usage>
</secret>
EOF

Dapatkan client.cinder key

root@rz-os-storage:~# ceph auth get-key client.cinder | ssh rz-os-compute tee client.cinder.key
root@rz-os-storage:~# ceph auth get-key client.cinder | ssh rz-os-compute-02 tee client.cinder.key

Set dan definisikan secret untuk libvirt

root@rz-os-compute:~# virsh secret-define --file secret.xml
root@rz-os-compute:~# virsh secret-set-value --secret $(cat uuid.txt) --base64 $(cat client.cinder.key)

Jalankan juga di node compute lainnya

root@rz-os-compute:~# scp secret.xml rz-os-compute-02
root@rz-os-compute-02:~# virsh secret-define --file secret.xml
root@rz-os-compute-02:~# virsh secret-set-value --secret $(cat uuid.txt) --base64 $(cat client.cinder.key)

5) Verifikasi apakah sudah terintegrasi dengan membuat volume

root@rz-os-controller:~# openstack volume create --size 1 tes

list volume OpenStack image.png list image yang ada pada pool volumes image.png

0
Subscribe to my newsletter

Read articles from Abdul Rozaqi W directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abdul Rozaqi W
Abdul Rozaqi W