Running databases in containers has long been considered an anti-pattern. However, the Kubernetes ecosystem has evolved significantly, allowing stateful workloads, including databases, to thrive in containerized environments. With PostgreSQL continuing its rise as one of the world’s most beloved databases, it’s essential to understand the right way to run it on Kubernetes.
To explore this, our host (formerly with Ubisoft, Hazelcast, and Timescale) is hosting a webinar:
Title: PostgreSQL on Kubernetes: Do's and Don'ts
Time: 24th of October at 5 PM CEST.
Register here: https://lu.ma/481tq3e9
If you're not joining, I would, in any case, love to hear your thoughts on this!
kubernetes - Access my Postgresql database inside a Kubernates pod from my computer with pgAdmin - Stack Overflow
Experiences with running PostgreSQL on Kubernetes
Have you ever used PostgreSQL on Kubernetes in production?
Implementing postgres on a kubernetes cluster for production. Any guides, articles, checklist, etc?
Videos
To access the database, you can expose the pgadmin tool via a Load-Balancer or Ingress controller. This is not always ideal from a security standpoint- as you are trusting the pgadmin tool to properly handle security. Another way to do this is to expose the pgadmin tool via cluster IP - or an internal IP address. This means, that those people outside of your clusters network, cannot access it. Then for you to access the tool, you would have to add a ssh/vpn tunnel or use kubernetes port-forwarding tool.
For deployment, this helm chart seems to be fairly reasonable, and you can control how you expose the admin utility.
Personally, if security is not of the upmost importance, I would expose pgadmin via an ingress controller. This would be the most convenient way to access the tool.
As for your second question, you can run postgress inside of a pod - but you need to make sure you have a persistent volume setup as the datastore location - as pods should be considered ephemeral. If you are struggling with how to start, I usually find Bitnami's offerings (free) a really good place to begin. Here is the link to the helm chart for postgress SQL. With Bitnami's charts, make sure to set the passwords and accounts during the deployment process- otherwise the deployment will work the first time, but not if you have to redeploy - as the randomly generated passwords will change.
As a note, with some helm charts I use the --dry-run flag to get the raw yaml which I use to do a more standard kubernetes deployment. Make sure to set your helm options properly, and then add that flag. This can be easier if you are just starting and are trying to customize something that does not have a built-in argument.
i guess you should have service object to make it accessable via ingress or nodePort.
For secound question: answer is not so clear and it depends on what you want achive.
As Ben said above, you have to make sure that you have peristent volume on which you can trust. As i know amazon could deliver some solutions but i dont konow if you want to store youre data into third party companies.