{question}
How do I manually configure local PVs (Persistent Volumes) in Kubernetes for a SingleStore operator deployment?
{question}
{answer}
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
StorageClass
for 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 thestorageClassName
in the PV manifest to match the storage class created above. - Use the
StorageClass
in the MemsqlCluster Custom Resource (CR) -- the name given to theStorageClass
is what needed to be given in thesdb-cluster.yaml
(or whatever you may have named the MemsqlCluster CR manifest) for both theaggregatorSpec
andleafSpec
sections:
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.
Example:
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.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name:aws-storage
provisioner: kubernetes.io/aws-ebs
parameters:
type: io1
iopsPerGB: "10"
fsType: ext4
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
storageclass.storage.k8s.io/aws-storage created
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>
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: myclaim
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: aws-storage
resources:
requests:
storage: 500Mi
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
persistentvolumeclaim/myclaim created
List PVCs and PVs:
kubectl get pvc
to 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:
{answer}