Showing posts with label Openstack. Show all posts
Showing posts with label Openstack. Show all posts

Wednesday, October 5, 2022

Using S3 storage on Open Data Framework provided by Ceph-RGW

My previous posts demonstrated how to use CephFS and Ceph RBD backed storage classes as deployed by Open Data Framework on OpenShift. 

This blog post I will demonstrate how to use the Ceph RGW backed storage class from within a pod running on the OpenShift cluster. I will extract the S3 authentication credentials, create a name space, start a pod and demonstrate how to securely interact with the S3 service. 

Background

As stated in the previous blog posts ODF deploys a Ceph cluster within the OCP cluster. The cluster master nodes are used as the Ceph monitor processes, workers are utilized as OSD and the remaining related pods are scheduled on the cluster. 

This post as been verified against OCP and ODF versions 4.11. 

Storage Class Listing

Let's start by verifying the availability of ODF storage classes. The following command will display the available storage classes.

$ oc get sc
NAME                          PROVISIONER                             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
localblock                    kubernetes.io/no-provisioner            Delete          WaitForFirstConsumer   false                  6d
ocs-storagecluster-ceph-nfs   openshift-storage.nfs.csi.ceph.com      Delete          Immediate              false                  6d
ocs-storagecluster-ceph-rbd   openshift-storage.rbd.csi.ceph.com      Delete          Immediate              true                   6d
ocs-storagecluster-ceph-rgw   openshift-storage.ceph.rook.io/bucket   Delete          Immediate              false                  6d
ocs-storagecluster-cephfs     openshift-storage.cephfs.csi.ceph.com   Delete          Immediate              true                   6d
openshift-storage.noobaa.io   openshift-storage.noobaa.io/obc         Delete          Immediate              false                  6d

Verify S3 Access

To verify S3 access we will create an object bucket claim, extract the needed authentication and connection information, create a namespace with a configured POD and verify access.

Create ObjectBucketClaim

An ObjectBucketClaim is created against the CephRGW backed storage class.

$ cat objectbucketclaim.yaml 
apiVersion: objectbucket.io/v1alpha1
kind: ObjectBucketClaim
metadata:
  name: ceph-bucket
  namespace: openshift-storage
spec:
  generateBucketName: ceph-bkt
  storageClassName: ocs-storagecluster-ceph-rgw
$ oc apply -f objectbucketclaim.yaml 
objectbucketclaim.objectbucket.io/ceph-bucket created
$ oc get objectbucketclaim -n openshift-storage ceph-bucket -o jsonpath='{.status.phase}{"\n"}'
Bound

Extract Secrets and Connection Information

Once the ObjectBucketClaim is phase is Bound, the S3 secrets and connection information can be extract from the OCP cluster. The following commands will extract the needed information for later usage and print the resulting information to the screen. 

$ export AWS_ACCESS_KEY_ID=`oc get secret -n openshift-storage rook-ceph-object-user-ocs-storagecluster-cephobjectstore-ocs-storagecluster-cephobjectstoreuser -o jsonpath='{.data.AccessKey}'  | base64 -d`
$ export AWS_SECRET_ACCESS_KEY=`oc get secret -n openshift-storage rook-ceph-object-user-ocs-storagecluster-cephobjectstore-ocs-storagecluster-cephobjectstoreuser -o jsonpath='{.data.SecretKey}'  | base64 -d`
$ export AWS_BUCKET=`oc get cm ceph-bucket -n openshift-storage -o jsonpath='{.data.BUCKET_NAME}'`
$ export AWS_HOST=`oc get cm ceph-bucket -n openshift-storage -o jsonpath='{.data.BUCKET_HOST}'`
$ export AWS_PORT=`oc get cm ceph-bucket -n openshift-storage -o jsonpath='{.data.BUCKET_PORT}'`
$ echo ${AWS_ACCESS_KEY_ID}
$ echo ${AWS_SECRET_ACCESS_KEY}
$ echo ${AWS_BUCKET}
$ echo ${AWS_BUCKET}
$ echo ${AWS_HOST}
$ echo ${AWS_PORT}

