最新消息:时间抓起来说是金子,抓不住就是流水。

K8S挂载SFS(NFS)

Kubernetes 老子黑牵翻 815浏览 0评论

1、添加PV配置

# vi pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: abc-pv
spec:
  #pv的大小
  capacity:
    storage: 100Gi
  #PV的卷模式
  volumeMode: Filesystem
  #PV的访问模式
  accessModes:
    - ReadWriteMany
  #PV的回收策略
  persistentVolumeReclaimPolicy: Retain
  storageClassName: abc-nfs
  #PV的类型为nfs
  nfs:
    #nfs共享目录
    path: /
    #nfs服务器地址
    server: 10.0.0.93

2、添加PVC配置

# vi pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: abc-pvc
  namespace: test
spec:
  #访问模式
  accessModes:
    - ReadWriteMany
  #卷模式
  volumeMode: Filesystem
  #请求的存储大小
  resources:
    requests:
      storage: 100Gi
  storageClassName: abc-nfs

3、配置deployment

# vi de.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: abc-test
  namespace: test
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: abc-test
  template:
    metadata:
      labels:
        app: abc-test
    spec:
      containers:
      - name: abc-test
        image: abc/abc:latest
        imagePullPolicy: Always
        volumeMounts:
        - name: abc-shared-storage
          mountPath: /data/abc
        ports:
        - containerPort: 8080
      volumes:
      - name: abc-shared-storage
        persistentVolumeClaim:
          claimName: abc-pvc

4、K8S执行YAML文件

kubectl apply -f pv.yaml
kubectl apply -f pvc.yaml
kubectl apply -f de.yaml

转载请注明:LINUX服务器运维架构技术分享 » K8S挂载SFS(NFS)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址