当前位置: 首页 > 工具软件 > docker-ceph > 使用案例 >

rook-ceph PV扩容

宰父学
2023-12-01

rook-ceph PV扩容

首先确认pod所在的node节点,如下:

[root@master1 ~]# kubectl get po -n xntest redis-85c75fd7f4-h6h4h -o wide
NAME                     READY   STATUS    RESTARTS   AGE    IP              NODE      NOMINATED NODE   READINESS GATES
redis-85c75fd7f4-h6h4h   1/1     Running   0          7d4h   170.80.180.52   master2   <none>           <none>

查找pod的pvc

[root@master1 ~]# kubectl get pvc -n xntest redis-data 
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
redis-data   Bound    pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09   5Gi        RWO            ceph-rbd       7d4h
[root@master2 ~]# df -h|grep pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09
/dev/rbd1                4.9G   21M  4.9G   1% /var/lib/kubelet/pods/826d9f4f-4291-41b7-acde-8e390c0a1f0c/volumes/kubernetes.io~csipvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09/mount

通过PVC查找 pv ,找到 imageName 字段,这个字段值就是rbd镜像块

[root@master1 ~]# kubectl get pv pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09 -o yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/provisioned-by: rook-ceph.rbd.csi.ceph.com
  creationTimestamp: "2022-04-29T03:09:51Z"
  finalizers:

 kubernetes.io/pv-protection
name: pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09
  resourceVersion: "49578312"
  uid: ebd5f96b-b6b3-4130-8d91-3b1694eee955
spec:
  accessModes:

ReadWriteOnce
capacity:
storage: 5Gi
  claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: redis-data
namespace: xntest
resourceVersion: "49578293"
uid: ac6a5c47-1e84-4689-a7cb-3808f3071c09
  csi:
controllerExpandSecretRef:
  name: rook-csi-rbd-provisioner
  namespace: rook-ceph
driver: rook-ceph.rbd.csi.ceph.com
fsType: ext4
nodeStageSecretRef:
name: rook-csi-rbd-node
namespace: rook-ceph
volumeAttributes:
clusterID: rook-ceph
csi.storage.k8s.io/pv/name: pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09
csi.storage.k8s.io/pvc/name: redis-data
csi.storage.k8s.io/pvc/namespace: xntest
imageFeatures: layering
imageFormat: "2"
imageName: csi-vol-d5dfc0a4-c769-11ec-b83f-86c16b53daf3
journalPool: replicapool
pool: replicapool
storage.kubernetes.io/csiProvisionerIdentity: 1650579489320-8081-rook-ceph.rbd.csi.ceph.com
volumeHandle: 0001-0009-rook-ceph-0000000000000002-d5dfc0a4-c769-11ec-b83f-86c16b53daf3
persistentVolumeReclaimPolicy: Delete
storageClassName: ceph-rbd
volumeMode: Filesystem
status:
phase: Bound

之后登入rook-ceph-tools 工具端进行检查扩容

[root@master1 ~]# kubectl exec -it -n rook-ceph rook-ceph-tools-78cdfd976c-hvdhw /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
[root@rook-ceph-tools-78cdfd976c-hvdhw /]# rbd info --pool  replicapool csi-vol-d5dfc0a4-c769-11ec-b83f-86c16b53daf3
rbd image 'csi-vol-d5dfc0a4-c769-11ec-b83f-86c16b53daf3':
	size 5 GiB in 1280 objects
	order 22 (4 MiB objects)
	snapshot_count: 0
	id: 7ebd4cf11a0d5f
	block_name_prefix: rbd_data.7ebd4cf11a0d5f
	format: 2
	features: layering
	op_features: 
	flags: 
	create_timestamp: Fri Apr 29 03:09:51 2022
	access_timestamp: Fri Apr 29 03:09:51 2022
	modify_timestamp: Fri Apr 29 03:09:51 2022

扩容命令

[root@rook-ceph-tools-78cdfd976c-hvdhw /]# rbd resize --size 8192 --pool replicapool csi-vol-d5dfc0a4-c769-11ec-b83f-86c16b53daf3
Resizing image: 100% complete...done.
[root@rook-ceph-tools-78cdfd976c-hvdhw /]# rbd info --pool  replicapool csi-vol-d5dfc0a4-c769-11ec-b83f-86c16b53daf3
rbd image 'csi-vol-d5dfc0a4-c769-11ec-b83f-86c16b53daf3':
	size 8 GiB in 2048 objects
	order 22 (4 MiB objects)
	snapshot_count: 0
	id: 7ebd4cf11a0d5f
	block_name_prefix: rbd_data.7ebd4cf11a0d5f
	format: 2
	features: layering
	op_features: 
	flags: 
	create_timestamp: Fri Apr 29 03:09:51 2022
	access_timestamp: Fri Apr 29 03:09:51 2022
	modify_timestamp: Fri Apr 29 03:09:51 2022

扩容成功后,进入pod所在的主机

xfs存储 : xfs_growfs /dev/rbd1
ext存储: resize2fs /dev/rbd1

扩容完成后检查

[root@master2 ~]# df -h|grep pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09
/dev/rbd1                7.9G   23M  7.8G   1% /var/lib/kubelet/pods/826d9f4f-4291-41b7-acde-8e390c0a1f0c/volumes/kubernetes.io~csipvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09/mount

通过PVC查看容量显示不正确,这个是应为PVC编排的值没变,所以不用在意

[root@master1 ~]# kubectl get pv pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09 
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE
pvc-ac6a5c47-1e84-4689-a7cb-3808f3071c09   5Gi        RWO            Delete           Bound    xntest/redis-data   ceph-rbd                7d4h
 类似资料: