1

The OpenShift Origin Client Tools allow to forward ports (example command: oc port-forward postgresql-1-a7hrv 5432).

However, my database backups are fetched from a FreeBSD box. Apparently the oc tools are not available on *BSD and I'd rather use standard commands anyway.

How can I do an oc port-forward-equivalent on FreeBSD and access the according database?

  • What do you mean by "standard Unix commands" in this question? – Kusalananda May 22 '18 at 15:38
0

you should use SSH port forwarding I guess. If I understood you correctly you have a PostgreSQL database on a server called postgresql-1-a7hrv running on port 5432 there. To do so you have to connect via SSH to this server using this command :

ssh -L 127.0.0.1:5432:127.0.0.1:5432 user@postgresql-1-a7hrv

Then you can access your database on port 5432 locally (on 127.0.0.1). This assumes your PostgreSQL database listens on 127.0.0.1 on the remote server. If not change the line to (where w.x.y.z is the ip on which the PostgreSQL server listens) : ssh -L 127.0.0.1:5432:w.x.y.z:5432 user@postgresql-1-a7hrv

  • Thanks, but OpenShift is RedHat's container platform, so the server/container is on a "pod" identified as "postgresql-1-a7hrv" and lacking a public IP. Thus I am unable to connect to w.x.y.z of your example. – user569825 Oct 31 '17 at 13:18
  • Okay, in that case maybe you should use a rebound, use a box where oc client is available, then use the command I wrote to use it from the FreeBSD box. – Pierre-Alain TORET Oct 31 '17 at 13:32
0

The only way to directly connect to a container (outside of using oc port-forward) is to expose it via a LoadBalancer or NodePort. Routes are only for select protocols (HTTP/HTTPS). Postgres will need to use either LoadBalancer or NodePort. See documentation here:

https://docs.openshift.org/latest/dev_guide/expose_service/index.html

Once it's exposed, you would use that to SSH into the container and do what you need to do from your FreeBSD box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.