⚙️

Enhancing Kubernetes with Shared NFS Storage

Feb 27, 2025

Expanding Kubernetes Cluster Capabilities with Shared Storage

Introduction

  • Purpose: Show how to add shared storage to a Kubernetes cluster.
  • Demo Focus: Connect Synology NAS as an NFS server for persistent volumes.

Why Use Shared Storage?

  • Kubernetes primarily provides compute resources, not storage.
  • Workloads needing persistent storage require external solutions.
  • Persistent volumes allow workloads to store data temporarily and reconnect after restarts or relocations.

Issues with Host Path Volumes

  • Single Node Cluster: Simple setup; volumes are directly accessible.
  • Multi-Node Cluster Problems:
    • Workload on one node may need to move to another, losing access to local volumes.
    • Scaling workloads can create conflicts due to access permissions (read-write-once limitation).

Solution: Using NFS Provisioner

  • NFS (Network File System):
    • Allows multiple workloads to read/write from the same disk.
    • NFS Container Storage Interface (CSI) integrates with Kubernetes for volume provisioning.

Setting Up NFS

NFS Server Options

  1. Install NFS on Kubernetes Node:

    • Quick, but not preferred (risk of losing access if the node fails).
    • Easy installation via SSH and MicroK8s instructions.
  2. Use a Dedicated NFS Device: (Preferred Method)

    • Example: Synology DS120 used for backups and now as NFS.
    • Steps to enable NFS on Synology NAS:
      • Log in to NAS manager.
      • Create shared folder and set NFS permissions (allow local IPs, squash users to root).
      • Enable NFS in the file services.

Installing NFS CSI Driver

  • Follow instructions for installation using Helm chart on MicroK8s site.
  • SSH into cluster and run installation commands.

Creating a Storage Class

  • A storage class is a set of instructions for volume provisioning in Kubernetes.
  • Example name: NFS CSI.
  • Parameters:
    • Specify NFS server's IP and name of the share.
    • Consider setting reclaim policy (retain vs. delete) depending on data importance.

Recap of Storage Class Configuration

  • Storage class instructs Kubernetes to provision volumes via NFS CSI.
  • Binds requested volumes to NFS server, appearing as shared persistent volumes to workloads.
  • Apply the storage class configuration using kubectl apply -f <filename>.

Using Persistent Volume Claims (PVCs)

  • Create a PVC with read-write-many access mode and link it to the storage class.
  • Apply the PVC configuration similarly using kubectl apply -f <filename>.
  • Once bound, integrate the PVC into your deployment by specifying it in the volume section.

Conclusion

  • Achieving a production-like Kubernetes cluster with separated storage and compute resources.
  • Encouragement to like and subscribe for more content.
  • Reminder to check out the previous video on setting up the cluster.