I was following the Django kubernetes series (How To Deploy a Scalable and Secure Django Application with Kubernetes | DigitalOcean
But I ran into a problem where the Django app that works fine in Docker can’t no connect to the digital ocean postgres after being deployed into Kubernetes. I then did some further exploration and launched postgresql-client pod, and I can’t seem to connect from it either, even though name lookup and so on seem to work. When trying to run this
psql -p 25060 -U sammy -d polls -h databasenamestring-0.b.db.ondigitalocean.com
from inside a pod it hangs, while the same command works from both a linuxvm droplet and also from my home comp. Also the name lookup for the database does work, nor does it work if I give the host ip address directly.
And of course most critically, the Django app can’t connect the database but hangs whenever it tries to access the DB in the back.
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!
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.
Adding the Kubernetes external IP would also work, but what you need to do is, in the section titled Trusted Sources, click Edit to open the Add trusted sources text box, you can enter Droplets, Kubernetes clusters, tags, apps, or specific IP addresses. Entering a tag provides access to the database for any Droplets or Kubernetes nodes containing that tag. At this time, DigitalOcean Cloud Firewalls are not supported.
Found the solution: I just had to go to my database settings and add the Kubernetes external ip to the list of trusted ips
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.
Sign up now