From f98d4ab9b554e0f6c4ac73695e1547d45d5df337 Mon Sep 17 00:00:00 2001 From: patdyn Date: Tue, 27 Aug 2024 15:40:16 +0200 Subject: [PATCH] Get env from configmap and secret --- src/main/resources/keycloak/configmap.yaml | 15 +++++++ src/main/resources/keycloak/deployment.yaml | 43 ++------------------- src/main/resources/keycloak/secret.yaml | 7 +++- 3 files changed, 24 insertions(+), 41 deletions(-) create mode 100644 src/main/resources/keycloak/configmap.yaml diff --git a/src/main/resources/keycloak/configmap.yaml b/src/main/resources/keycloak/configmap.yaml new file mode 100644 index 0000000..659dbf7 --- /dev/null +++ b/src/main/resources/keycloak/configmap.yaml @@ -0,0 +1,15 @@ +# TODO: Make generate-configmap function +apiVersion: v1 +kind: ConfigMap +metadata: + name: keycloak-env + namespace: NAMESPACE +data: + KC_HTTPS_CERTIFICATE_FILE: /etc/certs/tls.crt + KC_HTTPS_CERTIFICATE_KEY_FILE: /etc/certs/tls.key + KC_HOSTNAME: FQDN + KC_PROXY: edge + DB_VENDOR: POSTGRES + DB_ADDR: postgresql-service + DB_SCHEMA: public + DB_DATABASE: postgres diff --git a/src/main/resources/keycloak/deployment.yaml b/src/main/resources/keycloak/deployment.yaml index 5fc1ae0..20d2d52 100644 --- a/src/main/resources/keycloak/deployment.yaml +++ b/src/main/resources/keycloak/deployment.yaml @@ -25,46 +25,11 @@ spec: - name: keycloak-cert mountPath: /etc/certs readOnly: true - env: - - name: KC_HTTPS_CERTIFICATE_FILE - value: /etc/certs/tls.crt - - name: KC_HTTPS_CERTIFICATE_KEY_FILE - value: /etc/certs/tls.key - - name: KC_HOSTNAME - value: FQDN - - name: KC_PROXY - value: edge - - name: DB_VENDOR - value: POSTGRES - - name: DB_ADDR - value: postgresql-service - - name: DB_SCHEMA - value: public - - name: DB_DATABASE - valueFrom: - configMapKeyRef: - name: postgres-config - key: postgres-db - - name: DB_USER - valueFrom: - secretKeyRef: - name: postgres-secret - key: postgres-user - - name: DB_PASSWORD - valueFrom: - secretKeyRef: - name: postgres-secret - key: postgres-password - - name: KEYCLOAK_ADMIN - valueFrom: - secretKeyRef: + envFrom: + - configMapRef: + name: keycloak-env + - secretRef: name: keycloak-secret - key: keycloak-user - - name: KEYCLOAK_ADMIN_PASSWORD - valueFrom: - secretKeyRef: - name: keycloak-secret - key: keycloak-password ports: - name: http containerPort: 8080 diff --git a/src/main/resources/keycloak/secret.yaml b/src/main/resources/keycloak/secret.yaml index b214355..e10e2df 100644 --- a/src/main/resources/keycloak/secret.yaml +++ b/src/main/resources/keycloak/secret.yaml @@ -1,3 +1,4 @@ +# TODO: Update generate-secret function apiVersion: v1 kind: Secret metadata: @@ -5,5 +6,7 @@ metadata: namespace: NAMESPACE type: Opaque data: - keycloak-user: admin - keycloak-password: admin + DB_USER: DBUSER + DB_PASSWORD: DBPW + KEYCLOAK_ADMIN: ADMIN_USER + KEYCLOAK_ADMIN_PASSWORD: ADMIN_PASS