Creating a volume to persist your data
Before we start deploying our databases, let’s create a volume to store data first. For this, we have two options. One is to use a directory inside the server. This means that in order to not lose data, your Pods have to be provisioned in the same node as where your volume was created the first time. If you don’t want to depend on which node your pods are running, you have to choose a second option, which is to use a storage driver. If that’s your case, we are going to use Longhorn as our storage driver option. Now, let’s create our storage first, using a local directory. For this, follow the next steps:
- Create a PersistentVolume using the
/mnt/data
directory in the node to store data:$ cat <<EOF | kubectl apply -f - apiVersion: v1 kind: PersistentVolume metadata: name: db-pv-volume labels: type: local spec: storageClassName: manual ...