<p>I am new to Kubernetes and I am trying to setup a Java-app locally in minikube. And I want it to be able to connect to locally hosted Postgres DB, connection URL looks like <code>jdbc:postgresql://localhost:5432/my_db</code>, not inside k8s. That sounds like something simple but I just can't find a solution. Could you pls give me a piece of advice on where to look at? Thanks.</p>
<p>Btw, external connections to the DB server are allowed</p>
<p>My <code>deployment.yaml</code></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      name: my-app
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: my-app-image
</code></pre>

Vit Ias
<p>Seems, I found the solution. <code>host.minikube.internal</code> is exactly the alias we can use in this case. In my example just referring DB URI to <code>jdbc:postgresql://host.minikube.internal:5432/my_db</code> solved the problem.</p>
<p>More info <a href="https://minikube.sigs.k8s.io/docs/handbook/host-access/" rel="nofollow noreferrer">here</a></p>
