How do I manually configure local PVs (Persistent Volumes) in Kubernetes for a SingleStore operator deployment?
In Kubernetes, there are storage classes that allow an admin to define a "class" or storage type. You can set these up to dynamically spawn persistent volumes, or define a class that a persistent volume (like one on local storage) can be attached to. The storage class is then defined in the aggregator and/or leaf spec for the cluster and all nodes in that spec will be allocated with persistent volumes from that class.
For manually configuring Local PVs in Kubernetes follow the below steps,
- Create a
StorageClassfor your Persistent Volumes. You can read more about storage classes in the Kubernetes documentation here. We had added examples at the bottom of this article.
- Create a PV (
PersistentVolume). You can read more about persistent volumes in the Kubernetes documentation here. Make sure to define the
storageClassNamein the PV manifest to match the storage class created above.
- Use the
StorageClassin the MemsqlCluster Custom Resource (CR) -- the name given to the
StorageClassis what needed to be given in the
sdb-cluster.yaml(or whatever you may have named the MemsqlCluster CR manifest) for both the
storageClass: <<use what ever correctly configured storageclass name here>>
Note: It's a requirement you configure and attach a StorageClass to the PV before the K8's scheduler will be able to attach the storage to the S2DB/MemSQL Pods.
A StorageClass can be configured to automatically spawn PVs. This comes down to how you have configured your Kubernetes cluster and storage classes. Read the above Kubernetes documentation for more information on storage classes and persistent volumes.
SingleStore only supports the Operator and the S2DB node containers, this question is a K8's infrastructure and configuration question and so for further help reach out to your vendor.
Create Storage Class: (AWS Example)
If you’re not using AWS, the general principles are universally applicable, but you’ll need to change the provider.
To create the storage class, save the contents of the above code block as a YAML file, then use the
kubectl apply -f <file_name>command to apply the definitions:
~/storage$ kubectl apply -f sc-definition.yml
For Listing Storage Class:
kubectl get sc
Create a Persistent Volume Claim:
To use the storage class you have created, you need to have PVC. To create one, save the below manifest in a YAML file, and then apply it with
kubectl apply -f <file_name>
accessModes: [ "ReadWriteOnce" ]
The manifest tells Kubernetes to create a PVC with the name myclaim, and to use the aws-storage storage class.
~/storage$ kubectl apply -f pvc-definition.yml
List PVCs and PVs:
kubectl get pvcto list all PVCs and
kubectl get pv to get all PVs:
If you see the above output and the name you gave your PVC, your cluster has successfully created a PVC.
As the reclaim policy is immediate, a PV is created as soon as the PVC is. You can list your newly created persistent volume using the following command: