allow pg pinning override

This commit is contained in:
jem 2021-10-08 11:56:42 +02:00
parent ce72dc84eb
commit bc2ffc0693
3 changed files with 34 additions and 3 deletions

View file

@ -39,8 +39,12 @@
(yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml"))) (yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml")))
(assoc-in [:data :postgres-db] db-name)))) (assoc-in [:data :postgres-db] db-name))))
(defn generate-deployment [] (defn generate-deployment [& args]
(yaml/from-string (yaml/load-resource "postgres/deployment.yaml"))) (let [{:keys [postgres-image]
:or {postgres-image "postgres:13"}} args]
(->
(yaml/from-string (yaml/load-resource "postgres/deployment.yaml"))
(assoc-in [:spec :template :spec :containers 0 :image] postgres-image))))
(defn generate-persistent-volume [config] (defn generate-persistent-volume [config]
(let [{:keys [postgres-data-volume-path]} config] (let [{:keys [postgres-data-volume-path]} config]

View file

@ -14,7 +14,7 @@ spec:
app: postgresql app: postgresql
spec: spec:
containers: containers:
- image: postgres:13 - image: postgres
name: postgresql name: postgresql
env: env:
- name: POSTGRES_USER - name: POSTGRES_USER

View file

@ -39,3 +39,30 @@
:data :data
{:postgres-user "eHgtdXM=", :postgres-password "eHgtcHc="}} {:postgres-user "eHgtdXM=", :postgres-password "eHgtcHc="}}
(cut/generate-secret {:postgres-db-user "xx-us" :postgres-db-password "xx-pw"})))) (cut/generate-secret {:postgres-db-user "xx-us" :postgres-db-password "xx-pw"}))))
(deftest should-generate-deployment
(is (= [{:image "postgres:14"
:name "postgresql"
:env
[{:name "POSTGRES_USER"
:valueFrom
{:secretKeyRef
{:name "postgres-secret", :key "postgres-user"}}}
{:name "POSTGRES_PASSWORD"
:valueFrom
{:secretKeyRef
{:name "postgres-secret", :key "postgres-password"}}}
{:name "POSTGRES_DB"
:valueFrom
{:configMapKeyRef
{:name "postgres-config", :key "postgres-db"}}}]
:ports [{:containerPort 5432, :name "postgresql"}]
:volumeMounts
[{:name "postgres-config-volume"
:mountPath "/etc/postgresql/postgresql.conf"
:subPath "postgresql.conf"
:readOnly true}
{:name "postgre-data-volume"
:mountPath "/var/lib/postgresql/data"}]}]
(get-in (cut/generate-deployment :postgres-image "postgres:14")
[:spec :template :spec :containers]))))