1. 程式人生 > 其它 >|NO.Z.00248|——————————|CloudNative|——|KuberNetes&儲存進階.V14|-------------------------------------------------------|Ceph.v08|ceph測試|PVC擴容|

|NO.Z.00248|——————————|CloudNative|——|KuberNetes&儲存進階.V14|-------------------------------------------------------|Ceph.v08|ceph測試|PVC擴容|



[CloudNative:KuberNetes&儲存進階.V14]                                                               [Applications.KuberNetes] [|DevOps|k8s|雲原生儲存及儲存進階|**3節點.下**|ceph儲存叢集的測試|








一、PVC擴容
### --- PVC擴容說明

~~~     檔案共享型別的PVC擴容需要k8s 1.15+
~~~     塊儲存型別的PVC擴容需要k8s 1.16+
~~~     PVC擴容需要開啟ExpandCSIVolumes,新版本的k8s已經預設打開了這個功能,
~~~     可以檢視自己的k8s版本是否已經預設打開了該功能:
### --- 如果default為true就不需要開啟此功能,如果default為false,需要開啟該功能。

[root@k8s-master01 cephfs]# kube-apiserver -h |grep ExpandCSIVolumes
                                                     ExpandCSIVolumes=true|false (BETA - default=true)
二、擴容檔案共享型PVC

### --- 找到剛才建立的檔案共享型StorageClass,
~~~     將allowVolumeExpansion設定為true(新版rook預設為true,如果不為true更改後執行kubectl replace即可):

[root@k8s-master01 ~]# cd /root/rook/cluster/examples/kubernetes/ceph/csi/cephfs
[root@k8s-master01 cephfs]# vim storageclass.yaml 
reclaimPolicy: Delete
allowVolumeExpansion: true      // 設定為true
mountOptions:
三、找到第六章建立的pvc
### --- 擴容PVC
~~~     注:將大小修改為2Gi,之前是1Gi
~~~     儲存退出

[root@k8s-master01 cephfs]# kubectl  get pvc -n kube-system
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
cephfs-pvc   Bound    pvc-2ca6f479-124b-464a-85ab-cf307109f907   1Gi        RWX            rook-cephfs    12m
[root@k8s-master01 cephfs]# kubectl  edit pvc cephfs-pvc -n kube-system
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 2Gi                  
四、檢視PV和PVC的大小
[root@k8s-master01 cephfs]# kubectl  get pvc -n kube-system
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
cephfs-pvc   Bound    pvc-2ca6f479-124b-464a-85ab-cf307109f907   2Gi        RWX            rook-cephfs    15m
[root@k8s-master01 cephfs]#  kubectl  get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                    STORAGECLASS      REASON   AGE
pvc-2ca6f479-124b-464a-85ab-cf307109f907   2Gi        RWX            Delete           Bound    kube-system/cephfs-pvc   rook-cephfs                15m
pvc-a22e54cf-9d96-4070-b3a7-90a2fa73c249   20Gi       RWO            Delete           Bound    default/mysql-pv-claim   rook-ceph-block            48m
五、檢視容器內是否已經完成擴容
~~~     # 同樣的方案可以定義自己需求擴容的大小

[root@k8s-master01 cephfs]# kubectl get po -n kube-system -l k8s-app=kube-registry -owide
NAME                             READY   STATUS    RESTARTS   AGE   IP               NODE           NOMINATED NODE   READINESS GATES
kube-registry-66d4c7bf47-b87w4   1/1     Running   0          17m   172.27.14.204    k8s-node02     <none>           <none>
kube-registry-66d4c7bf47-tmp4c   1/1     Running   0          17m   172.17.125.22    k8s-node01     <none>           <none>
kube-registry-66d4c7bf47-tvxvb   1/1     Running   0          17m   172.25.244.212   k8s-master01   <none>           <none>
[root@k8s-master01 cephfs]# kubectl exec -ti kube-registry-66d4c7bf47-b87w4 -n kube-system -- df -Th | grep "/var/lib/registry"
                     ceph            2.0G         0      2.0G   0% /var/lib/registry








===============================END===============================


Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart                                                                                                                                                    ——W.S.Landor



來自為知筆記(Wiz)