Home > OS >  access database from multiple kubernetes pods
access database from multiple kubernetes pods

Time:02-11

I have 2 applications in 2 pods as well as a Postgres db deployed using a helm chart. The one application writes to the database and the other one uses only select operation for read. Is there any case where I can get a race condition?

2)

Is there any way to have both read and write to the above database from 2 different pods hosting different applications?

CodePudding user response:

  1. If only one of the two applications will be writing to the database, there should not be any risk of a race condition.

  2. Yes, you can define two pods for the two applications and have them both connect to the database. You could create a helm subchart for each application, define the Postgresql connection details in a ConfigMap in the parent chart, and then have each subchart's deployment load the ConfigMap as environment variables so your applications can connect to the database.

  • Related