helm-csi-driver-nfs

by jfelten

Helm chartv0.1.0App 2.0.0MIT

A Kubnetes Helm chart that mounts NFS volumes hosted on a remote server.

About this chart

helm-csi-driver-nfs

A Kubnetes Helm chart that mounts NFS volumes hosted on a remote server.

Homepage: https://github.com/keyporttech/helm-charts

Introduction

This Kubernetes helm chart allows the management of Network File System (NFS) storage. It does this by deploying, to each node in the cluster, a pod running both the driver and CSI Node Driver Registrar sidecar containers. Applications can access existing NFS shares by simply specifying a Persistent Volume (PV) and Persistent Volume Claim (PVC).

This chart was developed and tested on kubernetes version 1.19, but should work on earlier or later versions.

Requirements

Kubernetes: >=1.14

  • helm 3 installation
  • Nodes have enought resources to run the chart pod.
  • Any one namespace to deploy into.
  • NFS Client installed on each node in the cluster.
  • An NFS server and existing accessible shares (confirm that the shares are accessible from one or more of the cluster nodes).

Images:

  • Node Driver Registrar: https://github.com/kubernetes-csi/node-driver-registrar
  • CSI NFS driver: https://github.com/kubernetes-csi/csi-driver-nfs

Installing the Chart

There are two methods that can be used to install the chart. The first is to use the chart from the Keyporttech Helm Repository.

helm repo add keyporttech https://keyporttech.github.io/helm-charts/
helm install my-release keyporttech/helm-csi-driver-nfs -n my-namespace

or clone this repo and install from the local file system.

$ helm install my-release . -n my-namespace

Tip: There should not be a need to modify any of the chart values. Use the default values.yaml file.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm uninstall my-release -n my-namespace

All resources associated with the last release of the chart as well as its release history will be deleted.

Storage

This chart enables applications to access existing NFS shares through PVs and PVCs. By default no shares will be deleted when the chart is uninstalled.

In the repository root folder there is a examples subfolder containing the nginx web server. It shows how to create a pv and pvc outside the chart so that an application can mount an existing NFS share.

Applications do not have to be installed into the same namespace as this chart. Already deployed applications can remain in their current namespace and be updated to use the driver.

See nginx pod example below. The following may need to change:

  • PV and PVC name
  • PV and PVC storage size
  • PV mountOptions and volumeAttributes
apiVersion: v1
kind: PersistentVolume
metadata:
  name: csi-driver-nfs-nodeplugin-pv
spec:
  #claimRef:
  #  name: csi-driver-nfs-nodeplugin-pvc
  #  namespace: apps
  accessModes:
  - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  storageClassName: csi-driver-nfs-nodeplugin
  mountOptions:
    - nfsvers=3
    - nolock
    #- hard
  csi:
    driver: nfs.csi.k8s.io
    volumeHandle: nginx-data-id
    volumeAttributes:
      # NFS server and mount path i.e. share or its subdirectory
      # server: IP or FQDN i.e. host.example.com
      server: 192.168.x.x
      share: /mnt/Pool/share/csi-dir
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: csi-driver-nfs-nodeplugin-pvc
spec:
  storageClassName: csi-driver-nfs-nodeplugin
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  #serviceAccount: csi-driver-nfs-nodeplugin
  containers:
  - image: maersk/nginx
    name: nginx
    ports:
    - containerPort: 80
      protocol: TCP
    volumeMounts:
      - mountPath: /var/www
        name: nginx-data-nfs-nodeplugin
  volumes:
  - name: nginx-data-nfs-nodeplugin
    persistentVolumeClaim:
      claimName: csi-driver-nfs-nodeplugin-pvc

This will enable direct communication between the NFS server and the CSI Driver running in the cluster.

Values

KeyTypeDefaultDescription
affinityobject{}List of rules for which nodes the pod is eligible to be scheduled. This method relies on node labels.
csiDriver.image.pullPolicystring"IfNotPresent"When the image is pulled
csiDriver.image.repositorystring"registry.keyporttech.com/csi-driver-nfs"Repository for the NFS CSI Driver
csiDriver.image.tagstring"2.0.0"Version tag for the image
csiDriver.namestring"nfs.csi.k8s.io"NFS CSI Driver name
csiDriver.securityContext.allowPrivilegeEscalationbooltrueCan the current user context of the container be changed
csiDriver.securityContext.capabilities.addlist["SYS_ADMIN"]System admininstrator capability
csiDriver.securityContext.privilegedbooltrueDoes the driver have operating system administrative capabilities
fullnameOverridestring"csi-driver-nfs-nodeplugin"If not empty, replaces the generated name for the deployment
imagePullSecretslist[]List of secrets used to pull a private images for the pod
nameOverridestring""If not empty, replaces the name of the chart
nodeSelectorobject{}List of key-value pairs used to select a node for pod deployment. In order for the node to be eligible it must have each of the specified key-value pairs as labels.
podAnnotationsobject{}A list of annotations for the pod
podSecurityContextobject{}Specifies the privilege and access control settings of the pod
rbac.enablebooltrueSpecfies whether ClusterRole and ClusterRoleBinding will be enabled for ServiceAccount
replicaCountint1Number of pods to load balance between
resourcesobject{}Specifies the cpu and memory to be allocated for the pod
serviceAccount.annotationsobject{}List of annotations for the account
serviceAccount.createbooltrueSpecifies whether a service account should be created
serviceAccount.namestring""The name of the service account. If empty, a name is generated.
sidecar.image.pullPolicystring"IfNotPresent"When the image is pulled
sidecar.image.repositorystring"k8s.gcr.io/sig-storage/csi-node-driver-registrar"Repository for the Registrar CSI Driver
sidecar.image.tagstring"v1.3.0"Version tag for the image
sidecar.namestring"csi-driver-registrar"Registrar CSI Driver name
sidecar.securityContextobject{}Specifies the privilege and access control settings of the container
storageClass.namestring""Name of the storage class supported by the driver. If empty, a name is generated.
tolerationslist[]List of tolerations which allow the pod to be scheduled onto nodes with matching taints

Source Code

Maintainers

NameEmailUrl
Keyport Technologies, Inc.[email protected]https://keyporttech.github.io/

Contributing

Please see keyporttech charts contribution guidelines

Deploy helm-csi-driver-nfs with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has helm-csi-driver-nfs on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthelm-csi-driver-nfs is pinned at v0.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply