首页 > 其他 > 详细

K8S 之 使用NFS作为挂久卷使用POD

时间:2020-04-26 23:11:47      阅读:188      评论:0      收藏:0      [点我收藏+]
一、NFS搭建情况
[root@test-operator nginx_index]# cat /etc/exports
/data/nfs-volume 10.3.153.0/24(rw,no_root_squash)
/data/nfs-volume/nginx_index 10.3.153.0/24(rw,no_root_squash)
[root@test-operator nginx_index]# pwd
/data/nfs-volume/nginx_index
[root@test-operator nginx_index]# cat index.html 
This is NFS Server File!!!!!

二、创建挂久卷

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs                #挂久卷的名称,pv没有表空间概念,保存在整个集群中
spec:
  storageClassName: manual          #用于配匹pvc声明卷
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany                       #同时多节点挂载读写
  persistentVolumeReclaimPolicy: Recycle      #当pod删除后,保留持久卷内容
  nfs:
    path: /data/nfs-volume/nginx_index
    server: test-operator.cedarhd.com

三、创建挂久卷明

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs
  namespace: test
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: manual               #与持久卷配匹
  resources:
    requests:
      storage: 1Gi

四、创建POD并挂载该挂久卷

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  namespace: test
spec:
  containers:
    - image: nginx:alpine
      name: web-server
      volumeMounts:
        - mountPath: /usr/share/nginx/html
          name: nfs                 #所挂载的持久卷的名称
      ports:
        - containerPort: 80
          protocol: TCP
  volumes:
    - name: nfs                  #持久卷的名称
      persistentVolumeClaim: 
        claimName: nfs           #持久卷的挂久声名

五、挂载情况

技术分享图片

参考文档:https://www.jianshu.com/p/1e870a8d6286

K8S 之 使用NFS作为挂久卷使用POD

原文:https://blog.51cto.com/12965094/2490491

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!