• NFS使用-动态供应


    介绍

    参考

    https://blog.csdn.net/qq_41586875/article/details/120832198
    https://help.aliyun.com/document_detail/63956.html

    存储类搭建

    1. 首先搭建NFS-SERVER
    2. 其次创建NFS-Subdir-External-Provisioner
    3. 最后创建NFS StorageClass
      此时存储类就搭建完成

    使用

    1. 存储类使用,先创建PVC,从存储类动态分配PV
    2. 负载再绑定PV使用

    正文

    简介

    1、创建NFS-Subdir-External-Provisioner
    1-sep.yaml
    2、创建NFS StorageClass
    2-sc.yaml

    3、创建PVC
    3-pvc.yaml

    4、负载绑定pv
    4-deplozyment.yaml

    5、创建service
    5-service.yaml

    1、 nfs插件

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nfs-client-provisioner
      labels:
        app: nfs-client-provisioner
      # replace with namespace where provisioner is deployed
      namespace: wz-app
    spec:
      replicas: 1
      strategy:
        type: Recreate
      selector:
        matchLabels:
          app: nfs-client-provisioner
      template:
        metadata:
          labels:
            app: nfs-client-provisioner
        spec:
    #      nodeName: k8s-master-1   #设置在master节点运行
    #      tolerations:             #设置容忍master节点污点
    #        - key: node-role.kubernetes.io/master
    #          operator: Equal
    #          value: "true"
    #      serviceAccountName: nfs-client-provisioner
          containers:
            - name: nfs-client-provisioner
              image: registry.cn-hangzhou.aliyuncs.com/jiayu-kubernetes/nfs-subdir-external-provisioner:v4.0.0
              imagePullPolicy: IfNotPresent
              volumeMounts:
                - name: nfs-client-root
                  mountPath: /persistentvolumes
              env:
                - name: PROVISIONER_NAME
                  value: k8s/nfs-subdir-external-provisioner
                - name: NFS_SERVER
                  value: 10.180.151.220
                - name: NFS_PATH
                  value: /home/inspur/nfs/sc
          volumes:
            - name: nfs-client-root
              nfs:
                server: 10.180.151.220  # NFS SERVER_IP
                path: /home/inspur/nfs/sc
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45

    2、 存储类

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: managed-nfs-storage
    provisioner: k8s/nfs-subdir-external-provisioner
    allowVolumeExpansion: true
    parameters:
      server: 10.180.151.220
      path: /home/inspur/wz/sc
      archiveOnDelete: "true" # 设置为"false"时删除PVC不会保留数据,"true"则保留数据
    reclaimPolicy: Retain
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    3、 pvc

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
        name: sc-pvc
      namespace: wz-app
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 1Gi
      storageClassName: managed-nfs-storage
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    4、 deployment

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: deploy-cloud-reve
      namespace: wz-app
      labels:
        app: d-cloud-reve
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: p-cloud-reve
      template:
        metadata:
          name: pod-web
          namespace: wz-app
          labels:
            app: p-cloud-reve
        spec:
          volumes:
            - name: cloud-reve-v21
              configMap:
                defaultMode: 420
                name: cloud-reve-v21
                items:
                  - key: conf.ini
                    path: conf.ini
            - name: cloud-reve-sc
              persistentVolumeClaim:
                claimName: sc-pvc
          containers:
            - name: c-cloud-reve
              image: 10.180.151.242/bot-app-store/bot-cloud-icloudfile/amd64:1.2.3
              ports:
                - containerPort: 5212
                  name: cloud-reve-port
              volumeMounts:
                - name: cloud-reve-v21
                  mountPath: /cloudreve/conf.ini
                  subPath: conf.ini
                - name: cloud-reve-sc
                  mountPath: /cloudreve/statics
                  subPath: statics
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    5、 service

    apiVersion: v1
    kind: Service
    metadata:
      name: svc-cloud-reve
      namespace: wz-app
    spec:
      selector:
        app: p-cloud-reve
      ports:
        - name: svc-cloud-reve-port
          protocol: TCP
          port: 5212
          nodePort: 31212
          targetPort: cloud-reve-port
      type: NodePort
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
  • 相关阅读:
    谷歌『云开发者速查表』;清华3D人体数据集;商汤『通用视觉框架』公开课;Web3极简入门指南;高效深度学习免费书;前沿论文 | ShowMeAI资讯日报
    ubuntu20.04 MYNTEYE S 相机运行与标定记录
    C/C++面试常见问题——指针和引用的区别
    STM32的hal库中,后缀带ex和不带的有什么区别
    前端框架Bootstrap
    AI 实战篇 |十分钟学会【动物识别】,快去寻找身边的小动物试试看吧【送书】
    Servlet学习(四):urlPattern配置与XML配置
    Shell脚本简单认知
    如何通过port-forward命令在本地访问 k8s 集群服务
    使用 Tesseract 在 C# 中进行光学字符识别(OCR)
  • 原文地址:https://blog.csdn.net/Edu_enth/article/details/126658332