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.
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
-
In Control Panel, go to Cloud Platform → File Storage.
-
Click Create Storage.
-
Enter a new storage name or leave the name that is automatically created.
-
Select the pool where the Managed Kubernetes cluster is located. A vault will be created in this pool.
-
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.
-
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.
-
-
Specify the storage size: from 50 GB to 50 TB. Once created, you can increase file-storage, but you can't decrease it.
-
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.
-
-
Check out the cost of file storage.
-
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
Create PersistentVolume
-
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 Platform → File 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 Platform → File Storage → Storage page → Settings tab → IP field.
-
Create PersistentVolume — apply the manifest:
kubectl apply -f filestorage_persistent_volume.yaml
-
Verify that PersistentVolume has been created:
kubectl get pv
Create PersistentVolumeClaim
-
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. -
Create PersistentVolumeClaim — apply the manifest:
kubectl apply -f filestorage_persistent_volume_claim.yaml
-
Check that PersistentVolumeClaim has been created:
kubectl get pvc
Add storage to container
-
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. -
Create Deployment — apply the manifest:
kubectl apply -f deployment.yaml
Mount storage using CIFS SMBv3 protocol
- Install the CSI driver for Samba.
- Create a secret to store login and password.
- Create StorageClass.
- Create PersistentVolumeClaim.
- Add file storage to container.
Install CSI driver for Samba
-
Download the CSI driver from GitHub Kubernetes CSI.
-
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 -
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
-
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=0777Specify:
<mountpoint_uuid>
— mount point ID. You can look in control panel under Cloud Platform → File 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 Platform → File Storage → Storage page → Settings tab → IP field.
-
Create StorageClass — apply the manifest:
kubectl apply -f filestorage_storage_class.yaml
-
Verify that the StorageClass has been created:
kubectl get storageclass
Create PersistentVolumeClaim
-
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. -
Create PersistentVolumeClaim — apply the manifest:
kubectl apply -f filestorage_persistent_volume_claim.yaml
-
Check that PersistentVolumeClaim has been created:
kubectl get pvc
Add storage to container
-
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. -
Create Deployment — apply the manifest:
kubectl apply -f deployment.yaml