<p><a href="https://i.stack.imgur.com/gsuuu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gsuuu.png" alt="enter image description here" /></a></p>
<p>I have this situation where I want to connect my postgres database that is running on a docker container, to the pgadmin web client running on a local kubernetes cluster (minikube)</p>
<p>I already have the postgres working with docker and the pgadmin working with kubernetes.</p>
<p>I can access the pgadmin through the web browser (pgadminclient.com)</p>
<p>I can access the postgres in the container from outside kubernetes, but I can't access postgres from kubernetes pgadmin, what kind of component could I use to achieve the connection and put the right values here
<a href="https://i.stack.imgur.com/ziQzq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ziQzq.png" alt="enter image description here" /></a></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: pgadmin-deployment
  labels:
    app: pgadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pgadmin
  template:
    metadata:
      labels:
        app: pgadmin
    spec:
      containers:
      - name: pgadmin4
        image: dpage/pgadmin4
        ports:
        - containerPort: 80
        env:
        - name: PGADMIN_DEFAULT_EMAIL
          value: rocco@mail.com
        - name: PGADMIN_DEFAULT_PASSWORD
          value: qwerty

---
apiVersion: v1
kind: Service
metadata:
    name: pgadmin-service
spec:
  selector:
    app: pgadmin
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: pgadmin-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: pgadminclient.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: pgadmin-service
            port:
              number: 80
</code></pre>
<p>Also my docker-compose file</p>
<pre class="lang-yaml prettyprint-override"><code>version: &quot;3.8&quot;

services:
  postgresdb:
    image: postgres
    volumes:
      - db-data:/var/lib/postgresql/data
    restart: always
    ports:
      - &quot;5432:5432&quot;
    environment:
      - DATABASE_HOST=127.0.0.1
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=qwerty
      - POSTGRES_DB=practicedb
    
volumes:
  db-data:
</code></pre>

Rocco
<p>Your minikube cluster is using a VM which is different from the VM that docker uses on windows/mac to provide the container runtime. That makes access quite tricky.</p>
<p>But since your use case is to simulate a database outside of the cluster it serves quite well.
You already exposed the docker port externally so you can use the external ip of your host (from wifi, lan, ...) as host for pgadmin. minikube will reach out to the external ip/port which is then in turn mapped back to the docker vm and container. (I did not test it, but it should work.)</p>
