Kubernetes: Dynamic Storage Constant Volume Using NFS

I have multi node setup kubernetes. I am trying to distribute a persistent volume dynamically using storage classes with an NFS volume plugin. I found examples of storage classes for glusterfs, aws-ebs, etc., but I did not find any examples for NFS. If I create only PV and PVC, then NFS works very well (without storage class). I tried to write a storage class file for NFS, specifying other plugins. see below,

Nfs-storage-class.yaml

kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  namespace: kube-system
  name: my-storage
  annotations:
    storageclass.beta.kubernetes.io/is-default-class: "true"
  labels:
    kubernetes.io/cluster-service: "true"

provisioner: kubernetes.io/nfs
parameters:
  path: /nfsfileshare
  server: <nfs-server-ip> 

NFS-en-claim.yaml

apiVersion: v1
metadata:
  name: demo-claim
  annotations:
    volume.beta.kubernetes.io/storage-class: my-storage
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

This did not work. So my question is: can we write a storage class for NFS? Does it support dynamic redundancy?

+11
source share
5 answers
+2

StorageClass , ( "Provisioner", kubernetes docs). NFS , . , StorageClass. , .

+1

NFS kubernetes, , , rbac.yaml ( PR, ).

nfs , : https://github.com/kubernetes-incubator/external-storage/tree/master/nfs#quickstart

$ kubectl create -f deploy/kubernetes/deployment.yaml
$ kubectl create -f deploy/kubernetes/rbac.yaml
$ kubectl create -f deploy/kubernetes/class.yaml

PVC :

$ kubectl create -f deploy/kubernetes/claim.yaml

, , deployment.yaml .

+1

PV, . PV PVC , . nfs nfs/etc/exports .

example:
/mnt/disks/vol1 <IP ADDRESS OF THE NODE>(rw,sync,no_root_squash,no_all_squash)

registry-pv.yml -

apiVersion: v1
kind: PersistentVolume
metadata:
  name: registry-pv
  namespace: kube-system
spec:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 50Gi
  nfs:
    path: /mnt/disks/vol1
    server: <IP-Address of NFS SERVER>
  persistentVolumeReclaimPolicy: Retain
  storageClassName: registry-storage

registry-pvc.yml -

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: registry-pvc
  namespace: kube-system
  labels:
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: registry-storage
  volumeName: registry-pv
  resources:
    requests:
      storage: 50Gi

, -

kubectl create -f registry-pv.yml 
kubectl create -f registry-pvc.yml

PV -

enter image description here

0
source

Source: https://habr.com/ru/post/1674375/


All Articles