So far, we've used a relational database in all our services, but, as we will soon discover, we didn't have real persistence. First, we'll look at where the data is stored, and then we'll explore how durable it is. Finally, we'll migrate one of the databases to use a StatefulSet for proper persistence and durability.
Using relational databases in Kubernetes
Understanding where the data is stored
For PostgreSQL, there is a data directory; this directory can be set using the PGDATA environment variable. By default, it is set to /var/lib/postgresql/data:
$ kubectl exec -it link-db-6b9b64db5-zp59g env | grep PGDATA
PGDATA=/var/lib/postgresql/data
Let's take a look at what this directory contains:
...