一、PV
1、编写yml:k8s_nfs_pv_data.yml
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16apiVersion: v1 kind: PersistentVolume metadata: name: pv0001 labels: type: nfs001 spec: capacity: storage: 128Mi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Recycle nfs: path: "/Users/chenfenli/Bin/kubernetes/data" server: 127.0.0.1 readOnly: false
2、创建pv
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21MacBook-Air:test chenfenli$ kubectl create -f k8s_nfs_pv_data.yml persistentvolume/pv0001 created MacBook-Air:test chenfenli$ kubectl get pv -o wide NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE VOLUMEMODE pv0001 128Mi RWX Recycle Available 18m Filesystem MacBook-Air:test chenfenli$
二、PVC
1、编写yml:k8s_nfs_pvc_mysql.yml
复制代码
1
2
3
4
5
6
7
8
9
10apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pv0001 spec: accessModes: - ReadWriteMany resources: requests: storage: 36Mi
- pvc的metadata.name 跟上面pv的metadata.name 保持一致
2、创建pvc
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20MacBook-Air:test chenfenli$ kubectl create -f k8s_nfs_pvc_mysql.yml persistentvolumeclaim/pv0001 created MacBook-Air:test chenfenli$ kubectl get pvc -o wide NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODE pv0001 Bound pvc-6d99e164-cb7b-464c-8fa1-c1254fb13b18 36Mi RWX hostpath 8s Filesystem MacBook-Air:test chenfenli$
最后
以上就是无限裙子最近收集整理的关于Kubernetes-4: 共享持久化存储 PV、PVC的全部内容,更多相关Kubernetes-4:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复