1、基于nfs创建pv
 apiVersion: v1
 kind: PersistentVolume
 metadata:
   name: newpv
 spec:
   capacity:
     storage: 5Gi
   accessModes:
     - ReadWriteOnce
   persistentVolumeReclaimPolicy: Recycle
   storageClassName: slow
   nfs:
     path: /zg-k8s-test-storage/k8s
     server: n0.XXta.nas.xxyun.com  ##这里写nfs的服务器路径。
2、创建pvc
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: slow
3、创建pod,关联PVC
kind: Pod
apiVersion: v1
metadata:
  name: mypod
spec:
  containers:
    - name: myfrontend
      image: harbor.XX.cn/library/nginx:zuol   #镜像路径
      volumeMounts:
      - mountPath: "/var/www/html"
        name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: myclaim

注意:红色的注意必须一致,紫色的也必须一致。

 

Logo

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

更多推荐