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.
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
ceph.conf
file:[client.restapi] log file = /var/log/ceph/ceph.restapi.log keyring = /etc/ceph/ceph.client.restapi.keyring
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 &
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
osd
and mon
status via rest-api
:# curl localhost:5000/api/v0.1/osd/stat # curl localhost:5000/api/v0.1/mon/stat
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 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.
3.12.163.180