Managing Ceph Block Device namespaces

Ceph Block Device namespaces provide logical isolation for block device images within a pool. A namespace enables isolation of images for different applications, tenants, or workloads without requiring separate pools.

Before you begin

Before you begin, make sure that you have the following prerequisites in place:
  • Ensure that the target pool exists.
  • Ensure that you have appropriate permissions to manage Ceph Block Device resources.
  • Ensure that the Ceph cluster is accessible from the command-line interface.

About this task

Each namespace exists within a pool and is referenced as part of the image specification. You can create, list, remove, and use namespaces to organize Ceph Block Device images within a pool.

Using namespaces provides the following benefits:

  • Logical separation of images within a pool.
  • Improved organization of resources.
  • Multi-tenant isolation within the same pool.
  • Simplified management of large numbers of images.

An image-spec can be identified by using the following syntax:

[POOL_NAME/[NAMESPACE/]]IMAGE

Where,

  • The default for POOL_NAME is rbd
  • The default for NAMESPACE is "". When no namespace is specified, the image resides in the default namespace.
Note: POOL_NAME is required if an image name contains a slash character (/).

Creating a namespace

Create a new namespace within an existing pool to logically isolate block device images for specific applications or tenants.

Procedure

Create a namespace within a pool.
rbd namespace create POOL_NAME/NAMESPACE

For example,

[root@rbd-client ~]# rbd namespace create mypool/dev

What to do next

Verify that the namespace is created by listing namespaces in a pool. Check that the namespace is listed in the output.
rbd namespace list POOL_NAME

Removing a namespace

Delete a namespace from a pool when it is no longer needed. The namespace must be empty before removal.

Procedure

  1. Ensure that the namespace is empty.
    rbd ls -p POOL_NAME --namespace NAMESPACE

    The output should be empty. If any images are listed, the namespace is not empty.

    • If the output is empty, continue to step 3.
    • If the output contains remaining images, continue to step 2.
  2. If needed, remove any images within the namespace.
    1. Remove the images.
      rbd rm -p POOL_NAME --namespace NAMESPACE IMAGE_NAME
    2. Verify that the namespace is empty.

      Repeat step 1 and 2a until no images are listed.

  3. Remove the namespace.
    rbd namespace remove POOL_NAME/NAMESPACE
    For example,
    [root@rbd-client ~]# rbd namespace remove mypool/dev

What to do next

Verify that the namespace is removed.

rbd namespace list POOL_NAME

The namespace will no longer be listed in the output.

Using namespaces in Ceph Block Device operations

Use a namespace to scope Ceph Block Device commands to a specific group of images within a pool, either by including the namespace in the image path or by using the --namespace option.

About this task

Both methods are functionally equivalent. When using these commands:

  • Always specify both the pool and the namespace to avoid ambiguity.
  • Use the --namespace option when scripting or when you want to separate the namespace from the image path.

Procedure

Choose one of the following methods to create an image in a namespace.
  • Specify the namespace in the image path.

    rbd create POOL_NAME/NAMESPACE/IMAGE --size SIZE

    For example,

    [root@rbd-client ~]# rbd create mypool/dev/myimage --size 10240

    This command creates the image myimage in the dev namespace within the mypool pool.

  • Use the --namespace option.

    rbd --namespace NAMESPACE -p POOL_NAME create IMAGE --size SIZE

    For example,

    [root@rbd-client ~]# rbd --namespace dev -p mypool create myimage --size 10240

    This command creates the image myimage in the dev namespace within the mypool pool.