This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

CSI Driver

Provides overview information on the TrueNAS CSI driver integration with Kubernetes.

CSI Driver Overview

The TrueNAS CSI (Container Storage Interface) Driver is an official TrueNAS product that enables Kubernetes clusters to dynamically provision, manage, and consume storage from TrueNAS storage systems. The driver automatically creates storage volumes on-demand from Kubernetes, and leverages ZFS capabilities such as snapshots, clones, and compression in Kubernetes. The driver provides native Kubernetes integration via industry-standard CSI specifications.

The CSI driver supports snapshots, clones, ZFS compression (with no extra setup), and supports both file (NFS) and block (iSCSI) storage protocols. Standard Kubernetes uses K8s APIs and works with all K8s tooling. The CSI driver integration leverages TrueNAS investment in Kubernetes environments.

Storage administrators set up TrueNAS and the storage guardrails (StorageClasses), and thereafter developers can create the storage volumes they need through YAML files, bypassing the need to submit IT requests for the storage they need.

The CSI driver is ideal for:

  • Stateful applications in Kubernetes, like databases (PostgreSQL, MySQL, MongoDB), content management systems, CI/CD build caches, and application persistence.
  • DevOps and development, like development environments with persistent data, shared build artifacts, and testing environments
  • Data-intensive workloads, like big data processing (Spark, Hadoop), ML/AI training data storage, media processing and transcoding
  • Enterprise Kubernetes deployments, like multi-tenant Kubernetes clusters needing reliable storage, hybrid cloud deployments with on-premises storage, and edge computing with local TrueNAS systems.

The CSI driver is simple to use. Developer/users only need to create PVCs using the StorageClass cluster administrators setup, and the driver handles everything else.

