Skip to content

Instantly share code, notes, and snippets.

@predam
Last active September 26, 2021 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save predam/1463121b9a8e16fa685faa9adf612c1e to your computer and use it in GitHub Desktop.
Save predam/1463121b9a8e16fa685faa9adf612c1e to your computer and use it in GitHub Desktop.
Use FreeNAS/TrueNAS storage as k8s PVC
csiDriver:
# should be globally unique for a given cluster
name: "org.democratic-csi.nfs"
# add note here about volume expansion requirements
storageClasses:
- name: freenas-nfs-csi
defaultClass: false
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true
parameters:
# for block-based storage can be ext3, ext4, xfs
# for nfs should be nfs
fsType: nfs
# if true, volumes created from other snapshots will be
# zfs send/received instead of zfs cloned
# detachedVolumesFromSnapshots: "false"
# if true, volumes created from other volumes will be
# zfs send/received instead of zfs cloned
# detachedVolumesFromVolumes: "false"
mountOptions:
- noatime
- nfsvers=4
secrets:
provisioner-secret:
controller-publish-secret:
node-stage-secret:
node-publish-secret:
controller-expand-secret:
# if your cluster supports snapshots you may enable below
volumeSnapshotClasses: []
#- name: freenas-nfs-csi
# parameters:
# # if true, snapshots will be created with zfs send/receive
# # detachedSnapshots: "false"
# secrets:
# snapshotter-secret:
driver:
config:
# please see the most up-to-date example of the corresponding config here:
# https://github.com/democratic-csi/democratic-csi/tree/master/examples
# YOU MUST COPY THE DATA HERE INLINE!
driver: freenas-nfs
instance_id:
httpConnection:
protocol: http
host: <TRUENAS_IP>
port: 80
username: root
password: "replaceme"
allowInsecure: true
sshConnection:
host: <TRUENAS_IP>
port: 22
username: root
# use either password or key
password: "replaceme"
# privateKey: |
# -----BEGIN RSA PRIVATE KEY-----
# ...
# -----END RSA PRIVATE KEY-----
zfs:
datasetParentName: <pool_name><dataset_name>/vols
detachedSnapshotsDatasetParentName: <pool_name><dataset_name>/snaps
datasetEnableQuotas: true
datasetEnableReservation: false
datasetPermissionsMode: "0777"
datasetPermissionsUser: root
datasetPermissionsGroup: wheel
nfs:
shareHost: <TRUENAS_IP>
shareAlldirs: false
shareAllowedHosts: []
shareAllowedNetworks: []
shareMaprootUser: root
shareMaprootGroup: wheel
shareMapallUser: ""
shareMapallGroup: ""
  1. Create new dataset in TrueNAS pool
  2. Enable NFS sharing for dataset
  3. Enable NFS service
  • Make sure that NFS version is V4
  1. Enable SSH
  2. Install NFS on k8s host sudo apt-get install -y nfs-common
  3. Copy & Config freenas-nfs.yaml
  4. Make sure you have Helm installed
  5. Add helm repo helm repo add democratic-csi https://democratic-csi.github.io/charts/ helm repo update
  6. helm upgrade --install --create-namespace --values freenas-nfs.yaml --namespace democratic-csi --kubeconfig kube-config.yaml zfs-nfs democratic-csi/democratic-csi

More info https://github.com/democratic-csi/democratic-csi

  • If you want to update the configuration, change freenas-nfs.yaml file and run the command again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment