3.5. Enabling metadata on RBD and CephFS volumes


You can set the persistent volume claim (PVC), persistent volume (PV), and Namespace names in the RADOS block device (RBD) and CephFS volumes for monitoring purposes. This enables you to read the RBD and CephFS metadata to identify the mapping between the OpenShift Container Platform and RBD and CephFS volumes.

To enable RADOS block device (RBD) and CephFS volume metadata feature, you need to set the CSI_ENABLE_METADATA variable in the rook-ceph-operator-config configmap. By default, this feature is disabled. If you enable the feature after upgrading from a previous version, the existing PVCs will not contain the metadata. Also, when you enable the metadata feature, the PVCs that were created before enabling will not have the metadata.

Prerequisites

  • Ensure to install ocs_operator and create a storagecluster for the operator.
  • Ensure that the storagecluster is in Ready state.

    $ oc get storagecluster
    NAME                 AGE   PHASE   EXTERNAL   CREATED AT             VERSION
    ocs-storagecluster   57m   Ready              2022-08-30T06:52:58Z   4.12.0

Procedure

  1. Edit the rook-ceph operator ConfigMap to mark CSI_ENABLE_METADATA to true.

    $ oc patch cm rook-ceph-operator-config -n openshift-storage -p $'data:\n "CSI_ENABLE_METADATA":  "true"'
    configmap/rook-ceph-operator-config patched
  2. Wait for the respective CSI CephFS plugin provisioner pods and CSI RBD plugin pods to reach the Running state.

    注記

    Ensure that the setmetadata variable is automatically set after the metadata feature is enabled. This variable should not be available when the metadata feature is disabled.

    $ oc get pods | grep csi
    
    csi-cephfsplugin-b8d6c                         2/2     Running     0          56m
    csi-cephfsplugin-bnbg9                         2/2     Running     0          56m
    csi-cephfsplugin-kqdw4                         2/2     Running     0          56m
    csi-cephfsplugin-provisioner-7dcd78bb9b-q6dxb  5/5     Running     0          56m
    csi-cephfsplugin-provisioner-7dcd78bb9b-zc4q5  5/5     Running     0          56m
    csi-rbdplugin-776dl                            3/3     Running     0          56m
    csi-rbdplugin-ffl52                            3/3     Running     0          56m
    csi-rbdplugin-jx9mz                            3/3     Running     0          56m
    csi-rbdplugin-provisioner-5f6d766b6c-694fx     6/6     Running     0          56m
    csi-rbdplugin-provisioner-5f6d766b6c-vzv45     6/6     Running     0          56m

