文章大纲
Toolbox
Rook 提供了一个 toolbox 容器,用于 Ceph 集群的测试和 debug,使用 Rook 项目中提供的 deploy/examples/toolbox.yaml
文件可以非常方便的部署:
kubectl apply -f https://raw.githubusercontent.com/rook/rook/release-1.13/deploy/examples/toolbox.yaml
检查 toolbox 是否正常运行:
[vagrant@master01 rook-ceph]$ kubectl get pods -n rook-ceph | grep tools
rook-ceph-tools-66b77b8df5-x97q4 1/1 Running 6 27d
使用 Toolbox 进行测试
在 toolbox 中已经安装了 ceph
客户端工具,并且相应的 keyring 已经通过 secret 注入到 Pod 中,可以通过交互的方式去检查集群的状态:
[vagrant@master01 rook-ceph]$ kubectl exec -it rook-ceph-tools-66b77b8df5-x97q4 -n rook-ceph -- /bin/ceph -s
cluster:
id: f8bdb7b9-12c8-4814-b4a2-6122366ddd1a
health: HEALTH_OK
services:
mon: 3 daemons, quorum a,b,c (age 10m)
mgr: a(active, since 8m), standbys: b
osd: 3 osds: 3 up (since 9m), 3 in (since 3w)
data:
pools: 1 pools, 1 pgs
objects: 2 objects, 449 KiB
usage: 76 MiB used, 60 GiB / 60 GiB avail
pgs: 1 active+clean
查看集群 osd 的信息:
[vagrant@master01 rook-ceph]$ kubectl exec -it rook-ceph-tools-66b77b8df5-x97q4 -n rook-ceph -- /bin/ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 0.05846 root default
-7 0.01949 host master01-example-com
2 hdd 0.01949 osd.2 up 1.00000 1.00000
-3 0.01949 host worker01-example-com
0 hdd 0.01949 osd.0 up 1.00000 1.00000
-5 0.01949 host worker02-example-com
1 hdd 0.01949 osd.1 up 1.00000 1.00000
查看集群 Pool 的信息:
[vagrant@master01 rook-ceph]$ kubectl exec -it rook-ceph-tools-66b77b8df5-x97q4 -n rook-ceph -- /bin/ceph osd pool ls detail
pool 1 '.mgr' replicated size 3 min_size 2 crush_rule 0 object_hash rjenkins pg_num 1 pgp_num 1 autoscale_mode on last_change 31 flags hashpspool stripe_width 0 pg_num_max 32 pg_num_min 1 application mgr
可以看到默认部署 Rook 后只有一个用于 manager 的池。
创建新的池
应用在使用 Ceph 提供的存储之前,需要在 Ceph 集群中创建池,可以直接通过在 Toolbox 中通过 ceph
客户端创建,也可以通过 Kubernetes 基于 CRD 进行创建。
创建复制池
Rook 提供了 CephBlockPool
CRD 来创建 RBD 池,例如创建一个名为 replicapool
的三副本的复制池 replicapool.yaml
:
apiVersion: ceph.rook.io/v1
kind: CephBlockPool
metadata:
name: replicapool
namespace: rook-ceph
spec:
failureDomain: host
replicated:
size: 3
创建纠删代码池
纠删代码池也是通过 CephBlockPool
CRD 进行创建,例如创建一个名为 ecpool
的纠删代码池 ecpool.yaml
:
apiVersion: ceph.rook.io/v1
kind: CephBlockPool
metadata:
name: ecpool
namespace: rook-ceph
spec:
failureDomain: osd
erasureCoded:
dataChunks: 2
codingChunks: 1
上述定义中使用的纠删代码是 2 个 dataChunks + 1 个 condingChunks ,同样需要三个 OSD,但是利用率是 75%,比三副本的 33% 要高。
应用并验证
将 repolicapool.yaml
和 ecpool.yaml
应用到集群:
[vagrant@master01 rook-ceph]$ kubectl apply -f replicapool.yaml
cephblockpool.ceph.rook.io/replicapool created
[vagrant@master01 rook-ceph]$ kubectl apply -f ecpool.yaml
cephblockpool.ceph.rook.io/ecpool created
验证相关池是否成功创建:
[vagrant@master01 rook-ceph]$ kubectl get CephBlockPool -n rook-ceph
NAME PHASE
ecpool Ready
replicapool Ready
[vagrant@master01 rook-ceph]$ kubectl exec -it rook-ceph-tools-66b77b8df5-x97q4 -n rook-ceph -- /bin/ceph osd pool ls
.mgr
replicapool
ecpool
查看池的详细信息:
[vagrant@master01 rook-ceph]$ kubectl exec -it rook-ceph-tools-66b77b8df5-x97q4 -n rook-ceph -- /bin/ceph osd pool ls detail
pool 1 '.mgr' replicated size 3 min_size 2 crush_rule 0 object_hash rjenkins pg_num 1 pgp_num 1 autoscale_mode on last_change 31 flags hashpspool stripe_width 0 pg_num_max 32 pg_num_min 1 application mgr
pool 2 'replicapool' replicated size 3 min_size 2 crush_rule 2 object_hash rjenkins pg_num 32 pgp_num 32 autoscale_mode on last_change 110 lfor 0/0/108 flags hashpspool,selfmanaged_snaps stripe_width 0 application rbd
pool 3 'ecpool' erasure profile ecpool_ecprofile size 3 min_size 2 crush_rule 3 object_hash rjenkins pg_num 32 pgp_num 32 autoscale_mode on last_change 124 lfor 0/0/122 flags hashpspool,ec_overwrites,selfmanaged_snaps stripe_width 8192 application rbd
查看纠删代码池对应的 erasure profile 的信息:
[vagrant@master01 rook-ceph]$ kubectl exec -it rook-ceph-tools-66b77b8df5-x97q4 -n rook-ceph -- /bin/ceph osd erasure-code-profile get ecpool_ecprofile
crush-device-class=
crush-failure-domain=host
crush-root=default
jerasure-per-chunk-alignment=false
k=2
m=1
plugin=jerasure
technique=reed_sol_van
w=8