k8s 创建数据存储PVC(Persistent Volume Claims)

1.创建pv

1.1 编写pv部署文件consul-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: consul-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.154.129
    path: /root/consul

1.2 创建pv

kubectl apply -f consul-pv.yaml

nfs安装步骤: https://blog.csdn.net/FengShiLiuNian/article/details/140297090

2.创建pvc

2.1编写pv部署文件consul-pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: consul-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi

2.2 部署pvc

kubectl apply -f consul-pvc.yaml

2.3 查看pvc状态

kubectl get pvc

期望结果如下:

NAME         STATUS   VOLUME      CAPACITY   ACCESS MODES   STORAGECLASS   AGE
consul-pvc   Bound    consul-pv   2Gi        RWX                           40m
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