Skip to main content
Connect file storage to a Managed Kubernetes cluster in a single pool

Connect file storage to a Managed Kubernetes cluster in a single pool

If you need to increase disk space with file storage, we recommend creating storage in the same pool as the Managed Kubernetes cluster. If the file storage and the Managed Kubernetes cluster are in the same pool, you must mount the storage to connect it.

  1. Create file storage.
  2. Mount file storage to Managed Kubernetes cluster.

If you plan to use file storage to store backups, we recommend creating the Managed Kubernetes storage and cluster in pools from different availability zones or regions to improve fault tolerance. For more details, see the Connect file storage to a Managed Kubernetes cluster in another pool instructions.

Create file storage

  1. In Control Panel, go to Cloud PlatformFile Storage.

  2. Click Create Storage.

  3. Enter a new storage name or leave the name that is automatically created.

  4. Select the pool where the Managed Kubernetes cluster is located. A vault will be created in this pool.

  5. Select the subnet of the cloud private network. We recommend choosing the subnet where the nodes of the Managed Kubernetes cluster are located — this will automatically configure the network connectivity between the nodes and the storage.

  6. Select file storage type. Storages differ in read/write speeds and bandwidth values:

    • HDD Basic;

    • SSD Universal;

    • SSD Fast.

      Once created, the storage type cannot be changed.

  7. Specify the storage size: from 50 GB to 50 TB. Once created, you can increase file-storage, but you can't decrease it.

  8. Select a protocol:

    • NFSv4 — for connecting storage to servers running Linux and other Unix systems;

    • CIFS SMBv3 — for connecting the storage to Windows servers.

      Once created, the protocol cannot be changed.

  9. Check out the cost of file storage.

  10. Press Create.

Mount file storage to a Managed Kubernetes cluster

The mounting process depends on the file storage protocol: mount storage using NFSv4 protocol or CIFS SMBv3.

Mount storage using NFSv4 protocol

  1. Create PersistentVolume.
  2. Create PersistentVolumeClaim.
  3. Add file storage to container.

Create PersistentVolume

  1. Connect to Managed Kubernetes cluster.

  2. Create a yaml file filestorage_persistent_volume.yaml with a manifest for PersistentVolume:

    apiVersion: v1
    kind: PersistentVolume
    metadata:
    name: pv_name
    spec:
    storageClassName: storageclass_name
    capacity:
    storage: <storage_size>
    accessModes:
    - ReadWriteMany
    nfs:
    path: /shares/share-<mountpoint_uuid>
    server: <filestorage_ip_address>

    Specify:

    • <storage_size> is the size of the file storage in GB (PersistentVolume size), for example, 100 Gi. The limit is from 50 GB to 50 TB;
    • <mountpoint_uuid> — mount point ID. You can look in Control Panel under Cloud PlatformFile Storage → Storage page → Connectivity block → GNU/Linux tab;
    • <filestorage_ip_address> — IP address of the file storage. You can look in control panel under Cloud PlatformFile Storage → Storage page → Settings tabIP field.
  3. Create PersistentVolume — apply the manifest:

    kubectl apply -f filestorage_persistent_volume.yaml
  4. Verify that PersistentVolume has been created:

    kubectl get pv

Create PersistentVolumeClaim

  1. Create a yaml file filestorage_persistent_volume_claim.yaml with a manifest for PersistentVolumeClaim:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: pvc_name
    spec:
    storageClassName: storageclass_name
    accessModes:
    - ReadWriteMany
    resources:
    requests:
    storage: <storage_size>

    Specify <storage_size> — the file storage size in GB (PersistentVolume size), for example, 100 Gi. The limit is from 50 GB to 50 TB.

  2. Create PersistentVolumeClaim — apply the manifest:

    kubectl apply -f filestorage_persistent_volume_claim.yaml
  3. Check that PersistentVolumeClaim has been created:

    kubectl get pvc

