Synology is a leading innovator, providing robust and versatile solutions for both personal and business needs. Since its inception in 2000, Synology has been dedicated to delivering user-friendly, scalable, and high-performance Network Attached Storage (NAS) devices, which are essentially advanced storage systems that connect to a network, allowing multiple users and devices to store, access, and manage data centrally. Beyond just storage, Synology’s solutions offer plenty of functionalities, including data backup, file sharing, multimedia streaming, virtualization, and surveillance, making them indispensable for both home users and enterprises. along with a suite of powerful applications that cater to various aspects of digital life and work.
It would take too many articles if I wanted to talk in detail about Synology solutions. However, in this blog, I will talk about what Synology can offer for your Kubernetes environment.
Synology introduced open open-source CSI driver that gives your Kubernetes cluster scalable performance, security, and reliability when using persistent storage. Designed for enterprise environments, it enables volume snapshots via Kubernetes native API while supporting the SMB and iSCSI protocols.
Synology NAS devices can provide several benefits for Kubernetes data services:
Performance: Some Synology models offer SSD caching and 10GbE network support, which can enhance performance for I/O-intensive Kubernetes workloads.
Persistent storage: Synology can offer reliable, high-capacity storage for Kubernetes persistent volumes, ensuring data persistence across pod restarts and node failures.
NFS support: Many Synology models support NFS, which Kubernetes can use as a storage backend for persistent volumes.
iSCSI support: Synology’s iSCSI capabilities allow for block-level storage access, which can be beneficial for certain Kubernetes workloads requiring higher performance.
Backup and disaster recovery: Synology’s built-in backup solutions can help protect Kubernetes data and facilitate disaster recovery scenarios. Synology’s storage technology simplifies backup tasks with automated full-system backups and low recovery time snapshots.
Scalability: Synology systems can be expanded to accommodate growing storage needs for Kubernetes clusters.
Now, let’s build a technical example of using Synology with Kubernetes for persistent storage. We’ll create a simple NFS-based persistent volume setup.
1- First, ensure your Synology NAS is configured with NFS:
- On your Synology NAS, go to Control Panel > File Services
- Enable NFS
- Create a shared folder for Kubernetes (e.g., /volume1/kubernetes)
- Edit the shared folder’s NFS permissions to allow access from your Kubernetes nodes
2- Now, let’s create a Kubernetes Persistent Volume (PV) that uses this NFS share:
apiVersion: v1
kind: PersistentVolume
metadata:
name: synology-nfs-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
server: 192.168.1.100 # Replace with your Synology NAS IP
path: "/volume1/kubernetes"
3- Create a Persistent Volume Claim (PVC) to use this PV:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: synology-nfs-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
4- Now, let’s create a simple deployment that uses this PVC:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-synology
spec:
replicas: 1
selector:
matchLabels:
app: nginx-synology
template:
metadata:
labels:
app: nginx-synology
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: synology-nfs
mountPath: /usr/share/nginx/html
volumes:
- name: synology-nfs
persistentVolumeClaim:
claimName: synology-nfs-pvc
5- Apply these YAML files to your Kubernetes cluster:
kubectl apply -f pv.yaml
kubectl apply -f pvc.yaml
kubectl apply -f deployment.yaml
6- Verify that the pod is running and using the Synology NFS volume:
kubectl get pods
kubectl describe pod <pod-name>
Let’s now talk in detail about the technical aspects of this Kubernetes-Synology integration:
- NFS Configuration: The Network File System (NFS) protocol allows the Kubernetes nodes to mount and use the Synology storage as if it were local. NFS operates over TCP/IP, typically on port 2049. When configuring NFS on Synology, you’re essentially setting up an NFS server that the Kubernetes nodes will connect to as clients.
- Persistent Volume (PV):
- The PV is a cluster-wide resource representing a piece of storage.
accessModes: ReadWriteMany
means multiple nodes can mount the volume for read/write operations simultaneously.persistentVolumeReclaimPolicy: Retain
means the volume and its data will be kept even after the PVC is deleted.- The
nfs
section specifies the NFS server details:server
: IP address of the Synology NASpath
: The exported directory on the NAS
- Persistent Volume Claim (PVC):
- PVCs are namespace-scoped requests for storage by users.
- The PVC requests 5Gi of storage with ReadWriteMany access mode, which must match or be a subset of what the PV offers.
- Kubernetes will bind this PVC to the PV we created based on the matching criteria.
- Deployment:
- The deployment creates a single replica of an Nginx pod.
volumeMounts
in the container spec tells Kubernetes where to mount the volume inside the container (/usr/share/nginx/html
).- The
volumes
section references the PVC, linking this deployment to the Synology storage.
- Technical Flow:
- a. When the deployment is created, Kubernetes looks for a PVC named “synology-nfs-pvc”.
- b. This PVC is bound to the PV “synology-nfs-pv”.
- c. Kubernetes then instructs the kubelet on the node where the pod is scheduled to mount the NFS volume.
- d. The kubelet uses the node’s NFS client to mount the Synology NFS share.
- e. Once mounted, the kubelet makes this mount available to the container at the specified path.
- Network Considerations:
- Ensure network connectivity between Kubernetes nodes and the Synology NAS.
- NFS traffic is typically not encrypted, so consider network security measures like VLANs or VPNs in production environments.
- Performance Implications:
- NFS performance can be affected by network latency and bandwidth.
- For write-heavy workloads, consider using Synology’s SSD caching feature to improve performance.
- Scalability:
- This setup allows multiple pods across different nodes to access the same storage.
- Be mindful of the Synology NAS’s I/O capabilities when scaling up the number of pods.
- Data Consistency:
- NFS provides file-level locking, but application-level locking may be necessary for certain workloads to ensure data consistency.
- Monitoring and Troubleshooting:
- Monitor NFS metrics on both Kubernetes nodes and the Synology NAS.
- Use tools like
kubectl describe pv/pvc
andkubectl get events
for troubleshooting.
This setup provides a robust way to integrate Synology storage into a Kubernetes environment, offering persistent, shared storage that can be used across multiple pods and nodes. It’s particularly useful for scenarios where you need shared read-write access to files, such as content management systems or shared document storage for microservices.
Former Nuclear Engineer | University Lecturer | Technology Advisor | Digital Transformation evangelist | FinTech | Blockchain | Podcaster | vExpert ⭐️⭐️⭐️⭐️ | VeeamVanguard ⭐️⭐️ | Nutanix SME | MBA | AWS ABW Grant’23