<p>Is it possible to establish connection from my localhost app to a replica-set postgres kubernetes? or what solution I need to do for having a mirror of my production database?</p>

<p>Thanks in advance</p>

Jonathan Raul Reyes Toledo
<p>What you need is a so-called PostgreSQL <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/operator/" rel="nofollow noreferrer">Kubernetes operator</a> that will be responsible for building Kubernetes objects based on your requests.</p>

<p>You can have a look at <a href="https://operatorhub.io/" rel="nofollow noreferrer">OperatorHub.io</a>, they have <a href="https://operatorhub.io/?keyword=postgres" rel="nofollow noreferrer">some PostgreSQL operators</a>.</p>

<p>Maybe an easier solution is <a href="https://kubedb.com" rel="nofollow noreferrer">KubeDB</a> and <a href="https://kubedb.com/docs/v0.13.0-rc.0/guides/postgres/" rel="nofollow noreferrer">the KubeDB PostgreSQL implementation</a>.</p>

<p>The operator will also create a <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes <code>Service</code></a> that will create a resolvable name linked to the <a href="https://kubernetes.io/fr/docs/concepts/workloads/pods/pod/" rel="nofollow noreferrer">Kubernetes Pods</a> of your PostgreSQL cluster. KubeDB doc explains <a href="https://kubedb.com/docs/v0.13.0-rc.0/guides/postgres/quickstart/quickstart/#connect-with-postgresql-database" rel="nofollow noreferrer">how to connect to the database in their documentation</a>.</p>

<p>Now coming to your question :</p>

<blockquote>
  <p>Is it possible to establish connection from my localhost app [...]</p>
</blockquote>

<p>You can access the Kubernetes service from outside but you will have to create a Kubernetes Load Balancer. See <a href="https://gardener.cloud/050-tutorials/content/howto/service-access/" rel="nofollow noreferrer">this blog article</a> which explains it in details.</p>