Verification steps

  • To verify the metadata for RBD PVC:

    1. Create a PVC.

      $ cat <<EOF | oc create -f -
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: rbd-pvc
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
        storageClassName: ocs-storagecluster-ceph-rbd
      EOF
    2. Check the status of the PVC.

      $ oc get pvc | grep rbd-pvc
      rbd-pvc                           Bound    pvc-30628fa8-2966-499c-832d-a6a3a8ebc594   1Gi        RWO            ocs-storagecluster-ceph-rbd   32s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      [sh-4.x]$ rbd ls ocs-storagecluster-cephblockpool
      
      csi-vol-7d67bfad-2842-11ed-94bd-0a580a830012
      csi-vol-ed5ce27b-2842-11ed-94bd-0a580a830012
      
      [sh-4.x]$ rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-ed5ce27b-2842-11ed-94bd-0a580a830012

      There are four metadata on this image:

      Key                               Value
      csi.ceph.com/cluster/name         6cd7a18d-7363-4830-ad5c-f7b96927f026
      csi.storage.k8s.io/pv/name        pvc-30628fa8-2966-499c-832d-a6a3a8ebc594
      csi.storage.k8s.io/pvc/name       rbd-pvc
      csi.storage.k8s.io/pvc/namespace  openshift-storage
  • To verify the metadata for RBD clones:

    1. Create a clone.

      $ cat <<EOF | oc create -f -
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: rbd-pvc-clone
      spec:
        storageClassName: ocs-storagecluster-ceph-rbd
        dataSource:
          name: rbd-pvc
          kind: PersistentVolumeClaim
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
      EOF
    2. Check the status of the clone.

      $ oc get pvc | grep rbd-pvc
      rbd-pvc                           Bound    pvc-30628fa8-2966-499c-832d-a6a3a8ebc594   1Gi        RWO            ocs-storagecluster-ceph-rbd   15m
      rbd-pvc-clone                     Bound    pvc-0d72afda-f433-4d46-a7f1-a5fcb3d766e0   1Gi        RWO            ocs-storagecluster-ceph-rbd   52s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      [sh-4.x]$ rbd ls ocs-storagecluster-cephblockpool
      csi-vol-063b982d-2845-11ed-94bd-0a580a830012
      csi-vol-063b982d-2845-11ed-94bd-0a580a830012-temp
      csi-vol-7d67bfad-2842-11ed-94bd-0a580a830012
      csi-vol-ed5ce27b-2842-11ed-94bd-0a580a830012
      
      [sh-4.x]$ rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-063b982d-2845-11ed-94bd-0a580a830012
      There are 4 metadata on this image:
      
      Key                               Value
      csi.ceph.com/cluster/name         6cd7a18d-7363-4830-ad5c-f7b96927f026
      csi.storage.k8s.io/pv/name        pvc-0d72afda-f433-4d46-a7f1-a5fcb3d766e0
      csi.storage.k8s.io/pvc/name       rbd-pvc-clone
      csi.storage.k8s.io/pvc/namespace  openshift-storage
  • To verify the metadata for RBD Snapshots:

    1. Create a snapshot.

      $ cat <<EOF | oc create -f -
      apiVersion: snapshot.storage.k8s.io/v1
      kind: VolumeSnapshot
      metadata:
        name: rbd-pvc-snapshot
      spec:
        volumeSnapshotClassName: ocs-storagecluster-rbdplugin-snapclass
        source:
          persistentVolumeClaimName: rbd-pvc
      EOF
      volumesnapshot.snapshot.storage.k8s.io/rbd-pvc-snapshot created
    2. Check the status of the snapshot.

      $ oc get volumesnapshot
      NAME               READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT   RESTORESIZE   SNAPSHOTCLASS                            SNAPSHOTCONTENT                                    CREATIONTIME   AGE
      rbd-pvc-snapshot   true         rbd-pvc                             1Gi           ocs-storagecluster-rbdplugin-snapclass   snapcontent-b992b782-7174-4101-8fe3-e6e478eb2c8f   17s            18s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      [sh-4.x]$ rbd ls ocs-storagecluster-cephblockpool
      csi-snap-a1e24408-2848-11ed-94bd-0a580a830012
      csi-vol-063b982d-2845-11ed-94bd-0a580a830012
      csi-vol-063b982d-2845-11ed-94bd-0a580a830012-temp
      csi-vol-7d67bfad-2842-11ed-94bd-0a580a830012
      csi-vol-ed5ce27b-2842-11ed-94bd-0a580a830012
      
      [sh-4.x]$ rbd image-meta ls ocs-storagecluster-cephblockpool/csi-snap-a1e24408-2848-11ed-94bd-0a580a830012
      There are 4 metadata on this image:
      
      Key                                            Value
      csi.ceph.com/cluster/name                      6cd7a18d-7363-4830-ad5c-f7b96927f026
      csi.storage.k8s.io/volumesnapshot/name         rbd-pvc-snapshot
      csi.storage.k8s.io/volumesnapshot/namespace    openshift-storage
      csi.storage.k8s.io/volumesnapshotcontent/name  snapcontent-b992b782-7174-4101-8fe3-e6e478eb2c8f
  • Verify the metadata for RBD Restore:

    1. Restore a volume snapshot.

      $ cat <<EOF | oc create -f -
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: rbd-pvc-restore
      spec:
        storageClassName: ocs-storagecluster-ceph-rbd
        dataSource:
          name: rbd-pvc-snapshot
          kind: VolumeSnapshot
          apiGroup: snapshot.storage.k8s.io
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
      EOF
      persistentvolumeclaim/rbd-pvc-restore created
    2. Check the status of the restored volume snapshot.

      $ oc get pvc | grep rbd
      db-noobaa-db-pg-0                 Bound    pvc-615e2027-78cd-4ea2-a341-fdedd50c5208   50Gi       RWO            ocs-storagecluster-ceph-rbd   51m
      rbd-pvc                           Bound    pvc-30628fa8-2966-499c-832d-a6a3a8ebc594   1Gi        RWO            ocs-storagecluster-ceph-rbd   47m
      rbd-pvc-clone                     Bound    pvc-0d72afda-f433-4d46-a7f1-a5fcb3d766e0   1Gi        RWO            ocs-storagecluster-ceph-rbd   32m
      rbd-pvc-restore                   Bound    pvc-f900e19b-3924-485c-bb47-01b84c559034   1Gi        RWO            ocs-storagecluster-ceph-rbd   111s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      [sh-4.x]$ rbd ls ocs-storagecluster-cephblockpool
      csi-snap-a1e24408-2848-11ed-94bd-0a580a830012
      csi-vol-063b982d-2845-11ed-94bd-0a580a830012
      csi-vol-063b982d-2845-11ed-94bd-0a580a830012-temp
      csi-vol-5f6e0737-2849-11ed-94bd-0a580a830012
      csi-vol-7d67bfad-2842-11ed-94bd-0a580a830012
      csi-vol-ed5ce27b-2842-11ed-94bd-0a580a830012
      
      [sh-4.x]$ rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-5f6e0737-2849-11ed-94bd-0a580a830012
      There are 4 metadata on this image:
      
      Key                               Value
      csi.ceph.com/cluster/name         6cd7a18d-7363-4830-ad5c-f7b96927f026
      csi.storage.k8s.io/pv/name        pvc-f900e19b-3924-485c-bb47-01b84c559034
      csi.storage.k8s.io/pvc/name       rbd-pvc-restore
      csi.storage.k8s.io/pvc/namespace  openshift-storage
  • To verify the metadata for CephFS PVC:

    1. Create a PVC.

      cat <<EOF | oc create -f -
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: cephfs-pvc
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
        storageClassName: ocs-storagecluster-cephfs
      EOF
    2. Check the status of the PVC.

      oc get pvc | grep cephfs
      cephfs-pvc                        Bound    pvc-4151128c-86f0-468b-b6e7-5fdfb51ba1b9   1Gi        RWO            ocs-storagecluster-cephfs     11s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      $ ceph fs volume ls
      [
          {
              "name": "ocs-storagecluster-cephfilesystem"
          }
      ]
      
      $ ceph fs subvolumegroup ls ocs-storagecluster-cephfilesystem
      [
          {
              "name": "csi"
          }
      ]
      
      $ ceph fs subvolume ls ocs-storagecluster-cephfilesystem --group_name csi
      [
          {
              "name": "csi-vol-25266061-284c-11ed-95e0-0a580a810215"
          }
      ]
      
      $ ceph fs subvolume metadata ls ocs-storagecluster-cephfilesystem csi-vol-25266061-284c-11ed-95e0-0a580a810215 --group_name=csi --format=json
      
      {
          "csi.ceph.com/cluster/name": "6cd7a18d-7363-4830-ad5c-f7b96927f026",
          "csi.storage.k8s.io/pv/name": "pvc-4151128c-86f0-468b-b6e7-5fdfb51ba1b9",
          "csi.storage.k8s.io/pvc/name": "cephfs-pvc",
          "csi.storage.k8s.io/pvc/namespace": "openshift-storage"
      }
  • To verify the metadata for CephFS clone:

    1. Create a clone.

      $ cat <<EOF | oc create -f -
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: cephfs-pvc-clone
      spec:
        storageClassName: ocs-storagecluster-cephfs
        dataSource:
          name: cephfs-pvc
          kind: PersistentVolumeClaim
        accessModes:
          - ReadWriteMany
        resources:
          requests:
            storage: 1Gi
      EOF
      persistentvolumeclaim/cephfs-pvc-clone created
    2. Check the status of the clone.

      $ oc get pvc | grep cephfs
      cephfs-pvc                        Bound    pvc-4151128c-86f0-468b-b6e7-5fdfb51ba1b9   1Gi        RWO            ocs-storagecluster-cephfs     9m5s
      cephfs-pvc-clone                  Bound    pvc-3d4c4e78-f7d5-456a-aa6e-4da4a05ca4ce   1Gi        RWX            ocs-storagecluster-cephfs     20s
    3. Verify the metadata using the in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      [rook@rook-ceph-tools-c99fd8dfc-6sdbg /]$ ceph fs subvolume ls ocs-storagecluster-cephfilesystem --group_name csi
      [
          {
              "name": "csi-vol-5ea23eb0-284d-11ed-95e0-0a580a810215"
          },
          {
              "name": "csi-vol-25266061-284c-11ed-95e0-0a580a810215"
          }
      ]
      
      [rook@rook-ceph-tools-c99fd8dfc-6sdbg /]$ ceph fs subvolume metadata ls ocs-storagecluster-cephfilesystem csi-vol-5ea23eb0-284d-11ed-95e0-0a580a810215 --group_name=csi --format=json
      
      {
          "csi.ceph.com/cluster/name": "6cd7a18d-7363-4830-ad5c-f7b96927f026",
          "csi.storage.k8s.io/pv/name": "pvc-3d4c4e78-f7d5-456a-aa6e-4da4a05ca4ce",
          "csi.storage.k8s.io/pvc/name": "cephfs-pvc-clone",
          "csi.storage.k8s.io/pvc/namespace": "openshift-storage"
      }
  • To verify the metadata for CephFS volume snapshot:

    1. Create a volume snapshot.

      $ cat <<EOF | oc create -f -
      apiVersion: snapshot.storage.k8s.io/v1
      kind: VolumeSnapshot
      metadata:
        name: cephfs-pvc-snapshot
      spec:
        volumeSnapshotClassName: ocs-storagecluster-cephfsplugin-snapclass
        source:
          persistentVolumeClaimName: cephfs-pvc
      EOF
      volumesnapshot.snapshot.storage.k8s.io/cephfs-pvc-snapshot created
    2. Check the status of the volume snapshot.

      $ oc get volumesnapshot
      NAME                  READYTOUSE   SOURCEPVC    SOURCESNAPSHOTCONTENT   RESTORESIZE   SNAPSHOTCLASS                               SNAPSHOTCONTENT                                    CREATIONTIME   AGE
      cephfs-pvc-snapshot   true         cephfs-pvc                           1Gi           ocs-storagecluster-cephfsplugin-snapclass   snapcontent-f0f17463-d13b-4e13-b44e-6340bbb3bee0   9s             9s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      $ ceph fs subvolume snapshot ls ocs-storagecluster-cephfilesystem csi-vol-25266061-284c-11ed-95e0-0a580a810215 --group_name csi
      [
          {
              "name": "csi-snap-06336f4e-284e-11ed-95e0-0a580a810215"
          }
      ]
      
      $ ceph fs subvolume snapshot metadata ls ocs-storagecluster-cephfilesystem csi-vol-25266061-284c-11ed-95e0-0a580a810215 csi-snap-06336f4e-284e-11ed-95e0-0a580a810215 --group_name=csi --format=json
      
      {
          "csi.ceph.com/cluster/name": "6cd7a18d-7363-4830-ad5c-f7b96927f026",
          "csi.storage.k8s.io/volumesnapshot/name": "cephfs-pvc-snapshot",
          "csi.storage.k8s.io/volumesnapshot/namespace": "openshift-storage",
          "csi.storage.k8s.io/volumesnapshotcontent/name": "snapcontent-f0f17463-d13b-4e13-b44e-6340bbb3bee0"
      }
  • To verify the metadata of the CephFS Restore:

    1. Restore a volume snapshot.

      $ cat <<EOF | oc create -f -
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: cephfs-pvc-restore
      spec:
        storageClassName: ocs-storagecluster-cephfs
        dataSource:
          name: cephfs-pvc-snapshot
          kind: VolumeSnapshot
          apiGroup: snapshot.storage.k8s.io
        accessModes:
          - ReadWriteMany
        resources:
          requests:
            storage: 1Gi
      EOF
      persistentvolumeclaim/cephfs-pvc-restore created
    2. Check the status of the restored volume snapshot.

      $ oc get pvc | grep cephfs
      cephfs-pvc                        Bound    pvc-4151128c-86f0-468b-b6e7-5fdfb51ba1b9   1Gi        RWO            ocs-storagecluster-cephfs     29m
      cephfs-pvc-clone                  Bound    pvc-3d4c4e78-f7d5-456a-aa6e-4da4a05ca4ce   1Gi        RWX            ocs-storagecluster-cephfs     20m
      cephfs-pvc-restore                Bound    pvc-43d55ea1-95c0-42c8-8616-4ee70b504445   1Gi        RWX            ocs-storagecluster-cephfs     21s
    3. Verify the metadata in the Red Hat Ceph Storage command-line interface (CLI).

      For information about how to access the Red Hat Ceph Storage CLI, see the How to access Red Hat Ceph Storage CLI in Red Hat OpenShift Data Foundation environment article.

      $ ceph fs subvolume ls ocs-storagecluster-cephfilesystem --group_name csi
      [
          {
              "name": "csi-vol-3536db13-2850-11ed-95e0-0a580a810215"
          },
          {
              "name": "csi-vol-5ea23eb0-284d-11ed-95e0-0a580a810215"
          },
          {
              "name": "csi-vol-25266061-284c-11ed-95e0-0a580a810215"
          }
      ]
      
      $ ceph fs subvolume metadata ls ocs-storagecluster-cephfilesystem csi-vol-3536db13-2850-11ed-95e0-0a580a810215 --group_name=csi --format=json
      
      {
          "csi.ceph.com/cluster/name": "6cd7a18d-7363-4830-ad5c-f7b96927f026",
          "csi.storage.k8s.io/pv/name": "pvc-43d55ea1-95c0-42c8-8616-4ee70b504445",
          "csi.storage.k8s.io/pvc/name": "cephfs-pvc-restore",
          "csi.storage.k8s.io/pvc/namespace": "openshift-storage"
      }
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る