建立NFS型別的儲存

吃吃吃大王發表於2024-03-21

安裝NFS,設定共享目錄

#centos
yum -y install nfs-utils
#ubuntu
apt install nfs-server
#啟動RPC服務
start rpcbind
#建立共享目錄
mkdir -p /data/share
共享目錄
vim /etc/exports
  /data/share *(rw,no_root_squash)

exportfs -arv

掛載NFS

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deploy-nfs
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nfs
  template:
    metadata:
      name: deploy-nfs
      labels:
        app: nfs
    spec:
      containers:
      - name: test-nfs
        image: harbor.com/nginx:1.20.1
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: nfs-volumes
          mountPath: /usr/share/nginx/html         #掛載到容器的/usr/share/nginx/html路徑
      volumes:
      - name: nfs-volumes                          #卷名稱
        nfs:
          server: 10.16.17.57                      #設定共享的伺服器地址
          path: /data/share                        #共享目錄

相關文章