还在篮子里

NFS 存储搭建 · 语雀

NFS 存储搭建

本文指导在 Rancher 上搭建一个 NFS 动态分配 持久化存储的  PV

Step

  1. 打开应用商店找到 NFS Server Provisioner
  2. image.png

或者使用 📎nfs.yaml 导入。配置

  1. 启动,可以观察到 NFS 显示无可用 PV(查看日志)
  2. 添加 PV ,注意以下配置(自己选择一个目录作为存储地点)

image.png

  1. 完成后其他应用使用 nfs 的存储类即可分配(PVC 不可超过其大小)

下面是三种方式搭建 nfs ,我们使用的是第二种,需要在每一个 replica 上面都申请一个 PV。

The following is a recommended configuration example when another storage class

exists to provide persistence:

persistence:
  enabled: true
  storageClass: "standard"
  size: 200Gi
storageClass:
  defaultClass: true

On many clusters, the cloud provider integration will create a “standard” storage

class which will create a volume (e.g. a Google Compute Engine Persistent Disk or

Amazon EBS volume) to provide persistence.


The following is a recommended configuration example when another storage class

does not exist to provide persistence:

persistence:
  enabled: true
  storageClass: "-"
  size: 200Gi
storageClass:
  defaultClass: true

In this configuration, a PersistentVolume must be created for each replica

to use. Installing the Helm chart, and then inspecting the PersistentVolumeClaim‘s

created will provide the necessary names for your PersistentVolume‘s to bind to.

An example of the necessary PersistentVolume:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: data-nfs-server-provisioner-0
spec:
  capacity:
    storage: 200Gi
  accessModes:
    - ReadWriteOnce
  gcePersistentDisk:
    fsType: "ext4"
    pdName: "data-nfs-server-provisioner-0"
  claimRef:
    namespace: kube-system
    name: data-nfs-server-provisioner-0

The following is a recommended configration example for running on bare metal with a hostPath volume:

persistence:
  enabled: true
  storageClass: "-"
  size: 200Gi
storageClass:
  defaultClass: true
nodeSelector:
  kubernetes.io/hostname: {node-name}

In this configuration, a PersistentVolume must be created for each replica

to use. Installing the Helm chart, and then inspecting the PersistentVolumeClaim‘s

created will provide the necessary names for your PersistentVolume‘s to bind to.

An example of the necessary PersistentVolume:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: data-nfs-server-provisioner-0
spec:
  capacity:
    storage: 200Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /srv/volumes/data-nfs-server-provisioner-0
  claimRef:
    namespace: kube-system
    name: data-nfs-server-provisioner-0

Warning: hostPath volumes cannot be migrated between machines by Kubernetes, as such,

in this example, we have restricted the nfs-server-provisioner pod to run on a single node. This

is unsuitable for production deployments.

来源: NFS 存储搭建 · 语雀

发表评论

电子邮件地址不会被公开。 必填项已用*标注