From 9e73054781f72eb112b312674bacdf6ed091ca66 Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 30 Jan 2023 16:38:56 +0100 Subject: [PATCH] fix: use variable to determine postgresql service name --- components/hydra-cnpg-database/kustomization.yaml | 10 ++++++++++ .../hydra-cnpg-database/patches/hydra-deployment.yaml | 2 +- .../hydra-cnpg-database/patches/hydra-migrate-job.yaml | 2 +- resources/hydra/kustomization.yaml | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/hydra-cnpg-database/kustomization.yaml b/components/hydra-cnpg-database/kustomization.yaml index 685cddc..fc4c0db 100644 --- a/components/hydra-cnpg-database/kustomization.yaml +++ b/components/hydra-cnpg-database/kustomization.yaml @@ -19,6 +19,16 @@ secretGenerator: - username=hydra - password=NotSoSecret + +vars: +- name: HYDRA_DATABASE_SERVICE_NAME + objref: + name: hydra-postgres + kind: Cluster + apiVersion: postgresql.cnpg.io/v1 + fieldref: + fieldpath: metadata.name + patchesJson6902: - target: group: apps diff --git a/components/hydra-cnpg-database/patches/hydra-deployment.yaml b/components/hydra-cnpg-database/patches/hydra-deployment.yaml index 3302304..6185612 100644 --- a/components/hydra-cnpg-database/patches/hydra-deployment.yaml +++ b/components/hydra-cnpg-database/patches/hydra-deployment.yaml @@ -18,4 +18,4 @@ path: "/spec/template/spec/containers/0/env/-" value: name: DSN - value: "postgres://$(HYDRA_DATABASE_USER):$(HYDRA_DATABASE_PASSWORD)@hydra-postgres-rw:5432/hydra?sslmode=disable" \ No newline at end of file + value: "postgres://$(HYDRA_DATABASE_USER):$(HYDRA_DATABASE_PASSWORD)@$(HYDRA_DATABASE_SERVICE_NAME)-rw:5432/hydra?sslmode=disable" \ No newline at end of file diff --git a/components/hydra-cnpg-database/patches/hydra-migrate-job.yaml b/components/hydra-cnpg-database/patches/hydra-migrate-job.yaml index 3302304..6185612 100644 --- a/components/hydra-cnpg-database/patches/hydra-migrate-job.yaml +++ b/components/hydra-cnpg-database/patches/hydra-migrate-job.yaml @@ -18,4 +18,4 @@ path: "/spec/template/spec/containers/0/env/-" value: name: DSN - value: "postgres://$(HYDRA_DATABASE_USER):$(HYDRA_DATABASE_PASSWORD)@hydra-postgres-rw:5432/hydra?sslmode=disable" \ No newline at end of file + value: "postgres://$(HYDRA_DATABASE_USER):$(HYDRA_DATABASE_PASSWORD)@$(HYDRA_DATABASE_SERVICE_NAME)-rw:5432/hydra?sslmode=disable" \ No newline at end of file diff --git a/resources/hydra/kustomization.yaml b/resources/hydra/kustomization.yaml index df7897c..6a7d1f2 100644 --- a/resources/hydra/kustomization.yaml +++ b/resources/hydra/kustomization.yaml @@ -25,6 +25,13 @@ configMapGenerator: vars: - name: HYDRA_MIGRATE_JOB_NAME + objref: + name: hydra-migrate + kind: Job + apiVersion: batch/v1 + fieldref: + fieldpath: metadata.name +- name: HYDRA_POSTGRES_SERVICE_NAME objref: name: hydra-migrate kind: Job