Skip to main content
Synology is a company that specializes in Network Attached Storage (NAS) devices. They provide a number of features within a simple web OS, including an LDAP server, Docker support, and (perhaps most relevant to this guide) function as an iSCSI host. The focus of this guide is to allow a Kubernetes cluster running on Talos to provision Kubernetes storage (both dynamic or static) on a Synology NAS using a direct integration, rather than relying on an intermediary layer like Rook/Ceph or Mayastor. This guide assumes a very basic familiarity with iSCSI terminology (LUN, iSCSI target, etc.).

Prerequisites

  • Synology NAS running DSM 7.0 or above
  • Provisioned Talos cluster running Kubernetes v1.20 or above with siderolabs/iscsi-tools extension installed
  • (Optional) Both Volume Snapshot CRDs and the common snapshot controller must be installed in your Kubernetes cluster if you want to use the Snapshot feature

Setting up the Synology user account

The synology-csi controller interacts with your NAS in two different ways: via the API and via the iSCSI protocol. Actions such as creating a new iSCSI target or deleting an old one are accomplished via the Synology API, and require administrator access. On the other hand, mounting the disk to a pod and reading from / writing to it will utilize iSCSI. Because you can only authenticate with one account per DSM configured, that account needs to have admin privileges. In order to minimize access in the case of these credentials being compromised, you should configure the account with the least possible amount of access – explicitly specify “No Access” on all volumes when configuring the user permissions.

Setting up the Synology CSI

Clone the git repository.
The repository provides ready-to-apply Kubernetes manifests under deploy/kubernetes/<version>/. These manifests reference the synology/synology-csi image published on Docker Hub, and this guide configures and applies them directly. For additional configuration options and a full reference, see the Synology CSI README. The manifests you will work with are organized as follows:

Configure connection info

Copy the template to create your connection config file:
Edit config/client-info.yml to configure the connection information for DSM. You can specify one or more storage systems on which the CSI volumes will be created. See below for an example:

Create the namespace and secret

Create the namespace defined by the manifests, and label it so that the driver’s privileged node pods are admitted under Pod Security Admission:
The node DaemonSet runs a privileged container so it can manage iSCSI devices on the host. Without the privileged enforcement label, Pod Security Admission will emit warnings or block the pods.
Create a Kubernetes secret using the client information config file:
Note that if you rename the secret to something other than client-info-secret, make sure you update the corresponding references in the deployment manifests as well.

Configure the CSI driver

By default, the deployment manifests include one storage class and one volume snapshot class. See below for examples:
It can be useful to configure multiple different StorageClasses. For example, a popular strategy is to create two nearly identical StorageClasses, with one configured with reclaimPolicy: Retain and the other with reclaimPolicy: Delete. Alternately, a workload may require a specific filesystem, such as ext4. If a Synology NAS is going to be the most common way to configure storage on your cluster, it can be convenient to add the storageclass.kubernetes.io/is-default-class: "true" annotation to one of your StorageClasses. The following table details the configurable parameters for the Synology StorageClass. The VolumeSnapshotClass can be similarly configured with the following parameters:

Apply YAML manifests

Once you have created the desired StorageClass(es) and VolumeSnapshotClass(es), the final step is to apply the Kubernetes manifests against the cluster. The easiest way to apply them all at once is to create a kustomization.yaml file in the same directory as the manifests and use Kustomize to apply:
Alternately, you can apply each manifest one-by-one:

Run performance tests

In order to test the provisioning, mounting, and performance of using a Synology NAS as Kubernetes persistent storage, use the following command:
Content of speedtest.yaml (source)
If these two jobs complete successfully, use the following commands to get the results of the speed tests:
When you’re satisfied with the results of the test, delete the artifacts created from the speedtest: