Ceph REST API

Ceph comes with powerful REST API interface access, which allows you to administer your cluster programmatically. It can run as a WSGI application or as a standalone server, listening over the default port 5000. It provides a similar kind of functionality to that of the ceph command-line tool through an HTTP-accessible interface. Commands are submitted as HTTP GET and PUT requests, and the results can be returned in the JSON, XML, and text formats. In this recipe, I will quickly show you how to set up the Ceph REST API and interact with it.

How to do it…

  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
    
  2. 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
    
  3. Execute the following command to start the ceph-rest-api as a standalone webserver in the background:
    # nohup ceph-rest-api > /var/log/ceph-rest-api &> /var/log/ceph-rest-api-error.log &
    

    Note

    You can also run the ceph-rest-api without nohup, suppressing it to background.

  4. 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
    
  5. 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
    
    How to do it…
  6. 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
    

Note

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 webserver and front ended by load balancers. The ceph-rest-api is a scalable, light weight 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
3.12.163.180