Home Explore Blog CI



kubernetes

5th chunk of `content/en/blog/_posts/2017-02-00-Postgresql-Clusters-Kubernetes-Statefulsets.md`
f584bfce4d84e1c6eb590493fdc76f00f8ebb9d902af52ac0000000100000445
![](https://lh5.googleusercontent.com/w82XRPd9LqwgcoY3wJrilJEULxZyub6HLcFk332--1fd94-Vte4YlDFvspLM9syNCdT47PISJlEDo7jSPmiflFv-ZZKmrY6Jm6sJWMki0RfJigf6a6IEPNeyy1PJ_5Mhd4NW4rHm)





**Step 8** - Persistence Explained



Take a look at the persisted PostgreSQL data files on the resulting NFS mount path:



```
$ ls -l /nfsfileshare/

total 12

drwx------ 20   26   26 4096 Jan 17 16:35 pgset-0

drwx------ 20   26   26 4096 Jan 17 16:35 pgset-1

drwx------ 20   26   26 4096 Jan 17 16:48 pgset-2
 ```



Each container in the stateful set binds to the single NFS Persistent Volume Claim (pgset-pvc) created in the example script.  



Since NFS and the PVC can be shared, each pod can write to this NFS path.  



The container is designed to create a subdirectory on that path using the pod host name for uniqueness.



**Conclusion**



StatefulSets is an exciting feature added to Kubernetes for container builders that are implementing clustering. The ordinal values assigned to the set provide a very simple mechanism to make clustering decisions when deploying a PostgreSQL cluster.  



Title: Persistence and Conclusion of StatefulSet Example
Summary
This section explains how each pod in the StatefulSet binds to a single NFS Persistent Volume Claim (PVC), creating a unique subdirectory on the NFS path using the pod's hostname. The conclusion highlights StatefulSets as a useful Kubernetes feature for implementing clustering and using ordinal values for making clustering decisions when deploying a PostgreSQL cluster.