How to do it...

Let's configure and use the Ceph REST API to check some cluster states:

  1. Create a user, client.restapi, on the Ceph cluster with appropriate access to mon, osd, and mds:
        # ceph auth get-or-create client.restapi
mds 'allow *' osd 'allow *'

mon 'allow *' > /etc/ceph/ceph.client.restapi.keyring

 

  1. Add the following section to the ceph.conf file:
        [client.restapi]
log file = /var/log/ceph/ceph.restapi.log
keyring = /etc/ceph/ceph.client.restapi.keyring
  1. Execute the following command to start the ceph-rest-api as a standalone web server in the background:
        # nohup ceph-rest-api > /var/log/ceph-rest-api &> /var/log/
ceph-rest-api-error.log &
You can also run the ceph-rest-api without nohup, suppressing it to the background.
  1. The ceph-rest-api should now be listening on 0.0.0.0:5000; use curl to query the ceph-rest-api for the cluster health:
        # curl localhost:5000/api/v0.1/health
  1. Similarly, check the osd and mon status via rest-api:
        # curl localhost:5000/api/v0.1/osd/stat
# curl localhost:5000/api/v0.1/mon/stat
  1. The ceph-rest-api has support for most of the Ceph CLI commands. To check the list of available ceph-rest-api commands, execute the following:
        # curl localhost:5000/api/v0.1
This command will return the output in HTML; it will be good if you visit localhost:5000/api/v0.1 from a web browser to render the HTML for easier readability. 

This is a basic implementation of the ceph-rest-api. To use it in a production environment, it's a good idea to deploy it in more than one instance with a WSGI application wrapped with a web server and frontend is done by load balancers. The ceph-rest-api is a scalable, lightweight service that allows you to administer your Ceph cluster like a pro.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset