Implement and test configmap generation
This commit is contained in:
parent
7037d8a92a
commit
9d518ba4be
4 changed files with 29 additions and 6 deletions
|
@ -38,7 +38,8 @@
|
||||||
(cm/concat-vec
|
(cm/concat-vec
|
||||||
(ns/generate config)
|
(ns/generate config)
|
||||||
(postgres/generate-config config)
|
(postgres/generate-config config)
|
||||||
[(kc/generate-service config)
|
[(kc/generate-configmap config)
|
||||||
|
(kc/generate-service config)
|
||||||
(kc/generate-deployment config)]
|
(kc/generate-deployment config)]
|
||||||
(kc/generate-ratelimit-ingress config)
|
(kc/generate-ratelimit-ingress config)
|
||||||
(when (contains? config :mon-cfg)
|
(when (contains? config :mon-cfg)
|
||||||
|
|
|
@ -51,6 +51,15 @@
|
||||||
(cm/replace-all-matching "ADMIN_USER" (b64/encode keycloak-admin-user))
|
(cm/replace-all-matching "ADMIN_USER" (b64/encode keycloak-admin-user))
|
||||||
(cm/replace-all-matching "ADMIN_PASS" (b64/encode keycloak-admin-password)))))
|
(cm/replace-all-matching "ADMIN_PASS" (b64/encode keycloak-admin-password)))))
|
||||||
|
|
||||||
|
(defn-spec generate-configmap cp/map-or-seq?
|
||||||
|
[config config?]
|
||||||
|
(let [{:keys [namespace fqdn]} config]
|
||||||
|
(->
|
||||||
|
(yaml/load-as-edn "keycloak/configmap.yaml")
|
||||||
|
(cm/replace-all-matching "NAMESPACE" namespace)
|
||||||
|
(cm/replace-all-matching "FQDN" fqdn)
|
||||||
|
(cm/replace-all-matching "ADMIN_FQDN" (str "control." fqdn))))) ; TODO Document this
|
||||||
|
|
||||||
(defn-spec generate-service cp/map-or-seq?
|
(defn-spec generate-service cp/map-or-seq?
|
||||||
[config config?]
|
[config config?]
|
||||||
(let [{:keys [namespace]} config]
|
(let [{:keys [namespace]} config]
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# TODO: Make generate-configmap function
|
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
|
@ -10,10 +9,9 @@ data:
|
||||||
KC_HOSTNAME: FQDN
|
KC_HOSTNAME: FQDN
|
||||||
KC_HOSTNAME_ADMIN: ADMIN_FQDN
|
KC_HOSTNAME_ADMIN: ADMIN_FQDN
|
||||||
KC_PROXY: edge
|
KC_PROXY: edge
|
||||||
DB_VENDOR: POSTGRES
|
KC_DB: postgres
|
||||||
DB_ADDR: postgresql-service
|
KC_DB_URL_HOST: postgresql-service
|
||||||
DB_SCHEMA: public
|
KC_DB_URL_PORT: 5432
|
||||||
DB_DATABASE: postgres
|
|
||||||
# TODO Do we need to enable http, as we are behind ingress?
|
# TODO Do we need to enable http, as we are behind ingress?
|
||||||
# KC_HTTP_ENABLED: true
|
# KC_HTTP_ENABLED: true
|
||||||
# TODO Maybe also enable load shedding
|
# TODO Maybe also enable load shedding
|
||||||
|
|
|
@ -22,6 +22,21 @@
|
||||||
:postgres-db-user "keycloak"
|
:postgres-db-user "keycloak"
|
||||||
:postgres-db-password "db-password"}))))
|
:postgres-db-password "db-password"}))))
|
||||||
|
|
||||||
|
(deftest should-generate-configmap
|
||||||
|
(is (= {:apiVersion "v1",
|
||||||
|
:kind "ConfigMap",
|
||||||
|
:metadata {:name "keycloak-env", :namespace "keycloak"},
|
||||||
|
:data
|
||||||
|
{:KC_HTTPS_CERTIFICATE_FILE "/etc/certs/tls.crt",
|
||||||
|
:KC_HTTPS_CERTIFICATE_KEY_FILE "/etc/certs/tls.key",
|
||||||
|
:KC_HOSTNAME "test.de" ,
|
||||||
|
:KC_HOSTNAME_ADMIN "control.test.de",
|
||||||
|
:KC_PROXY "edge",
|
||||||
|
:KC_DB "postgres",
|
||||||
|
:KC_DB_URL_HOST "postgresql-service",
|
||||||
|
:KC_DB_URL_PORT 5432}}
|
||||||
|
(cut/generate-configmap {:namespace "keycloak" :fqdn "test.de"}))))
|
||||||
|
|
||||||
(deftest should-generate-deployment
|
(deftest should-generate-deployment
|
||||||
(is (= {:name "keycloak", :namespace "keycloak", :labels {:app "keycloak"}}
|
(is (= {:name "keycloak", :namespace "keycloak", :labels {:app "keycloak"}}
|
||||||
(:metadata (cut/generate-deployment {:fqdn "example.com" :namespace "keycloak"})))))
|
(:metadata (cut/generate-deployment {:fqdn "example.com" :namespace "keycloak"})))))
|
||||||
|
|
Loading…
Reference in a new issue