Skip to content

Commit a103e16

Browse files
committed
add POSTGRES_HOST_RO to core host if using cnpg cluster
Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
1 parent aee069d commit a103e16

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

deploy/internal/statefulset-core.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ spec:
119119
key: NOOBAA_VERSION_AUTH_ENABLED
120120
- name: POSTGRES_HOST
121121
value: "noobaa-db-pg-0.noobaa-db-pg"
122+
- name: POSTGRES_HOST_RO
122123
- name: POSTGRES_PORT
123124
- name: POSTGRES_DBNAME
124125
- name: POSTGRES_USER

pkg/bundle/deploy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5293,7 +5293,7 @@ spec:
52935293
noobaa-s3-svc: "true"
52945294
`
52955295

5296-
const Sha256_deploy_internal_statefulset_core_yaml = "34da89373b8398adb670d779a35f5c5a94365da99b5a2db65715fd62a7638d5c"
5296+
const Sha256_deploy_internal_statefulset_core_yaml = "3dba40ad6babb033832e999680f333849bf3f194a24aa1163587529315ebe8da"
52975297

52985298
const File_deploy_internal_statefulset_core_yaml = `apiVersion: apps/v1
52995299
kind: StatefulSet
@@ -5416,6 +5416,7 @@ spec:
54165416
key: NOOBAA_VERSION_AUTH_ENABLED
54175417
- name: POSTGRES_HOST
54185418
value: "noobaa-db-pg-0.noobaa-db-pg"
5419+
- name: POSTGRES_HOST_RO
54195420
- name: POSTGRES_PORT
54205421
- name: POSTGRES_DBNAME
54215422
- name: POSTGRES_USER

pkg/system/phase2_creating.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,20 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) {
452452
c.Env[j].ValueFrom = nil
453453
}
454454

455+
case "POSTGRES_HOST_RO":
456+
if r.shouldReconcileCNPGCluster() {
457+
//RO host is not part of the cnpg app secret, so we're getting it here from the service
458+
services := &corev1.ServiceList{}
459+
cnpg_label, _ := labels.Parse("app=noobaa,cnpg.io/cluster=noobaa-db-pg-cluster")
460+
util.KubeList(services, &client.ListOptions{Namespace: r.NooBaaPostgresDB.Namespace, LabelSelector: cnpg_label})
461+
for _, service := range services.Items {
462+
if (service.Spec.Selector["cnpg.io/instanceRole"] == "replica") {
463+
c.Env[j].Value = service.Name
464+
break
465+
}
466+
}
467+
}
468+
455469
case "DB_TYPE":
456470
c.Env[j].Value = "postgres"
457471

0 commit comments

Comments
 (0)