I have a stateful application, where my app has a db, and that conflicts if another (same) app uses it. Therefore, to avoid downtime in case of a crash, I want to deploy two of those. The client should be transparent to where it ends up, but app1 can only use db1, and app2 only db2.
client
app1------- | ------- app2
| |
db1 db2
It looks simple but I haven’t been able to figure this out. Ideally, I’d be able to scale them horizontally with more instances.
I am using bitnami’s postgres as a dependency:
- name: pg
version: "16.1.0"
repository: "https://charts.bitnami.com/bitnami"
I know I could alias this and use two of them, but then I also have to repeat all the configs for each. Which isn’t too bad, but then if I have to add a 3rd, or a xth, then this doesn’t work well.
Ideally I have ONE deployment object which encapsulates my app and the db into one thing, so that I could just set a replicas of that and I’d be happy. But I couldn’t figure out how to do this.
So far my app is in a Statefulset, but that kinda is detached from the postgres dependency. How can I create such a “package” with app and db?