美文网首页
nfs存储类

nfs存储类

作者: 六弦极品 | 来源:发表于2024-04-07 19:45 被阅读0次

配置文件: rbac.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: common
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: common
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: common
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: common
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: common
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io

配置文件:deployment.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nfs-client-provisioner
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
#      imagePullSecrets:
#      - name: reg
      containers:
        - name: nfs-client-provisioner
          image: reg.llschain.com/base/nfs-client-provisione:latest
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: fuseim.pri/ifs
            - name: NFS_SERVER
              value: 10.51.10.11
            - name: NFS_PATH
              value: /opt/pvctest
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.51.10.11
            path: /opt/pvctest

配置文件:sc.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
  archiveOnDelete: "true"

创建资源执行命令:

kubectl create namespace common
kubectl apply -f rbac.yaml -f deployment.yaml -f sc.yaml -n common

验证是否可用创建pvc
配置文件:nginx-statefulset-pv.yaml

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: nginx 
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteMany" ]
      storageClassName: "managed-nfs-storage"
      resources:
        requests:
          storage: 1Gi

相关文章

  • NFS企业级网络存储服务

    1、什么是NFS? 2、为什么要用共享存储? 3、共享存储的种类 4、NFS工作原理 5、安装 6、配置nfs 实...

  • Centos7.6NFS储存服务

    NFS存储服务概念 NFS详解.png NFS工作流程 储存服务存在的意义 可以实现数据统一共享存储 节省架构服务...

  • k8s配置htps证书

    配置nfs-存储

  • day34-NFS

    1.什么是NFS network file system (网络文件/nfs共享存储) 2.nfs能干什么 nfs...

  • kubernetes(k8s)jenkins+gitlab自动化

    一、共享存储NFS部署 1、关闭防火墙 2、安装配置 nfs 3、共享目录设置权限: 4、配置 nfs,nfs 的...

  • kubernetes持久化存储-StorageClass

    创建StorageClass持久化存储 以NFS 作为后端存储资源,在主节点安装NFS,共享/data/k8s/目...

  • openshift持久化存储

    存储支持方式:NFS、GlusterFs、cep、samba等以下以NFS为例,构建pod的持久化存储1.创建NF...

  • NFS

    第1章 存储与nfs存储概述 1.为什么用共享存储2.存储有哪些工具3.共享存储应用场景有哪些4.部署nfs共享存...

  • 03期中架构-NFS

    第1章 存储与nfs存储概述 1.为什么用共享存储2.存储有哪些工具3.共享存储应用场景有哪些4.部署nfs共享存...

  • NFS共享存储

    第1章 存储与nfs存储概述 1.为什么用共享存储2.存储有哪些工具3.共享存储应用场景有哪些4.部署nfs共享存...

网友评论

      本文标题:nfs存储类

      本文链接:https://www.haomeiwen.com/subject/ltdtxjtx.html