<p>What is the preferred Kubernetes storageClass for a PersistentVolume used by a Postgresql database? Which factors should go into consideration choosing the storageClass when I have the choice between S3 (Minio), NFS and HostPath?</p>

mxcd
<p>When you choose a storage option for Postgresql in Kubernetes, you should take into account the following:</p>
<ol>
<li><p><strong>NFS / Minio</strong> is not the preferred storage for databases, if your application is latency-sensitive. A common use case is a download folder or a logging/backup folder.<br />
But it gives you flexibility to design a k8s cluster and ability to easily move to cloud-based solution in future (AWS EFS or S3 for example).</p>
</li>
<li><p><strong>HostPath</strong> is a better option for databases. But</p>
</li>
</ol>
<blockquote>
<p>Kubernetes supports hostPath for development and testing on a single-node cluster. A hostPath PersistentVolume uses a file or directory on the Node to emulate network-attached storage.</p>
</blockquote>
<blockquote>
<p>In a production cluster, you would not use hostPath. Instead a cluster administrator would provision a network resource like a Google Compute Engine persistent disk, an NFS share, or an Amazon Elastic Block Store volume. Cluster administrators can also use StorageClasses to set up dynamic provisioning.</p>
</blockquote>
<ol start="3">
<li>As you mentioned, there is quite a good option for non-cloud k8s clusters <strong>Longhorn</strong></li>
</ol>
<blockquote>
<p>Longhorn is a lightweight, reliable, and powerful distributed block storage system for Kubernetes.<br />
Longhorn implements distributed block storage using containers and microservices. Longhorn creates a dedicated storage controller for each block device volume and synchronously replicates the volume across multiple replicas stored on multiple nodes. The storage controller and replicas are themselves orchestrated using Kubernetes.</p>
</blockquote>
<ol start="4">
<li>Also, check this <a href="https://github.com/bitnami/charts/tree/master/bitnami/postgresql" rel="nofollow noreferrer">Bitnami PostgreSQL Helm chart</a></li>
</ol>
<blockquote>
<p>It offers a PostgreSQL Helm chart that comes pre-configured for security, scalability and data replication. It's a great combination: all the open source goodness of PostgreSQL (foreign keys, joins, views, triggers, stored procedures…) together with the consistency, portability and self-healing features of Kubernetes.</p>
</blockquote>
