How to connect to an external postgres database service from k8s

I have an external postgres service running elsewhere on the internet that is accepting public connections. I have set up a simple k8s cluster with a node app that should connect to it. This is confirmed via pg_isready on my machine and shelling in the pods.

I also have set up egress NetworkPolicy to accept all egress connections from all pods via the k8s tutorial.

kind: NetworkPolicy
  name: allow-all-egress
  podSelector: {}
    - {}
    - Egress

I can connect to the postgres database locally but not within any pods. Is there another step or firewall to configure within DO?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

I think that this looks all correct. What is the exact error that you get when you try to connect and do you have a firewall enabled on your database server side?

Also if you try to ping the hostname of your database, do you get back a response?

Regards, Bobby