Additional CSI Driver Articles

  • CSI Driver Administrators Guide
  • Provides Kubernetes cluster administrators with the information needed to deploy the TrueNAS CSI Driver integration with Kubernetes, including information on setting up StorageClasses.

    • CSI Driver User Guide
    • Provides information for Kubernetes developer/users of the TrueNAS CSI Driver.

      • CSI Driver Reference
      • Provides information on best practices, example StorageClasses, glossary of terms, troubleshooting and diagnostic commands, and API commands related to the TrueNAS CSI Driver integration with Kubernetes.

        CSI Driver Administrators Guide

        Configuration Overview

        This article is for Kubernetes cluster administrators who perform the one-time configuration of Kubernetes that consists of:

        • Setting up each worker node that can use the CSI driver
        • Deploying the TrueNAS CSI driver in Kubernetes

        After receiving the authentication credentials from the TrueNAS administrator, they then establish communication with TrueNAS using the API authentication key provided by TrueNAS and the TrueNAS system IP address.

        The TrueNAS administrator does the one-time setup that consists of:

        • Creating an API key for Kubernetes authentication
        • Setting up a pool to use for storage
        • Turning on the appropriate service (nfs for file or iscsi for block storage requests)
        • Supplying the Kubernetes administrator with the API and IP address of the TrueNAS system

        Each Kubernetes cluster user (developer) creates a YAML file that specifies the volume size, access mode, StorageClass, etc., then submits this PVC request in Kubernetes using a kubectl command. TrueNAS receives the request, adds the requested volumes based on the StorageClass information received in the yaml file.

        The CSI driver does the work of communicating what is received from Kubernetes, passes it to TrueNAS, and then sends information from TrueNAS back to Kubernetes where users can mount the storage volume(s) requested.

        Prerequisites

        • Kubernetes Cluster Requirements

          • Kubernetes Version 1.20 or higher
          • Node OS Linux (Ubuntu, RHEL, Debian, etc.)
        • Required packages on Kubernetes nodes:

          • For NFS: nfs-common (Debian/Ubuntu) or nfs-utils (RHEL/CentOS)
          • For iSCSI: open-iscsi (Debian/Ubuntu) or iscsi-initiator-utils (RHEL/CentOS)
        • Privileges: Cluster admin access for installation

        TrueNAS Requirements

        • TrueNAS SCALE 25.10.0 or later

        • Services enabled:

          • NFS service (for NFS volumes)
          • iSCSI service (for iSCSI volumes)
        • Network connectivity - Kubernetes nodes must reach TrueNAS IP

        • Storage pool - provide at least one ZFS pool with space available to meet user needs

        • API key with administrative privileges to authenticate Kubernetes connections

        • TrueNAS network requirements:

          • TrueNAS WebSocket API Port 443 (HTTPS/WSS)
          • NFS Port 2049 (TCP/UDP)
          • iSCSI Port 3260 (TCP)
          • Firewall that allows Kubernetes pod network CIDR to reach TrueNAS

        Configuring TrueNAS

        Share Creation

        The CSI driver automatically creates datasets and NFS shares or iSCSI targets with UUID-based names, which are not human-readable. For example, a path like /mnt/Tank1/pvc-538b3b31-2619-4cda-837a-57a47c40e8df. Do not modify or delete these auto-created shares or targets.

        Log in to TrueNAS:

        1. Generate an API key for Kubernetes.

          a. Click Settings on the top toolbar, then click My API Keys to open the User API Keys screen. b. Click Add, enter a name for the key, for example, Kubernetes or CSI driver. c. Click Save. d. Copy the key to a txt file or a document you keep secured, and backed up regularly.

          Provide this to the Kubernetes cluster administrator, who should enter this key in Kubernetes along with the TrueNAS IP address to establish authenticated communication with TrueNAS.

          For more information on TrueNAS API keys, see Managing API Keys .

          To locate the IP address for TrueNAS, go to System > Network. The primary network interface is listed in the Interfaces card.

        2. Enable the NFS service if using NFS, or enable the iSCSI service if using iSCSI.

          a. Go to System > Services. b. Edit the service settings to provide the required port access. For the NFS service, set TCP port 2049, and set UDP port 2049. For iSCSI, set TCP port 3260. c. Click Save. d. Click the enable-service toggle to turn on the NFS and/or iSCSI services based on your use case. If you installed the nfs-common package on the Kubernetes worker nodes, enable the NFS service. If you installed the open-iscsi package on the Kubernetes worker nodes, enable the iSCSI service.

        3. Create a new pool or locate a pool with enough storage to accommodate the Kubernetes cluster storage needs. Go to Storage Dashboard, identify a pool with enough storage capacity to suit your use case, or click Create Pool to add a new pool for Kubernetes volumes. For more information on creating new pools, see Creating Pools . To increase storage in an existing pool, see Expanding a Pool in Managing Pools .

        4. Verify the WebSocket API port is set to port 443. Go to System > General Settings. The GUI card should show the Web Interface HTTPS port set to 443. If not, click Settings, locate the Web Interface HTTPS Port field and change the value to 443. Click Save after making a change.

          Provide the pool name to the Kubernetes cluster administrator.

        Verifying the Network Configuration

        Check with your network administrator to verify the Kubernetes cluster can communicate with the TrueNAS server.

        Configuring Kubernetes

        First, download the container image and the deploy/truenas-csi-driver.yaml file found here:

          Or fetch it directly using the following command:

        curl -O https://raw.githubusercontent.com/truenas/truenas-csi/master/deploy/truenas-csi-driver.yaml

        For standard Kubernetes, the user needs to edit deploy/truenas-csi-driver.yaml before deploying. They update the ConfigMap with their TrueNAS connection details (URL, pool name, NFS server address, iSCSI portal) and the Secret with their API key. Then kubectl apply -f deploy/truenas-csi-driver.yaml. which is covered in step 4 in the procedure below.

          If using OpenShift, editing the YAML is not required. The user installs the operator from OperatorHub through the web console, then creates two small resources:

          1. A Secret with their API key

          2. A TrueNASCSI custom resource with their connection details (TrueNAS URL, pool name, etc.)

          Both of those can be created through the OpenShift console UI or via oc apply. The operator handles all the deployment details.

          After that, on either platform, the user creates StorageClass and PVC resources, but these are standard Kubernetes patterns, and not a driver-specific setup.

        The procedure below covers adding the API key and TrueNAS IP address to Kubernetes to establish communication, editing the deploy/yaml file, adding required packages, deploying the CSI driver, and setting up StorageClasses.

        Kubernetes automatically communicates with TrueNAS, making storage requests, driver calls to the TrueNAS API, and TrueNAS creates the resources. For more information on Kubernetes, refer to:

        To deploy the CSI Driver, the Kubernetes cluster administrator does the following:

        1. Install NFS packages on all nodes.

          # Debian/Ubuntu
          sudo apt-get install -y nfs-common
          
          # RHEL/CentOS
          sudo yum install -y nfs-utils
          
        2. Install iSCSI packages on all nodes (if using iSCSI).

          # Debian/Ubuntu
          sudo apt-get install -y open-iscsi
          sudo systemctl enable iscsid
          sudo systemctl start iscsid
          
          # RHEL/CentOS
          sudo yum install -y iscsi-initiator-utils
          sudo systemctl enable iscsid
          sudo systemctl start iscsid
          
        3. Verify kubectl access.

          kubectl cluster-info
          kubectl get nodes
          
        4. Configure the deployment manifest, by editing the deploy/truenas-csi-driver.yaml.

          Update ConfigMap (line ~160) in the YAML file:

           data:
             truenasURL: "wss://YOUR_TRUENAS_IP/api/current"
             truenasInsecure: "true"  # Set to "false" for production with valid certs
             defaultPool: "YOUR_POOL_NAME"  # e.g., "tank"
             nfsServer: "YOUR_TRUENAS_IP"
             iscsiPortal: "YOUR_TRUENAS_IP:3260"
             iscsiIQNBase: "iqn.2000-01.io.truenas"  # Optional: customize IQN prefix
          

          Update secret (line ~150) in the YAML file:

            stringData:
            api-key: "YOUR_TRUENAS_API_KEY"
          

          Update Image (line ~188, ~345):

            image: ghcr.io/truenas/truenas-csi:latest  # Or your registry path
            imagePullPolicy: IfNotPresent
          
        5. Deploy the CSI driver.

          # Apply the manifest
          kubectl apply -f deploy/truenas-csi-driver.yaml
          
          # Wait for pods to be ready
          kubectl wait --for=condition=Ready pod -n truenas-csi -l app=truenas-csi-controller --timeout=120s
          kubectl wait --for=condition=Ready pod -n truenas-csi -l app=truenas-csi-node --timeout=120s
          
          # Verify deployment
          kubectl get pods -n truenas-csi
          kubectl get csidriver csi.truenas.io
          
          Expected Output:
          NAME                                      READY   STATUS
          truenas-csi-controller-xxxxxxxxxx-xxxxx   6/6     Running
          truenas-csi-node-xxxxx                    3/3     Running
          truenas-csi-node-xxxxx                    3/3     Running
          
        6. Verify the driver started by checking controller logs for the startup message.

          kubectl logs -n truenas-csi -l app=truenas-csi-controller -c csi-controller | head -5
          
          Expected Output:
          "Starting TrueNAS CSI Driver" version="v1.0.2"
          

          A successful startup with no error messages indicates the driver is connected and authenticated.

        7. Create the StorageClasses for the package method used (NFS or iSCSI).

          Create NFS StorageClass:
          ```
          kubectl apply -f - <<EOF
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: truenas-nfs
          provisioner: csi.truenas.io
          parameters:
            protocol: "nfs"
            pool: "tank"
            compression: "lz4"
            sync: "standard"
          allowVolumeExpansion: true
          reclaimPolicy: Delete
          volumeBindingMode: Immediate
          EOF
          ```
          
          Create iSCSI StorageClass:
          kubectl apply -f - <<EOF
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: truenas-iscsi
          provisioner: csi.truenas.io
          parameters:
            protocol: "iscsi"
            pool: "tank"
            compression: "lz4"
            volblocksize: "16K"
          allowVolumeExpansion: true
          reclaimPolicy: Delete
          volumeBindingMode: Immediate
          EOF
          
        8. Create a test volume

          # Create test PVC
          kubectl apply -f - <<EOF
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            name: test-volume
            namespace: default
          spec:
            accessModes:
              - ReadWriteMany
            storageClassName: truenas-nfs
            resources:
              requests:
                storage: 1Gi
          EOF
          
          # Wait for binding
          kubectl wait --for=jsonpath='{.status.phase}'=Bound pvc/test-volume --timeout=60s
          
          # Check status
          kubectl get pvc test-volume
          

          If PVC binds the installation is successful!

        StorageClass Parameters

        The following parameters are needed when configuring Kubernetes.

        Common Parameters

        ParameterTypeDefaultDescription
        protocolstringnfsStorage protocol: “nfs” or “iscsi”
        poolstring(from ConfigMap)ZFS pool name (overrides default)
        datasetPathstring-Relative path under pool for datasets (e.g., “k8s/volumes”)
        compressionstringlz4ZFS compression: lz4, gzip, zstd, off

        NFS and iSCSI Parameters

        ParameterTypeDefaultDescription
        syncstringstandardZFS sync: standard, always, disabled
        nfs.hostsstring-Comma-separated allowed hosts
        nfs.networksstring-Comma-separated allowed networks (CIDR)
        nfs.mapAllUserstringrootUser for NFS mapall (controls file ownership)
        nfs.mapAllGroupstringwheelGroup for NFS mapall (controls file ownership)

        Example:

        parameters:
          protocol: "nfs"
          pool: "tank"
          compression: "lz4"
          sync: "standard"
          nfs.networks: "10.0.0.0/8,192.168.0.0/16"
        
        ParameterTypeDefaultDescription
        volblocksizestring16KZVOL block size: 4K, 8K, 16K, 32K, 64K, 128K
        sparsestringfalseUse sparse (thin-provisioned) ZVOLs
        iscsi.blocksizestring512iSCSI extent logical block size
        iscsi.iqn-basestring(from ConfigMap)Custom IQN prefix per StorageClass

        Example:

        parameters:
          protocol: "iscsi"
          pool: "ssd-pool"
          compression: "lz4"
          volblocksize: "8K"
          iscsi.blocksize: "512"
        

        StorageClass Design Patterns

        • Pattern 1: Performance Tiers

          Fast tier - SSD pool with minimal compression
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: truenas-fast
          provisioner: csi.truenas.io
          parameters:
            protocol: "iscsi"
            pool: "ssd-pool"
            compression: "off"
            volblocksize: "8K"
          allowVolumeExpansion: true
          reclaimPolicy: Delete
          
          Standard tier - HDD pool with LZ4
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: truenas-standard
          provisioner: csi.truenas.io
          parameters:
            protocol: "nfs"
            pool: "hdd-pool"
            compression: "lz4"
          allowVolumeExpansion: true
          reclaimPolicy: Delete
          

          Archive tier - High compression
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: truenas-archive
          provisioner: csi.truenas.io
          parameters:
            protocol: "nfs"
            pool: "archive-pool"
            compression: "gzip-9"
          allowVolumeExpansion: true
          reclaimPolicy: Retain  # Keep data even if PVC deleted
          
        • Pattern 2: Protocol-Specific

          NFS for shared file storage
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: shared-files
          provisioner: csi.truenas.io
          parameters:
            protocol: "nfs"
            pool: "tank"
            compression: "lz4"
            sync: "standard"
            nfs.networks: "10.0.0.0/8"  # Restrict to internal network
          allowVolumeExpansion: true
          reclaimPolicy: Delete
          
          iSCSI for database block storage
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: database-block
          provisioner: csi.truenas.io
          parameters:
            protocol: "iscsi"
            pool: "tank"
            compression: "lz4"
            volblocksize: "16K"
            iscsi.blocksize: "4096"
          allowVolumeExpansion: true
          reclaimPolicy: Retain  # Keep DB data if PVC accidentally deleted
          

        • Pattern 3: Application-Specific

          PostgreSQL optimized
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: postgres-storage
          provisioner: csi.truenas.io
          parameters:
            protocol: "iscsi"
            pool: "db-pool"
            compression: "lz4"
            volblocksize: "8K"  # Match PostgreSQL page size
            zfs.recordsize: "8K"
          allowVolumeExpansion: true
          reclaimPolicy: Retain
          

          Media/video storage
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: media-storage
          provisioner: csi.truenas.io
          parameters:
            protocol: "nfs"
            pool: "media-pool"
            compression: "off"  # Media already compressed
            sync: "disabled"    # Better performance for streaming
            zfs.recordsize: "1M"  # Large files
          allowVolumeExpansion: true
          reclaimPolicy: Retain
          

        ReclaimPolicy Explained

        Delete (default):

        • When PVC is deleted, PV and backend storage are automatically deleted
        • Use for: Temporary data, dev/test environments
        • Risk: Accidental PVC deletion causes data loss

        Retain:

        • When PVC is deleted, PV and backend storage are kept
        • Admin must manually delete resources
        • Use for: Production databases, important data
        • Safety: Prevents accidental data loss

        Example:

        reclaimPolicy: Retain  # Safe for production
        reclaimPolicy: Delete  # Convenient for dev/test
        

        Advanced ZFS Properties

        Set advanced ZFS properties via StorageClass:

        Any parameter prefixed with zfs. is set as a ZFS property:

        parameters:
          protocol: "nfs"
          pool: "tank"
          zfs.recordsize: "128K"     # Sets recordsize property
          zfs.atime: "off"           # Disables access time updates
          zfs.dedup: "on"            # Enables deduplication (use cautiously!)
        

        Custom ZFS Properties

        apiVersion: storage.k8s.io/v1
        kind: StorageClass
        metadata:
          name: truenas-custom
        provisioner: csi.truenas.io
        parameters:
          protocol: "nfs"
          pool: "tank"
          compression: "lz4"
          zfs.recordsize: "1M"      # Large recordsize for large files
          zfs.atime: "off"          # Better performance (no access time updates)
          zfs.redundant_metadata: "most"  # Balance between performance and safety
          zfs.xattr: "sa"           # System attribute-based extended attributes
        

        Common ZFS Properties Descriptions

        • recordsize: Suggested block size (4K-1M) - affects performance
        • atime: Access time updates (on/off) - disable for performance
        • dedup: Deduplication (on/off) - requires lots of RAM
        • sync: Write behavior (standard/always/disabled)
        • redundant_metadata: Metadata redundancy level

        Warning: Some properties (like dedup) can significantly impact TrueNAS performance. Consult ZFS documentation and test before using in production.

        CSI Driver User Guide

        This guide is for developers/users using a Kubernetes cluster that want to use the TrueNAS CSI driver to create and submit requests for storage to use in pods. It covers creating PersistentVolumeClaims, mounting storage volumes, and using the features available to TrueNAS storage users.

        For an overview of the Kubernetes/CSI driver integration see TrueNAS CSI Driver

        For reference material including a glossary of terms, see CSI Driver Reference

        Kubernetes Cluster Administrators Guide provides instructions on configuring StorageClasses and the Kubernetes integration with the CSI driver. The process involves creating a yaml file stored locally, and then submitting it to create the PVC using kubectl commands.

        The Kubernetes uses the CSI driver to send the information from Kubernetes to TrueNAS. TrueNAS creates the storage volume based on the information in the PVC yaml file, and sends this back to Kubernetes through the CSI driver, where it can be mounted and used in a pod.

        Using the CSI Driver

        Developers/users should follow this process to set up storage they can mount in their Kubernetes pods.

        Replace my-app-data with the name of your PVC in the commands in this section.

        1. Create a PersistentVolumeClaim.
        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: my-app-data
          namespace: default
        spec:
          accessModes:
            - ReadWriteMany  # For NFS (multiple pods can access)
          storageClassName: truenas-nfs
          resources:
            requests:
              storage: 10Gi  # Request 10GB of storage
        
        1. Apply the PersistentVolumeClaim.

        kubectl apply -f my-app-data.yaml

        Where my-app-data is the name of the yaml file (and PVC) created locally by the developer/user.

        1. Check the PVC status.
        kubectl get pvc my-app-data
        
        Expected Output:
        NAME          STATUS   VOLUME                                     CAPACITY   ACCESS MODES
        my-app-data   Bound    pvc-a1b2c3d4-e5f6-7890-abcd-ef1234567890   10Gi       RWX
        

        Status Meanings:

        • Pending - Waiting for driver to create volume
        • Bound - Volume created and ready to use
        • Lost - PV was deleted but PVC still exists (error state)

        Using a Volume in a Pod

        apiVersion: v1
        kind: Pod
        metadata:
          name: my-app
          namespace: default
        spec:
          containers:
          - name: app
            image: nginx
            volumeMounts:
            - name: data
              mountPath: /usr/share/nginx/html  # Where to mount in container
          volumes:
          - name: data
            persistentVolumeClaim:
              claimName: my-app-data  # Reference the PVC
        

        Then to apply a volume in a pod:

        kubectl apply -f pod.yaml
        

        Verifying a Volume is Mounted

        These commands check if a pod is running, verify a mount inside a container, and then write test data to and read it back from the container.

        # Check pod is running
        kubectl get pod my-app
        
        # Verify mount inside container
        kubectl exec my-app -- df -h /usr/share/nginx/html
        
        # Write test data
        kubectl exec my-app -- sh -c "echo 'Hello from TrueNAS' > /usr/share/nginx/html/index.html"
        
        # Read it back
        kubectl exec my-app -- cat /usr/share/nginx/html/index.html
        

        Expanding a Volume

        1. Check the current size. The CAPACITY shows current size.

          kubectl get pvc my-app-data
          
        2. Edit a PVC to request a larger size. Change the storage size, then save and exit.

          kubectl edit pvc my-app-data
          
          # Change:
            resources:
                requests:
                      storage: 10Gi
          
          # To:
            resources:
                requests:
                      storage: 20Gi
          
          # Save and exit
          

          Alternatively, use kubectl patch:

          kubectl patch pvc my-app-data -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'
          
        3. Wait for the expansion. Watch the CAPACITY column increase in size.

          kubectl get pvc my-app-data -w
          
          # Watch CAPACITY column increase to 20Gi
          

          Note: For iSCSI volumes, you might need to restart the pod for the filesystem resize to take effect.

        Creating a Snapshot

        1. Create a VolumeSnapshot, and then apply it.

          apiVersion: snapshot.storage.k8s.io/v1
          kind: VolumeSnapshot
          metadata:
            name: my-app-snapshot-20250102
            namespace: default
          spec:
            volumeSnapshotClassName: truenas-snapshot-class
            source:
              persistentVolumeClaimName: my-app-data
          

          Apply it:

           kubectl apply -f snapshot.yaml
          
        2. Verify the snapshot.

          kubectl get volumesnapshot my-app-snapshot-20250102
          
          Expected Result
          # Expected:
          # NAME                        READYTOUSE   SOURCEPVC     RESTORESIZE
          # my-app-snapshot-20250102    true         my-app-data   10Gi
          
        3. Check in TrueNAS.

          Navigate to Datasets, locate and select the dataset on the table, then click View Snapshots on the Data Protection card to open the Snapshots screen. Search for the snapshot. The snapshot name format is pool/dataset@snapshot-name

        Restoring from Snapshot

        You can restore from a snapshot by creating a new volume from a snapshot, or cloning an existing volume.

        Create New Volume from Snapshot

        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: my-app-restore
          namespace: default
        spec:
          accessModes:
            - ReadWriteMany
          storageClassName: truenas-nfs
          resources:
            requests:
              storage: 10Gi
          dataSource:
            name: my-app-snapshot-20250102
            kind: VolumeSnapshot
            apiGroup: snapshot.storage.k8s.io
        

        Apply it:

        kubectl apply -f restore-pvc.yaml
        kubectl wait --for=jsonpath='{.status.phase}'=Bound pvc/my-app-restore --timeout=120s
        

        Result: New volume with data from snapshot

        Cloning an Existing Volume

        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: my-app-clone
          namespace: default
        spec:
          accessModes:
            - ReadWriteMany
          storageClassName: truenas-nfs
          resources:
            requests:
              storage: 10Gi
          dataSource:
            name: my-app-data  # Source PVC to clone
            kind: PersistentVolumeClaim
        

        Apply it:

        kubectl apply -f clone-pvc.yaml
        kubectl wait --for=jsonpath='{.status.phase}'=Bound pvc/my-app-clone --timeout=120s
        

        Result: New independent volume with copy of source data

        Advanced Features

        The TrueNAS CSI driver supports advanced storage operations including snapshot-based backup and restore, volume cloning, and multi-protocol deployments. These features are available to all cluster users with the appropriate StorageClass configured by the cluster administrator.

        Creating Volume Snapshots for Backup and Restore

        The following is a backup workflow:

        1. Create Pre-Upgrade Snapshot.

          kubectl apply -f - <<EOF
          apiVersion: snapshot.storage.k8s.io/v1
          kind: VolumeSnapshot
          metadata:
            name: db-before-upgrade
            namespace: production
          spec:
            volumeSnapshotClassName: truenas-snapshot-class
            source:
              persistentVolumeClaimName: postgres-data
          EOF
          
        2. Perform Application Upgrade.

          kubectl set image deployment/postgres postgres=postgres:15
          
        3. Restore if upgrade fails. Stop the application and then create a new volume from a snapshot. Next update the deployment to use the restored volume and then restart the application.

          # Stop the application
          kubectl scale deployment postgres --replicas=0
          
          # Create new volume from snapshot
          kubectl apply -f - <<EOF
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            name: postgres-data-restored
            namespace: production
          spec:
            accessModes: [ReadWriteOnce]
            storageClassName: truenas-iscsi
            resources:
              requests:
                storage: 100Gi
            dataSource:
              name: db-before-upgrade
              kind: VolumeSnapshot
              apiGroup: snapshot.storage.k8s.io
          EOF
          
          # Update deployment to use restored volume
          kubectl set volume deployment/postgres --add --name=data --claim-name=postgres-data-restored
          
          # Restart application
          kubectl scale deployment postgres --replicas=1
          

        Volume Cloning for Environments

        Volume cloning creates an instant copy of an existing volume using ZFS copy-on-write, making it ideal for spinning up staging or test environments with real production data.

        Cloning Production Data to Staging

        Benefits:

        • Instant copy via ZFS clones
        • Minimal storage overhead (copy-on-write)
        • Staging has real production data for testing
        • No impact on production volume
        # Clone production volume
        kubectl apply -f - <<EOF
        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: app-data-staging
          namespace: staging
        spec:
          accessModes: [ReadWriteMany]
          storageClassName: truenas-nfs
          resources:
            requests:
              storage: 50Gi
          dataSource:
            name: app-data-prod
            kind: PersistentVolumeClaim
        EOF
        

        Multi-Protocol Deployments

        Some applications benefit from using both protocols. Example content management system:

        # Media files - NFS for shared access
        ---
        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: cms-media
        spec:
          accessModes: [ReadWriteMany]
          storageClassName: truenas-nfs
          resources:
            requests:
              storage: 100Gi
        
        ---
        # Database - iSCSI for performance
        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: cms-database
        spec:
          accessModes: [ReadWriteOnce]
          storageClassName: truenas-iscsi
          resources:
            requests:
              storage: 20Gi
        

        CSI Driver Reference

        This article provides general reference information about the CSI Driver, a deployment checklist, capacity planning, troubleshooting and diagnostic commands for resolving issues between Kubernetes and the CSI driver, workflows for NFS and iSCSI deployments of the CSI driver integration with Kubernetes, best practices, a glossary of terms, as well as upgrade and suggested deployment options.

        This article provides information that is not included in the administration and user guide articles.

        Kubernetes Fundamentals

        Kubernetes is an open-source container orchestration platform that automates deployment, scaling, and management of containerized applications.

        The following are important terms and foundational to how the CSI driver works with Kubernetes:

        • Pod - A pod is the smallest deployable unit in Kubernetes. It contains one or more containers. Because pods can be created and destroyed frequently, they need persistent storage to retain data beyond their lifecycle.

        • Persistent Volume - A persistent volume is a piece of storage in the cluster, provisioned by the Kubernetes administrator or can be dynamically provisioned via storage classes (StorageClass). It exists independently of pods, and has a lifecycle independent of any pod that uses it.

        • PersistentVolumeClaims (PVC) - A persistent volume claim (PVC) is a request for storage by a user or application. It specifies size, access mode, and storage class. Kubernetes finds or creates a matching PV. It acts like a ticket that entitles a pod to use storage. Think of it like this:

          PV = a physical parking space PVC = a parking ticket requesting a space Pod = a car that parks in the space

        • StorageClass - A StorageClass defines classes of storage with different properties. They enable dynamic provisioning, specifying which provisioner to use (for example, TrueNAS CSI Driver), and contains parameters for that provisioner (pool name, compression, etc.).

        • Container Storage Interface (CSI) - A container storage interface (CSI) is an industry standard for storage plugins in Kubernetes. It enables storage vendors to write one plugin that works everywhere, and separates storage logic from Kubernetes core. The TrueNAS CSI driver implements this standard.

        How it works

        A user creates a PVC requesting storage (creates a YAML file specifying volume size, access mode, StorageClass, etc.). Kubernetes calls the CSI driver CreateVolume function (executes the kubectl apply -f filename.yaml command) The CSI driver creates storage on the backend (TrueNAS creates the volume per request in YAML file), and then returns volume information to Kubernetes. Kubernetes then creates a PV and binds it to a PVC. A pod can now mount and use the volume.

        Best Practices

        Before deploying the CSI driver integration, review the following best practices sections to assist with planning the implementation in Kubernetes.

        Deployment Best Practices

        1. Use Dedicated Namespace

          • Deploy driver in truenas-csi namespace (not default or kube-system)
          • Isolates driver from application workloads
        2. Resource Limits

          • Set memory and CPU limits on driver pods
          • Prevents resource exhaustion
          • Recommended: 128Mi-256Mi RAM, 100m-200m CPU per container
        3. High Availability

          • Controller uses leader election (supports multiple replicas)
          • For HA: Set replicas: 3 in controller deployment
          • Node driver runs on all nodes automatically (DaemonSet)
        4. Security

          • Use a strong TrueNAS API key
          • Rotate API keys periodically
          • Enable TLS verification in production (truenasInsecure: "false")
          • Restrict the NFS networks parameter to the cluster pod CIDR

        Storage Management Best Practices

        • Pool Planning

          • Use separate pools for different performance tiers
          • Monitor pool capacity
          • Set up TrueNAS alerts for pool >80% full
        • Naming Conventions

          • Use descriptive StorageClass names (e.g., fast-ssd, archive-hdd)
          • PVC names should indicate application and purpose
          • Snapshot names should include date/time
        • Quota Management

          • Set realistic default sizes in StatefulSet templates
          • Monitor actual usage
          • Use volume expansion when needed (don’t over-provision initially)
        • *Compression Strategy

          • lz4 (default) - Good balance of speed and compression
          • off - For pre-compressed data (videos, images, archives)
          • gzip or zstd - Higher compression for archives, backups
          • Test with your data to determine the best setting

        Application Usage Best Practices

        • StatefulSets for Databases

          apiVersion: apps/v1
          kind: StatefulSet
          metadata:
            name: postgres
          spec:
            serviceName: postgres
            replicas: 3
            volumeClaimTemplates:  # Automatic PVC per replica
            - metadata:
                name: data
              spec:
                accessModes: [ReadWriteOnce]
                storageClassName: truenas-iscsi
                resources:
                  requests:
                    storage: 50Gi
          
        • Shared Storage for Multi-Pod Apps

          # One PVC, multiple pods (NFS only)
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            name: shared-uploads
          spec:
            accessModes: [ReadWriteMany]
            storageClassName: truenas-nfs
            resources:
              requests:
                storage: 100Gi
          
          ---
          # Multiple pods reference same PVC
          apiVersion: apps/v1
          kind: Deployment
          metadata:
            name: web-app
          spec:
            replicas: 5  # All 5 pods share same storage
            template:
              spec:
                volumes:
                - name: uploads
                  persistentVolumeClaim:
                    claimName: shared-uploads
          
        • Backup Strategy

          • Create a VolumeSnapshotClass before using snapshot features:
            apiVersion: snapshot.storage.k8s.io/v1
            kind: VolumeSnapshotClass
            metadata:
              name: truenas-snapshot-class
            driver: csi.truenas.io
            deletionPolicy: Delete
            
          • Daily snapshots via CronJob
          • Export snapshots to an external backup system
          • Test restore procedures regularly
          apiVersion: batch/v1
          kind: CronJob
          metadata:
            name: daily-snapshot
          spec:
            schedule: "0 2 * * *"  # 2 AM daily
            jobTemplate:
              spec:
                template:
                  spec:
                    serviceAccountName: snapshot-creator
                    containers:
                    - name: create-snapshot
                      image: bitnami/kubectl
                      command:
                      - /bin/sh
                      - -c
                      - |
                        kubectl apply -f - <<EOF
                        apiVersion: snapshot.storage.k8s.io/v1
                        kind: VolumeSnapshot
                        metadata:
                          name: db-snapshot-$(date +%Y%m%d)
                          namespace: production
                        spec:
                          volumeSnapshotClassName: truenas-snapshot-class
                          source:
                            persistentVolumeClaimName: postgres-data
                        EOF
                    restartPolicy: OnFailure
          

        Performance Optimization Best Practices

        • Choose the Right Protocol

          • NFS: Shared file access, ease of use, cross-platform
          • iSCSI: Better performance for databases, single-node access
        • Tune ZFS Properties

          • recordsize: Match application I/O patterns
            • Database: 8K-16K
            • Large files: 128K-1M
          • sync: Adjust based on durability vs performance needs
            • standard: Good balance (default)
            • always: Maximum durability, slower writes
            • disabled: Faster, risk of data loss on crash
        • Volume Block Size (iSCSI)

          • volblocksize: Must match application needs
          • Cannot be changed after creation
          • Default 16K is good for most uses
          • Database: Match DB page size (8K for PostgreSQL)
        • Network Optimization

          • Use a dedicated network for storage traffic (if possible)
          • 10GbE recommended for high throughput
          • MTU 9000 (jumbo frames) for better performance

        Production Deployment Checklist

        Pre-Deployment:

        • TrueNAS system properly sized for workload
        • Network connectivity tested from all K8s nodes to TrueNAS
        • API key generated with strong security
        • Pool created with appropriate RAID level
        • NFS/iSCSI services tested manually
        • Backup strategy for TrueNAS configuration

        Deployment:

        • Use production-grade container registry
        • Tag images with version numbers (not :latest)
        • Set truenasInsecure: "false" (validate TLS certificates)
        • Configure resource limits on driver pods
        • Enable leader election for controller HA
        • Deploy to dedicated namespace

        Post-Deployment:

        • Monitor driver logs for errors
        • Create test volume and verify in TrueNAS
        • Set up alerting for driver pod failures
        • Document StorageClasses for users
        • Train users on PVC creation
        • Establish snapshot/backup schedules

        Capacity Planning

        TrueNAS Side

        • Reserve 20% pool space for snapshots and overhead
        • Monitor pool space usage
        • Set up TrueNAS alerts for capacity thresholds

        Kubernetes Side

        • Use ResourceQuotas to limit PVC sizes per namespace
          apiVersion: v1
          kind: ResourceQuota
          metadata:
            name: storage-quota
            namespace: dev
          spec:
            hard:
              requests.storage: 1Ti  # Max 1TB total storage in namespace
              persistentvolumeclaims: "50"  # Max 50 PVCs
          

        Troubleshooting

        This section provides troubleshooting for common issues, and offers solutions to resolve them.

        “Pool name is required but not configured”

        Cause: Pool name is empty or not set

        Solution:

        • Check ConfigMap has defaultPool set
        • OR ensure StorageClass has pool parameter
        • Verify pool name is correct and exists in TrueNAS
        # Check ConfigMap
        kubectl get configmap truenas-csi-config -n truenas-csi -o yaml
        
        # Update if needed
        kubectl patch configmap truenas-csi-config -n truenas-csi -p '{"data":{"defaultPool":"tank"}}'
        kubectl rollout restart deployment truenas-csi-controller -n truenas-csi
        

        “Authentication failed: credentials were rejected by TrueNAS”

        Cause: Invalid or expired API key

        Solution:

        1. Generate new API key in TrueNAS (Settings → API Keys)

        2. Update Kubernetes secret:

          kubectl create secret generic truenas-api-credentials \
            --from-literal=api-key='NEW_KEY_HERE' \
            --namespace=truenas-csi \
            --dry-run=client -o yaml | kubectl apply -f -
          
        3. Restart controller:

          kubectl rollout restart deployment truenas-csi-controller -n truenas-csi
          

        “Please provide a valid dataset name according to ZFS standards”

        Cause: Dataset name starts with / or contains invalid characters

        Solution: This is fixed in v1.0.0. If using an older version, upgrade to the latest driver.

        Connection Timeout to TrueNAS

        Cause: Network connectivity issue

        Diagnosis:

        # Test from a pod
        kubectl run nettest --image=busybox --rm -it --restart=Never -- ping -c 3 TRUENAS_IP
        
        # Test WebSocket port
        kubectl run wstest --image=curlimages/curl --rm -it --restart=Never -- \
          curl -k -I https://TRUENAS_IP/api/current
        

        Solution:

        • Check firewall rules on TrueNAS
        • Check Kubernetes network policies
        • Verify TrueNAS is reachable from pod network (not just host network)
        • For Docker/kind: Add iptables rule to allow pod traffic

        NFS Mount Fails with “Permission Denied”

        Cause: NFS export doesn’t allow access from Kubernetes nodes

        Solution:

        1. Check NFS share in TrueNAS UI

        2. Verify “Authorized Networks” includes Kubernetes pod CIDR

        3. Update StorageClass to set network restriction:

          parameters:
            nfs.networks: "10.244.0.0/16"  # Your pod CIDR
          

        iSCSI: “No iSCSI session found”

        Cause: iscsid not running on nodes or login failed

        Diagnosis:

        # Check if iscsid is running
        kubectl exec -n truenas-csi <node-pod> -c csi-node -- ps aux | grep iscsid
        
        # Check node logs
        kubectl logs -n truenas-csi <node-pod> -c csi-node
        

        Solution:

        • Ensure open-iscsi package is installed on all nodes
        • Ensure iscsid service is enabled and started
        • Check iSCSI portal is reachable on port 3260

        Volume Expansion Stuck

        Cause: StorageClass doesn’t allow expansion

        Check:

        kubectl get storageclass truenas-nfs -o jsonpath='{.allowVolumeExpansion}'
        # Should return: true
        

        Solution:

        kubectl patch storageclass truenas-nfs -p '{"allowVolumeExpansion":true}'
        

        Diagnostic Commands

        This section provides diagnostic commands to resolve issues in the areas specified.

        Check Driver Health

        # All driver pods running?
        kubectl get pods -n truenas-csi
        
        # Controller healthy?
        kubectl get pod -n truenas-csi -l app=truenas-csi-controller -o jsonpath='{.items[0].status.conditions[?(@.type=="Ready")].status}'
        # Should return: True
        
        # Check authentication
        kubectl logs -n truenas-csi -l app=truenas-csi-controller -c csi-controller | grep -i "auth\|pool"
        

        Check Volume Status

        # List all PVCs
        kubectl get pvc --all-namespaces
        
        # Check specific PVC
        kubectl describe pvc <name> -n <namespace>
        
        # Check corresponding PV
        PV=$(kubectl get pvc <name> -n <namespace> -o jsonpath='{.spec.volumeName}')
        kubectl describe pv $PV
        
        # Check in TrueNAS (via logs)
        kubectl logs -n truenas-csi -l app=truenas-csi-controller -c csi-controller | grep -i "CreateVolume"
        

        Check Network Connectivity

        # From a pod
        kubectl run nettest --image=busybox --rm -it --restart=Never -- \
          sh -c "ping -c 3 TRUENAS_IP && nc -zv TRUENAS_IP 443 && nc -zv TRUENAS_IP 3260"
        

        Monitoring and Alerting

        Monitoring the CSI driver integration requires watching both the Kubernetes cluster and TrueNAS. Kubernetes tracks driver health and storage operations, while TrueNAS monitors pool capacity and service availability.

        For information on alerts in Kubernetes and TrueNAS see:

        Metrics to Monitor

        • Driver pod health and restarts
        • PVC binding success rate
        • Volume creation time
        • TrueNAS pool capacity
        • Network latency between K8s and TrueNAS
        • iSCSI session health (for iSCSI volumes)
        • Driver pod not running
        • PVC stuck in Pending > 5 minutes
        • TrueNAS pool > 80% full
        • Authentication failures
        • Volume creation failures

        API References

        CSI Standard Methods Implemented

        Identity Service

        • GetPluginInfo - Returns driver name and version
        • GetPluginCapabilities - Returns capabilities (CONTROLLER_SERVICE, VOLUME_ACCESSIBILITY_CONSTRAINTS)
        • Probe - Health check endpoint

        Controller Service

        • CreateVolume - Creates dataset/ZVOL and shares on TrueNAS
        • DeleteVolume - Removes dataset/ZVOL and associated resources
        • ControllerPublishVolume - Returns volume connection info (NFS path or iSCSI IQN)
        • ControllerUnpublishVolume - Cleanup on detach
        • ValidateVolumeCapabilities - Validates requested capabilities
        • ListVolumes - Lists all volumes managed by driver
        • GetCapacity - Returns available space in pool
        • ControllerExpandVolume - Expands volume size
        • CreateSnapshot - Creates ZFS snapshot
        • DeleteSnapshot - Deletes ZFS snapshot
        • ListSnapshots - Lists snapshots for a volume

        Node Service

        • NodeStageVolume - Discovers and logs into iSCSI targets
        • NodeUnstageVolume - Logs out of iSCSI targets
        • NodePublishVolume - Mounts volume into pod directory
        • NodeUnpublishVolume - Unmounts volume from pod directory
        • NodeGetCapabilities - Returns node capabilities
        • NodeGetInfo - Returns node ID and topology info
        • NodeGetVolumeStats - Returns volume usage statistics

        TrueNAS API Methods Used

        Dataset Management

        • pool.dataset.create - Create ZFS dataset or ZVOL
        • pool.dataset.get_instance - Get dataset details
        • pool.dataset.update - Update dataset properties (for expansion)
        • pool.dataset.delete - Delete dataset

        NFS Share Management

        • sharing.nfs.create - Create NFS share
        • sharing.nfs.query - Query NFS shares
        • sharing.nfs.delete - Delete NFS share

        iSCSI Management

        • iscsi.target.create - Create iSCSI target
        • iscsi.extent.create - Create extent (links to ZVOL)
        • iscsi.targetextent.create - Associate target with extent
        • iscsi.target.delete - Delete target (and associations)
        • iscsi.extent.delete - Delete extent

        Snapshot Management

        • pool.snapshot.create - Create ZFS snapshot
        • pool.snapshot.delete - Delete snapshot
        • pool.snapshot.clone - Clone dataset from snapshot
        • pool.snapshot.query - List snapshots

        Pool Management

        • pool.query - Query pool information (for capacity reporting)

        CSI Driver and Kubernetes Architecture Diagrams

        High-Level Component Interaction

        ┌────────────────────────────────────────────────────────────┐
        │                   Developer/User                           │
        │                        │                                   │
        │                        │ kubectl apply -f pvc.yaml         │
        │                        ▼                                   │
        │              ┌──────────────────────┐                      │
        │              │  Kubernetes API      │                      │
        │              │  (PVC Created)       │                      │
        │              └──────────┬───────────┘                      │
        │                         │                                  │
        │        ┌────────────────┴────────────────┐                 │
        │        │  PVC stored in etcd             │                 │
        │        └────────────────┬────────────────┘                 │
        │                         │                                  │
        │                         │ Watch for new PVCs               │
        │                         ▼                                  │
        │              ┌──────────────────────┐                      │
        │              │  CSI Provisioner     │                      │
        │              │  (Sidecar)           │                      │
        │              └──────────┬───────────┘                      │
        │                         │                                  │
        │                         │ gRPC: CreateVolume()             │
        │                         ▼                                  │
        │              ┌──────────────────────┐                      │
        │              │  TrueNAS CSI Driver  │                      │
        │              │  (Controller)        │                      │
        │              └──────────┬───────────┘                      │
        │                         │ WebSocket API                    │
        │                         │ (wss://truenas/api/current)      │
        └─────────────────────────┼──────────────────────────────────┘
                                  │
                                  ▼
                        ┌──────────────────────┐
                        │  TrueNAS Middleware  │
                        │  (API Server)        │
                        └──────────┬───────────┘
                                   │ Creates resources:
                                   │ • pool.dataset.create
                                   │ • sharing.nfs.create
                                   ▼
                        ┌──────────────────────┐
                        │    ZFS Storage       │
                        │  • Datasets created  │
                        │  • Shares configured │
                        └──────────────────────┘
        

        NFS Volume Mount Flow

        1. Pod Scheduled Pod → Node (Kubernetes scheduler assigns pod to node)

        2. Kubelet Calls CSI Node Plugin Kubelet → NodePublishVolume(volumeId, targetPath)

        3. CSI Node Plugin Mounts NFS Node Plugin executes: mount -t nfs TRUENAS_IP:/mnt/pool/dataset /var/lib/kubelet/pods/.../volumes/.../mount

        4. Bind Mount to Pod /var/lib/kubelet/pods/…/volumes/…/mount → bind mounted to /var/lib/kubelet/pods/…/volumes/…/data

        5. Container Starts Container sees volume at /data (or specified mountPath)

        iSCSI Volume Mount Flow

        1. Pod Scheduled Pod → Node

        2. CSI Attacher Creates VolumeAttachment Attacher → ControllerPublishVolume(volumeId, nodeId) Driver returns: targetPortal, targetIQN, LUN

        3. Kubelet Calls NodeStageVolume Node Plugin: a. Discover iSCSI target iscsiadm -m discovery -t sendtargets -p TRUENAS_IP:3260

          b. Log in to iSCSI target iscsiadm -m node -T <IQN> -p TRUENAS_IP:3260 --login

          c. Wait for block device /dev/sdX appears

          d. Create filesystem if needed mkfs.ext4 /dev/sdX

          e. Mount to staging path mount /dev/sdX /var/lib/kubelet/plugins/…/globalmount

        4. Kubelet Calls NodePublishVolume Bind mount staging path to pod volume path

        5. Container Starts Container sees volume at /data

        Integration with Prometheus

        Note

        The TrueNAS CSI driver does not currently expose a Prometheus metrics endpoint. The example below is provided for future reference when metrics support is added.

        # ServiceMonitor for driver metrics (if driver exposes metrics)
        apiVersion: monitoring.coreos.com/v1
        kind: ServiceMonitor
        metadata:
          name: truenas-csi-metrics
          namespace: truenas-csi
        spec:
          selector:
            matchLabels:
              app: truenas-csi-controller
          endpoints:
          - port: metrics
        

        Backup and Disaster Recovery

        Volume Snapshots:

        • Create daily snapshots via CronJob.
        • Retain seven daily, four weekly snapshots.
        • Document restore procedures.

        TrueNAS Snapshots:

        • Use TrueNAS snapshot tasks as an additional backup layer.
        • Replicate to a secondary TrueNAS system.

        Metadata Backup: Export PVC/PV definitions regularly.

        kubectl get pvc --all-namespaces -o yaml > pvc-backup.yaml
        kubectl get pv -o yaml > pv-backup.yaml
        

        Upgrade Strategy

        Driver Upgrade:

        1. Test new version in dev/staging cluster.
        2. Create snapshots of critical volumes.
        3. Update driver image in deployment.
        4. Rolling update automatically replaces pods.
        5. Verify existing volumes are still accessible.
        6. Test creating new volumes.

        TrueNAS Upgrade:

        1. Check the CSI driver compatibility with a new TrueNAS version.
        2. Perform TrueNAS upgrade during maintenance window.
        3. Verify API connectivity post-upgrade.
        4. Test volume operations.

        Kubernetes Upgrade:

        1. Check CSI specification compatibility.
        2. Might need to update sidecar container versions.
        3. Test in staging first.

        Glossary

        For definitions of Kubernetes terms (Pod, Persistent Volume, PersistentVolumeClaim, StorageClass, Container Storage Interface), see Kubernetes Fundamentals .

        ZFS: Advanced filesystem with features like snapshots, clones, compression, and data integrity.

        ZVOL: ZFS Volume - a block device created from a ZFS pool.

        Dataset: ZFS filesystem entity that can store files or act as a volume.

        NFS (Network File System): Protocol for sharing files over a network.

        iSCSI (Internet Small Computer Systems Interface): Protocol for block-level storage over a network.

        IQN (iSCSI Qualified Name): Unique identifier for iSCSI targets.

        LUN (Logical Unit Number): Identifier for iSCSI storage units.

        Extent: iSCSI term for the actual storage backing an iSCSI target.

        WebSocket: Communication protocol for persistent, bi-directional connection.

        Snapshot: Read-only point-in-time copy of data (instant with ZFS).

        Clone: Writable copy of data created from a snapshot.

        Copy-on-Write (CoW): ZFS technique where clones share data with the source until modified.

        Appendix A: Sample Deployment for Common Applications

        • PostgreSQL Database
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            name: postgres-data
          spec:
            accessModes: [ReadWriteOnce]
            storageClassName: truenas-iscsi
            resources:
              requests:
                storage: 100Gi
          ---
          apiVersion: apps/v1
          kind: StatefulSet
          metadata:
            name: postgres
          spec:
            serviceName: postgres
            replicas: 1
            selector:
              matchLabels:
                app: postgres
            template:
              metadata:
                labels:
                  app: postgres
              spec:
                containers:
                - name: postgres
                  image: postgres:15
                  env:
                  - name: POSTGRES_PASSWORD
                    value: "changeme"
                  - name: PGDATA
                    value: /var/lib/postgresql/data/pgdata
                  ports:
                  - containerPort: 5432
                  volumeMounts:
                  - name: data
                    mountPath: /var/lib/postgresql/data
                volumes:
                - name: data
                  persistentVolumeClaim:
                    claimName: postgres-data
          
        • WordPress (Multi-Pod with Shared Storage)
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            name: wordpress-uploads
          spec:
            accessModes: [ReadWriteMany]
            storageClassName: truenas-nfs
            resources:
              requests:
                storage: 50Gi
          ---
          apiVersion: apps/v1
          kind: Deployment
          metadata:
            name: wordpress
          spec:
            replicas: 3
            template:
              spec:
                containers:
                - name: wordpress
                  image: wordpress:latest
                  volumeMounts:
                  - name: uploads
                    mountPath: /var/www/html/wp-content/uploads
                volumes:
                - name: uploads
                  persistentVolumeClaim:
                    claimName: wordpress-uploads
          

        Appendix B: Network Requirements Reference

        ServiceProtocolPortSourceDestinationPurpose
        TrueNAS APITCP443K8s PodsTrueNASWebSocket management API
        NFSTCP/UDP2049K8s NodesTrueNASMount NFS shares
        RPC BindTCP/UDP111K8s NodesTrueNASNFS RPC services
        iSCSITCP3260K8s NodesTrueNASiSCSI target access

        Firewall Configuration:

        • Allow Kubernetes pod CIDR (e.g., 10.244.0.0/16) to TrueNAS IP
        • Allow Kubernetes node IPs to TrueNAS IP
        • For iptables/Docker environments: Configure DOCKER-USER chain

        Appendix C: Comparison with Other Storage Solutions

        FeatureTrueNAS CSINFS SubdirLocal PathCloud Provider CSI
        Dynamic Provisioning✓✓✓✓
        ReadWriteMany✓ (NFS)✓✗✗ (usually)
        Volume Expansion✓✗✗✓
        Snapshots✓✗✗✓
        Cloning✓✗✗✓
        Block Storage✓ (iSCSI)✗✓✓
        Enterprise Features✓ (ZFS)✗✗✓
        CostInfrastructure onlyInfrastructure onlyInfrastructure onlyPer-use cloud billing
        On-Premises✓✓✓✗