Update S3 pod yaml

The pod yaml file will be updated to pass the S3 parameters and applied to the cluster
$ cat 74-consume-s3.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: s3-test
---
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  namespace: s3-test
  labels:
    app: rook-s3
spec:
  containers:
  - name: run-pod1
    image: registry.access.redhat.com/ubi8/ubi
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', 'yum install -y wget python3 && cd /tmp && wget https://downloads.sourceforge.net/project/s3tools/s3cmd/2.2.0/s3cmd-2.2.0.tar.gz && tar -zxf /tmp/s3cmd-2.2.0.tar.gz && ls /tmp && tail -f /dev/null' ]
    env:
    - name: AWS_ACCESS_KEY_ID
      value: VALUE_FROM_ECHO_AWS_ACCESS_KEY_ID
    - name: AWS_SECRET_ACCESS_KEY
      value: VALUE_FROM_ECHO_AWS_SECRET_ACCESS_KEY
    - name: AWS_HOST
      value: VALUE_FROM_ECHO_AWS_HOST
    - name: AWS_PORT
      value: VALUE_FROM_ECHO_AWS_PORT
    - name: AWS_BUCKET
      value: VALUE_FROM_ECHO_AWS_BUCKET
$ sed -e "s/VALUE_FROM_ECHO_AWS_ACCESS_KEY_ID/${AWS_ACCESS_KEY_ID}/g" \
-e "s/VALUE_FROM_ECHO_AWS_SECRET_ACCESS_KEY/${AWS_SECRET_ACCESS_KEY}/" \
-e "s/VALUE_FROM_ECHO_AWS_HOST/${AWS_HOST}/" \
-e "s/VALUE_FROM_ECHO_AWS_PORT/\"${AWS_PORT}\"/" \
-e "s/VALUE_FROM_ECHO_AWS_BUCKET/${AWS_BUCKET}/" \
-i consume-s3.yaml
$ oc apply -f consume-s3.yaml 
namespace/s3-test created
pod/test-pod created

Wait for the pod to be ready

The pod command line includes the installation commands needed to update the UBI image as needed for this demonstration. A customized image should be used in a production environment. Checking for the python3 command will be a sufficient check to ensure this demonstration pod is configured.

$ oc exec -n s3-test test-pod -- python3 -V
Python 3.6.8

NOTE: This demonstration is using the s3cmd to interface with the bucket. A customized configuration file using the needed S3 parameters and the service CA certificate is copied into to the pod for easier testing. This updating and copying of this file is left out of this blog post.

Verify S3 Environment

We can use the printenv command to verify the setting of the necessary environment credentials. These parameters can be used with a custom image to access the internal Ceph RGW storage
$ oc exec -n s3-test test-pod -- printenv | grep AWS
AWS_BUCKET=ceph-bkt-...ac49
AWS_ACCESS_KEY_ID=FAJ...1HR
AWS_SECRET_ACCESS_KEY=3z3...Vtd
AWS_HOST=rook-ceph-rgw-ocs-storagecluster-cephobjectstore.openshift-storage.svc
AWS_PORT=443

Verify S3 Access

To verify S3 access, we will simply create and list a new bucket.

$ oc exec -n s3-test test-pod -- python3 /tmp/s3cmd-2.2.0/s3cmd mb s3://validate.${RANDOM}
Bucket 's3://validate.18454/' created
$ oc exec -n s3-test test-pod -- python3 /tmp/s3cmd-2.2.0/s3cmd ls
2022-10-05 20:54  s3://validate.18454

Conclusion

With this blog post we have demonstrated how to consume the internal S3 storage service by creating an ObjectBucketClaim, extracting needed authentication information, deploying a customized pod and running commands. This information can be extended to support the deployment and operation of customized S3 enabled applications. 

Saturday, September 10, 2016

Integrating OpenStack Mitaka Cinder with External Ceph

This post describes how to manually integrate OpenStack Mitaka Cinder with a prexisting external Ceph cluster. The final configuration goals are to have Cinder configuration with multiple storage backends and support for creating volumes in either backend.

This post will not cover the initial deployment of OpenStack Cinder or the Ceph clusters.

Initial Conditions


  • OpenStack Mitaka deployed - deployed all-in-one on clone.example.com
  • Two Ceph clusters deployed - deployed as ceph1.example.com and ceph2.example.com

First Backend Configuration Process


The example configuration is for a OpenStack cluster installed in an all-in-one configuration and one external Ceph cluster is utilized. For larger OpenStack installations, the Cinder reconfiguration operations will need to be repeated on each controller. For multiple Ceph clusters, the ceph steps will be repeated once per cluster and a unique cinder.conf configuration stanza will be created.

Create Ceph pool

The Ceph pool should be created for cinder usage. The placement group size should be adjusted to satisfy operational requirements

[root@ceph1 ~]# ceph osd pool create cinder1 32
[root@ceph1 ~]# rados lspools
rbd
cinder1


Create Ceph client keyring

The client authentication keyring is created to permit cephx authenticated client connections. The "images1" and "vms1" pools are for other OpenStack usage.  The client name (client.ceph1) needs to be unique for this service across all Ceph clusters.

[root@ceph1 ~]# ceph auth get-or-create client.ceph1 mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=cinder1, allow rwx pool=vms1, allow rx pool=images1' | tee /etc/ceph/ceph.client.ceph1.keyring

Copy Ceph config

The ceph configuration file needs to be copied to the OpenStack controllers. 
[root@ceph1 ~]# scp /etc/ceph/ceph.conf root@clone:/etc/ceph/ceph-ceph1.conf

Copy Ceph client keyring[root@ceph1 ~]# scp /etc/ceph/ceph.client.ceph1.keyring root@clone:/etc/ceph/ceph.client.ceph1.keyring

Install ceph-common packages


The ceph-common package needs to be installed on the cinder servers

[root@clone ~]# yum -q -y install ceph-common
Package 1:ceph-common-10.2.2-0.el7.x86_64 already installed and latest version


Configure cinder.conf

Add the storage backend to the cinder.conf

[BACKEND_ceph1]
volume_driver=cinder.volume.drivers.rbd.RBDDriver

#rbd_secret_uuid is used by libvirt
rbd_secret_uuid=d0439829-7970-421b-a25e-37b1c3a97d7f

#rbd_ceph_conf points to the configuration file copied above
rbd_ceph_conf=/etc/ceph/ceph-ceph1.conf

#rbd_pool is the OSD pool created for this service
rbd_pool=cinder
backend_host=rbd:cinder1

#rbd_user is the client key create in the ceph cluster.
rbd_user=ceph1
volume_backend_name=BACKEND_ceph1



Update the list of available backends


enabled_backends = BACKEND_1,BACKEND_ceph1


Restart Cinder

The Cinder volume servers needs to be restarted on each configured controller.

[root@clone ~]# systemctl restart openstack-cinder-volume

Configure OpenStack to use new backend

 Create a new type of volume

[root@clone ~]# openstack volume type create BACKEND_ceph1

Associate the new type to the configured backend.

[root@clone ~]# openstack volume type set --property volume_backend_name=BACKEND_ceph1 BACKEND_ceph1

List available volume types and display the configuration information of the new type.
[root@clone ~]# openstack volume type list
[root@clone ~]# openstack volume type show BACKEND_ceph1

Test new backend

 Create a new volume with the new type.

[root@clone ~]# openstack volume create --size 1 --type BACKEND_ceph1 test
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2016-09-14T03:15:58.362561           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | a7950b6b-fcfd-4c90-8897-a0561befdaad |
| migration_status    | None                                 |
| multiattach         | False                                |
| name                | test                                 |
| properties          |                                      |
| replication_status  | disabled                             |
| size                | 1                                    |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | BACKEND_ceph1                        |
| updated_at          | None                                 |
| user_id             | d91cad8a93bb462cab84f51a6925e752     |
+---------------------+--------------------------------------+


Second Backend Configuration Process

The same process is used to configure the second backend with the following parameters changed:
  • Ceph client name - ceph2
  • Ceph client keyring name - ceph.clinet.ceph2.keyring
  • Ceph pool name - cinder2 
  • Cinder configuration stanza and backend type - BACKEND_ceph2
  • OpenStack volume type names

Final Configurations

Below is the output of various OpenStack and Ceph configuration queries

Contents of /etc/ceph

[root@clone ~]# ls -laF /etc/ceph
total 36
drwxr-xr-x.  2 root root 4096 Sep 13 23:20 ./
drwxr-xr-x. 87 root root 8192 Sep 13 23:21 ../
-rw-r--r--.  1 root root  400 Sep 13 22:21 ceph-ceph1.conf
-rw-r--r--.  1 root root  400 Sep 13 23:20 ceph-ceph2.conf
-rw-r--r--.  1 root root   63 Sep 13 22:22 ceph.client.ceph1.keyring
-rw-r--r--.  1 root root   63 Sep 13 23:19 ceph.client.ceph2.keyring
-rwxr-xr-x.  1 root root   92 Jul  4 06:00 rbdmap*

OpenStack Volume Services

[root@clone ~]# openstack volume service list
+------------------+-----------------------------+------+---------+-------+----------------------------+
| Binary           | Host                        | Zone | Status  | State | Updated At                 |
+------------------+-----------------------------+------+---------+-------+----------------------------+
| cinder-volume    | clone.example.com@BACKEND_1 | nova | enabled | up    | 2016-09-14T03:26:57.000000 |
| cinder-scheduler | clone.example.com           | nova | enabled | up    | 2016-09-14T03:26:58.000000 |
| cinder-volume    | rbd:cinder1@BACKEND_ceph1   | nova | enabled | up    | 2016-09-14T03:27:07.000000 |
| cinder-volume    | rbd:cinder2@BACKEND_ceph2   | nova | enabled | up    | 2016-09-14T03:27:07.000000 |
+------------------+-----------------------------+------+---------+-------+----------------------------+

OpenStack Volume Types

[root@clone ~]# openstack volume type list
+--------------------------------------+---------------+
| ID                                   | Name          |
+--------------------------------------+---------------+
| 00bc818f-4d04-4678-9b33-739c9457d14f | BACKEND_ceph2 |
| fbd2bdba-c909-4369-beef-00427df10934 | BACKEND_ceph1 |
| 66c24362-d848-4b21-8124-171cb246f34f | BACKEND_1     |
+--------------------------------------+---------------+

OpenStack Volume Type BACKEND_ceph1

[root@clone ~]# openstack volume type show BACKEND_ceph1
+---------------------------------+--------------------------------------+
| Field                           | Value                                |
+---------------------------------+--------------------------------------+
| access_project_ids              | None                                 |
| description                     | None                                 |
| id                              | fbd2bdba-c909-4369-beef-00427df10934 |
| is_public                       | True                                 |
| name                            | BACKEND_ceph1                        |
| os-volume-type-access:is_public | True                                 |
| properties                      | volume_backend_name='BACKEND_ceph1'  |
| qos_specs_id                    | None                                 |
+---------------------------------+--------------------------------------+



OpenStack Volume Type BACKEND_ceph2


[root@clone ~]# openstack volume type show BACKEND_ceph2
+---------------------------------+--------------------------------------+
| Field                           | Value                                |
+---------------------------------+--------------------------------------+
| access_project_ids              | None                                 |
| description                     | None                                 |
| id                              | 00bc818f-4d04-4678-9b33-739c9457d14f |
| is_public                       | True                                 |
| name                            | BACKEND_ceph2                        |
| os-volume-type-access:is_public | True                                 |
| properties                      | volume_backend_name='BACKEND_ceph2'  |
| qos_specs_id                    | None                                 |
+---------------------------------+--------------------------------------+

OpenStack Volumes


