From cce0778886da1c60797b7548fe22c2e6bed9f888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Muzik=C3=A1=C5=99?= Date: Thu, 27 Jul 2023 15:42:51 +0200 Subject: [PATCH] Change postgres image for Operator tests Closes #22032 --- .../src/main/resources/example-db-secret.yaml | 6 ++--- .../src/main/resources/example-postgres.yaml | 23 +++++++++++++------ .../integration/BaseOperatorTest.java | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/operator/src/main/resources/example-db-secret.yaml b/operator/src/main/resources/example-db-secret.yaml index 99e4842ef2..4082f8f531 100644 --- a/operator/src/main/resources/example-db-secret.yaml +++ b/operator/src/main/resources/example-db-secret.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: keycloak-db-secret -data: - username: cG9zdGdyZXM= # postgres - password: dGVzdHBhc3N3b3Jk # testpassword +stringData: + username: "kc-user" + password: "testpassword" type: Opaque \ No newline at end of file diff --git a/operator/src/main/resources/example-postgres.yaml b/operator/src/main/resources/example-postgres.yaml index 8b6f491835..e6385b22e3 100644 --- a/operator/src/main/resources/example-postgres.yaml +++ b/operator/src/main/resources/example-postgres.yaml @@ -16,16 +16,25 @@ spec: spec: containers: - name: postgresql-db - image: postgres:latest + # WARN: this image is not ARM64 native, consider using "postgres:latest" or "registry.redhat.io/rhel9/postgresql-15:latest" if you need that + # See also https://github.com/sclorg/postgresql-container/pull/527 + # Using c8s instead of c9s as c9s requires additional arguments for emulation on ARM machines, while c8s works OOTB + image: quay.io/sclorg/postgresql-15-c8s:latest volumeMounts: - - mountPath: /data + - mountPath: /var/lib/pgsql/data name: cache-volume env: - - name: POSTGRES_PASSWORD - value: testpassword - - name: PGDATA - value: /data/pgdata - - name: POSTGRES_DB + - name: POSTGRESQL_USER + valueFrom: + secretKeyRef: + key: username + name: keycloak-db-secret + - name: POSTGRESQL_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: keycloak-db-secret + - name: POSTGRESQL_DATABASE value: keycloak volumes: - name: cache-volume diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java index eb32e6e862..55a1fbc6f6 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java @@ -183,6 +183,8 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback { } protected static void deployDB() { + deployDBSecret(); + // DB Log.info("Creating new PostgreSQL deployment"); K8sUtils.set(k8sclient, BaseOperatorTest.class.getResourceAsStream("/example-postgres.yaml")); @@ -191,8 +193,6 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback { Log.info("Checking Postgres is running"); Awaitility.await() .untilAsserted(() -> assertThat(k8sclient.apps().statefulSets().inNamespace(namespace).withName("postgresql-db").get().getStatus().getReadyReplicas()).isEqualTo(1)); - - deployDBSecret(); } protected static void deployDBSecret() {