naiserator
naiserator copied to clipboard
Postgres databases with equal names in a single team doesn't work
I've been testing a change to nais-cli where I needed to create a couple of different postgres configurations. For simplicity I reused names for the database between the two instances, which ended up with an empty database for the second app to be deployed.
The issue seems to be that the sqldatabases.sql.cnrm.cloud.google.com created only uses the name of the database, not the instance it's created for, creating a conflict.
App A:
apiVersion: nais.io/v1alpha1
kind: Application
metadata:
labels:
team: test
name: multidb-test
namespace: test
spec:
gcp:
sqlInstances:
- databases:
- name: common
users:
- name: common-login
- name: mydb
users:
- name: mydb-login
type: POSTGRES_14
image: ghcr.io/nais/up
App B:
apiVersion: nais.io/v1alpha1
kind: Application
metadata:
labels:
team: test
name: singledb-test
namespace: test
spec:
gcp:
sqlInstances:
- databases:
- name: common
users:
- name: common-login
type: POSTGRES_14
image: ghcr.io/nais/up
Resulted in:
$ kubectl get sqldatabases.sql.cnrm.cloud.google.com --show-labels
NAME AGE READY STATUS STATUS AGE LABELS
common 24h True UpToDate 24h app=multidb-test,team=test
mydb 24h True UpToDate 24h app=multidb-test,team=test