数据持久化 - 二

准备 PV 与 PVC

circle-check

准备创建 PV 所需的 yaml 文件

准备3个 yaml 文件 pv1.yaml、pv2.yaml、pv3.yaml

cat > pv1.yaml << EOF
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv1
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    server: 10.0.0.31
    path: "/data/pv1"
    readOnly: false
EOF

准备创建 PVC 所需的 yaml 文件

此处的 pvc的yaml 文件名为 mysql-pvc.yaml

创建 PV PVC

查看 PV 与 PVC

使用 PVC

准备 Deployment 资源的 yaml 文件

triangle-exclamation

创建 Deployment 资源

检验数据持久化结果

方式一:

方式二:

Last updated