[root@clone ~]# openstack volume list
+--------------------------------------+--------------+-----------+------+-------------+
| ID                                   | Display Name | Status    | Size | Attached to |
+--------------------------------------+--------------+-----------+------+-------------+
| eada663d-523a-4d00-9874-fd7749745f1d | test2        | available |    1 |             |
| a7950b6b-fcfd-4c90-8897-a0561befdaad | test         | available |    1 |             |
+--------------------------------------+--------------+-----------+------+-------------+


OpenStack Volume Information

[root@clone ~]# openstack volume show test
+--------------------------------+-----------------------------------------+
| Field                          | Value                                   |
+--------------------------------+-----------------------------------------+
| attachments                    | []                                      |
| availability_zone              | nova                                    |
| bootable                       | false                                   |
| consistencygroup_id            | None                                    |
| created_at                     | 2016-09-14T03:15:58.000000              |
| description                    | None                                    |
| encrypted                      | False                                   |
| id                             | a7950b6b-fcfd-4c90-8897-a0561befdaad    |
| migration_status               | None                                    |
| multiattach                    | False                                   |
| name                           | test                                    |
| os-vol-host-attr:host          | rbd:cinder1@BACKEND_ceph1#BACKEND_ceph1 |
| os-vol-mig-status-attr:migstat | None                                    |
| os-vol-mig-status-attr:name_id | None                                    |
| os-vol-tenant-attr:tenant_id   | 63919c9c4e4c4d149e560ad0815c41d3        |
| properties                     |                                         |
| replication_status             | disabled                                |
| size                           | 1                                       |
| snapshot_id                    | None                                    |
| source_volid                   | None                                    |
| status                         | available                               |
| type                           | BACKEND_ceph1                           |
| updated_at                     | 2016-09-14T03:16:00.000000              |
| user_id                        | d91cad8a93bb462cab84f51a6925e752        |
+--------------------------------+-----------------------------------------+
[root@clone ~]# openstack volume show test2
+--------------------------------+-----------------------------------------+
| Field                          | Value                                   |
+--------------------------------+-----------------------------------------+
| attachments                    | []                                      |
| availability_zone              | nova                                    |
| bootable                       | false                                   |
| consistencygroup_id            | None                                    |
| created_at                     | 2016-09-14T03:24:21.000000              |
| description                    | None                                    |
| encrypted                      | False                                   |
| id                             | eada663d-523a-4d00-9874-fd7749745f1d    |
| migration_status               | None                                    |
| multiattach                    | False                                   |
| name                           | test2                                   |
| os-vol-host-attr:host          | rbd:cinder2@BACKEND_ceph2#BACKEND_ceph2 |
| os-vol-mig-status-attr:migstat | None                                    |
| os-vol-mig-status-attr:name_id | None                                    |
| os-vol-tenant-attr:tenant_id   | 63919c9c4e4c4d149e560ad0815c41d3        |
| properties                     |                                         |
| replication_status             | disabled                                |
| size                           | 1                                       |
| snapshot_id                    | None                                    |
| source_volid                   | None                                    |
| status                         | available                               |
| type                           | BACKEND_ceph2                           |
| updated_at                     | 2016-09-14T03:24:23.000000              |
| user_id                        | d91cad8a93bb462cab84f51a6925e752        |
+--------------------------------+-----------------------------------------+

Ceph Pool Contents

[root@ceph1 ~]# rados ls -p cinder1
rbd_header.5e4334da1f50
rbd_id.volume-a7950b6b-fcfd-4c90-8897-a0561befdaad
rbd_object_map.5e4334da1f50
rbd_directory


[root@ceph2 ~]# rados ls -p cinder2
rbd_id.volume-eada663d-523a-4d00-9874-fd7749745f1d
rbd_header.853994579fc
rbd_object_map.853994579fc
rbd_directory



More Information

Additional information about related topics to Ceph, Openstack and additional integration settings can be found at the following URLs.

Git repo related to this post
Configuring OpenStack to use Ceph
OpenStack Nova: configure multiple Ceph backends on one hypervisor