Membuat Persistent Volume Menggunakan Ceph RBD

Sebagai salah satu komponen inti distribusi Ceph, Ceph RBD dirancang untuk menyediakan solusi block storage yang skalabel dan berkinerja tinggi. Ini memungkinkan pengguna untuk dengan mudah membuat, mengelola, dan memanfaatkan virtual disk (RBD Images) yang disimpan langsung di klaster Ceph.

Dalam artikel ini kita akan belajar langkah-langkah membuat persistent volume menggunakan Ceph RBD.

Environment

Ceph Cluster

HostnameIP AddressRole
rz-ceph-node01192.168.10.30Ceph Mon
rz-ceph-node02192.168.10.31Ceph Mon, Ceph OSD
rz-ceph-node03192.168.10.32Ceph OSD

Kubernetes Cluster

HostnameIP AddressRole
rz-master01192.168.10.20Control Plane, ETCD
rz-worker01192.168.10.21Worker
rz-worker02192.168.10.22Worker

Step-by-step

Untuk mendapatkan informasi FSID dan Ceph Mon, jalankan command berikut:

Simpan informasi fsid dan <IP:6789>

ceph mon dump
...
dumped monmap epoch 4
epoch 4
fsid f2e8791a-37ad-11f0-b942-15fd889ba33d
last_changed 2025-05-23T08:20:46.148011+0000
created 2025-05-23T08:14:57.778245+0000
min_mon_release 15 (octopus)
0: [v2:192.168.10.30:3300/0,v1:192.168.10.30:6789/0] mon.rz-ceph-node01
1: [v2:192.168.10.31:3300/0,v1:192.168.10.31:6789/0] mon.rz-ceph-node02

Tambahkan helm repository Ceph CSI

helm repo add ceph-csi https://ceph.github.io/csi-charts
helm repo update

Buat osd pool, block device, dan user block device.

ceph osd pool create kubernetes 64 64
rbd pool init kubernetes
ceph auth get-or-create client.kubernetes mon 'profile rbd' osd 'profile rbd pool=kubernetes' mgr 'profile rbd pool=kubernetes'

Untuk mendapatkan user key, gunakan command berikut:

ceph auth get-key client.kubernetes | base64
...
QVFEWUkxVm9EVnRFRXhBQWRwcW1adExpdXFIaEJYQjduYXVRL3c9PQ==

Export helm values Ceph CSI

helm inspect values ceph-csi/ceph-csi-rbd > ceph-csi-rbd-values.yaml
...
csiConfig:
  - clusterID: "f2e8791a-37ad-11f0-b942-15fd889ba33d"
    monitors:
      - "192.168.10.30:6789"
      - "192.168.10.31:6789"
...
storageClass:
  create: true
  name: csi-rbd-sc
  clusterID: f2e8791a-37ad-11f0-b942-15fd889ba33d
  pool: kubernetes
  imageFeatures: "layering"
  provisionerSecret: csi-rbd-secret
  provisionerSecretNamespace: ""
  controllerExpandSecret: csi-rbd-secret
  controllerExpandSecretNamespace: ""
  nodeStageSecret: csi-rbd-secret
  nodeStageSecretNamespace: ""
  fstype: ext4
  reclaimPolicy: Delete
  allowVolumeExpansion: true
  mountOptions:
    - discard
...
secret:
  create: true
  name: csi-rbd-secret
  annotations: {}
  userID: kubernetes
  userKey: AQDYI1VoDVtEExAAdpqmZtLiuqHhBXB7nauQ/w==
...

Deploy Ceph CSI RBD

kubectl create namespace ceph-csi-rbd
helm install --namespace ceph-csi-rbd ceph-csi-rbd ceph-csi/ceph-csi-rbd --values ceph-csi-rbd-values.yaml

Coba test buat sebuah persistent volume

cat > ceph-rbd-sc-pvc.yaml <<EOF
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: ceph-rbd-sc-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: csi-rbd-sc
EOF
kubectl apply -f ceph-rbd-sc-pvc.yaml

Pastikan pvc dalam status Bound, nantinya pv akan otomatis terbuat.

kubectl get pvc
...
NAME              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
ceph-rbd-sc-pvc   Bound    pvc-c02f6a88-a965-4440-96c6-dc6d8e9340cd   2Gi        RWO            csi-rbd-sc     89s
kubectl get pv
...
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                     STORAGECLASS   REASON   AGE
pvc-c02f6a88-a965-4440-96c6-dc6d8e9340cd   2Gi        RWO            Delete           Bound    default/ceph-rbd-sc-pvc   csi-rbd-sc              6s

Secara otomatis rbd image terbuat

rbd -p kubernetes ls
...
csi-vol-a0c6862a-7188-4d1d-bc1e-b12ceb79929c
rbd info kubernetes/csi-vol-a0c6862a-7188-4d1d-bc1e-b12ceb79929c
...
rbd image 'csi-vol-a0c6862a-7188-4d1d-bc1e-b12ceb79929c':
        size 2 GiB in 512 objects
        order 22 (4 MiB objects)
        snapshot_count: 0
        id: 34501f714dc9b
        block_name_prefix: rbd_data.34501f714dc9b
        format: 2
        features: layering
        op_features:
        flags:
        create_timestamp: Tue Jun 24 11:29:48 2025
        access_timestamp: Tue Jun 24 11:29:48 2025
        modify_timestamp: Tue Jun 24 11:29:48 2025
0
Subscribe to my newsletter

Read articles from Rivaldy Ahmad Azhar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rivaldy Ahmad Azhar
Rivaldy Ahmad Azhar