Add storage to container

  1. Create a yaml file deployment.yaml with the manifest for Deployment:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: filestorage_deployment_name
    labels:
    project: filestorage_deployment_name
    spec:
    replicas: 2
    selector:
    matchLabels:
    project: filestorage_project_name
    template:
    metadata:
    labels:
    project: filestorage_project_name
    spec:
    volumes:
    - name: volume_name
    persistentVolumeClaim:
    claimName: pvc_name
    containers:
    - name: container-nginx
    image: nginx:stable-alpine
    ports:
    - containerPort: 80
    name: "http-server"
    volumeMounts:
    - name: volume_name
    mountPath: <mouth_path>

    Specify <mouth_path> — the path to the folder inside the container to which the file storage will be mounted.

  2. Create Deployment — apply the manifest:

    kubectl apply -f deployment.yaml

Mount storage using CIFS SMBv3 protocol

  1. Install the CSI driver for Samba.
  2. Create a secret to store login and password.
  3. Create StorageClass.
  4. Create PersistentVolumeClaim.
  5. Add file storage to container.

Install CSI driver for Samba

  1. Connect to Managed Kubernetes cluster.

  2. Install Helm package manager.

  3. Download the CSI driver from GitHub Kubernetes CSI.

  4. Install the latest driver version:

    helm repo add csi-driver-smb https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/charts
    helm install csi-driver-smb csi-driver-smb/csi-driver-smb --namespace kube-system --version v1.4.0
  5. Check that the pods are installed and running:

    kubectl --namespace=kube-system get pods --selector="app=csi-smb-controller"

Create a secret

File storage does not support access rights differentiation. CIFS SMBv3 access is performed under the guest user.

Create a secret to store the login and password (default is guest/guest):

kubectl create secret generic smbcreds --from-literal username=guest --from-literal password=guest

Create StorageClass

  1. Create a filestorage_storage_storage_class.yaml file with a manifest for StorageClass:

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
    name: storageclass_name
    provisioner: smb.csi.k8s.io
    parameters:
    source: "//<filestorage_ip_address>/share-<mountpoint_uuid>"
    csi.storage.k8s.io/provisioner-secret-name: "smbcreds"
    csi.storage.k8s.io/provisioner-secret-namespace: "default"
    csi.storage.k8s.io/node-stage-secret-name: "smbcreds"
    csi.storage.k8s.io/node-stage-secret-namespace: "default"
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    mountOptions:
    - dir_mode=0777
    - file_mode=0777

    Specify:

    • <mountpoint_uuid> — mount point ID. You can look in control panel under Cloud PlatformFile Storage → Storage page → Connectivity block → GNU/Linux tab;
    • <filestorage_ip_address> — IP address of the file storage. You can look in control panel under Cloud PlatformFile Storage → Storage page → Settings tabIP field.
  2. Create StorageClass — apply the manifest:

    kubectl apply -f filestorage_storage_class.yaml
  3. Verify that the StorageClass has been created:

    kubectl get storageclass

Create PersistentVolumeClaim

  1. Create a yaml file filestorage_persistent_volume_claim.yaml with a manifest for PersistentVolumeClaim:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: pvc_name
    annotations:
    volume.beta.kubernetes.io/storage-class: smb
    spec:
    accessModes: ["ReadWriteMany"]
    resources:
    requests:
    storage: <storage_size>

    Specify <storage_size> — the file storage size in GB (PersistentVolume size), for example, 100 Gi. The limit is from 50 GB to 50 TB.

  2. Create PersistentVolumeClaim — apply the manifest:

    kubectl apply -f filestorage_persistent_volume_claim.yaml
  3. Check that PersistentVolumeClaim has been created:

    kubectl get pvc

Add storage to container

  1. Create a yaml file deployment.yaml with the manifest for Deployment:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: filestorage_deployment_name
    labels:
    project: filestorage_deployment_name
    spec:
    replicas: 2
    selector:
    matchLabels:
    project: filestorage_project_name
    template:
    metadata:
    labels:
    project: filestorage_project_name
    spec:
    volumes:
    - name: volume_name
    persistentVolumeClaim:
    claimName: pvc_name
    containers:
    - name: container-nginx
    image: nginx:stable-alpine
    ports:
    - containerPort: 80
    name: "http-server"
    volumeMounts:
    - name: volume_name
    mountPath: <mouth_path>

    Specify <mouth_path> — the path to the folder inside the container to which the file storage will be mounted.

  2. Create Deployment — apply the manifest:

    kubectl apply -f deployment.yaml