|NO.Z.00247|——————————|CloudNative|——|KuberNetes&存储进阶.V13|——|Ceph.v07|ceph测试|共享文件系统|

一、共享文件系统的使用
### --- 创建共享类型的文件系统
~~~     共享文件系统一般用于多个pod共享一个存储
~~~     切换到filesystem配置文件目录下

[root@k8s-master01 kubernetes]# cd /root/rook/cluster/examples/kubernetes/ceph
### --- 创建filesystem.yaml

[root@k8s-master01 ceph]# kubectl  create -f filesystem.yaml
cephfilesystem.ceph.rook.io/myfs created
### --- 创建完成后会启动mds容器,需要等待启动后才可进行创建pv

[root@k8s-master01 ceph]# kubectl -n rook-ceph get pod -l app=rook-ceph-mds -owide
NAME                                   READY   STATUS    RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
rook-ceph-mds-myfs-a-8d657f8dc-mx7z7   1/1     Running   0          2m32s   172.17.125.18    k8s-node01     <none>           <none>
rook-ceph-mds-myfs-b-69bf9dc67-vr97t   1/1     Running   0          98s     172.25.244.209   k8s-master01   <none>           <none>

二、也可以在ceph dashboard上面查看状态

三、创建共享文件系统的StorageClass
### --- 切换到StorageClass创建目录下并创建共享文件系统的pod
~~~     之后将pvc的storageClassName设置成rook-cephfs即可创建共享文件类型的存储,类似于NFS,可以给多个Pod共享数据。

[root@k8s-master01 cephfs]# pwd
/root/rook/cluster/examples/kubernetes/ceph/csi/cephfs
[root@k8s-master01 cephfs]# kubectl create -f storageclass.yaml
storageclass.storage.k8s.io/rook-cephfs created
四、挂载测试
### --- 进出创建目录下并执行创建

[root@k8s-master01 cephfs]# pwd
/root/rook/cluster/examples/kubernetes/ceph/csi/cephfs
[root@k8s-master01 cephfs]# ls
kube-registry.yaml  pod.yaml  pvc-clone.yaml  pvc-restore.yaml  pvc.yaml  snapshotclass.yaml  snapshot.yaml  storageclass.yaml
[root@k8s-master01 cephfs]# kubectl create -f kube-registry.yaml 
persistentvolumeclaim/cephfs-pvc created
deployment.apps/kube-registry created
### --- 查看创建的PVC和pod

[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          2m20s   172.27.14.204    k8s-node02     <none>           <none>
kube-registry-66d4c7bf47-tmp4c   1/1     Running   0          2m20s   172.17.125.22    k8s-node01     <none>           <none>
kube-registry-66d4c7bf47-tvxvb   1/1     Running   0          2m20s   172.25.244.212   k8s-master01   <none>           <none>
[root@k8s-master01 cephfs]# kubectl get pvc -n kube-system -owide
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE     VOLUMEMODE
cephfs-pvc   Bound    pvc-2ca6f479-124b-464a-85ab-cf307109f907   1Gi        RWX            rook-cephfs    3m13s   Filesystem    
### --- 该配置文件的pvc配置,用于连接ceph创建存储,如下:
~~~     注意claimName为pvc的名称。
~~~     此时一共创建了三个Pod,这三个Pod共用了一个存储,挂载到了/var/lib/registry,该目录三个容器共享数据。

[root@k8s-master01 cephfs]# vim kube-registry.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: cephfs-pvc
  namespace: kube-system
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
  storageClassName: rook-cephfs
# 然后在deployment的volumes配置添加了该pvc,并将其挂载到了/var/lib/registry    
        volumeMounts:
        - name: image-store
          mountPath: /var/lib/registry
************省略部分内容***************
      volumes:
      - name: image-store
        persistentVolumeClaim:
          claimName: cephfs-pvc
          readOnly: false  

 
 
 
 
 
 
 
 
 

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

 

 

posted on   yanqi_vip  阅读(35)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示