diff --git a/src/main/cljc/dda/c4k_jira/backup.cljc b/src/main/cljc/dda/c4k_jira/backup.cljc index bebf960..91e6752 100644 --- a/src/main/cljc/dda/c4k_jira/backup.cljc +++ b/src/main/cljc/dda/c4k_jira/backup.cljc @@ -5,12 +5,12 @@ [dda.c4k-common.yaml :as yaml] [dda.c4k-common.base64 :as b64] [dda.c4k-common.common :as cm] - [dda.c4k-common.prefixes :as pf])) + [dda.c4k-common.predicate :as pd])) -(s/def ::aws-access-key-id pf/bash-env-string?) -(s/def ::aws-secret-access-key pf/bash-env-string?) -(s/def ::restic-password pf/bash-env-string?) -(s/def ::restic-repository pf/bash-env-string?) +(s/def ::aws-access-key-id pd/bash-env-string?) +(s/def ::aws-secret-access-key pd/bash-env-string?) +(s/def ::restic-password pd/bash-env-string?) +(s/def ::restic-repository pd/bash-env-string?) #?(:cljs (defmethod yaml/load-resource :backup [resource-name] diff --git a/src/main/cljc/dda/c4k_jira/core.cljc b/src/main/cljc/dda/c4k_jira/core.cljc index 33ea69c..2758404 100644 --- a/src/main/cljc/dda/c4k_jira/core.cljc +++ b/src/main/cljc/dda/c4k_jira/core.cljc @@ -9,29 +9,31 @@ [dda.c4k-jira.jira :as jira] [dda.c4k-jira.backup :as backup])) +(def default-storage-class :local-path) + +(def default-jira-storage-size-gb 50) + (def config-defaults {:issuer :staging}) -(def config? (s/keys :req-un [::jira/fqdn] - :opt-un [::jira/issuer ::jira/jira-data-volume-path - ::postgres/postgres-data-volume-path ::restic-repository])) +(def config? (s/keys :req-un [::fqdn] + :opt-un [::issuer ::restic-repository])) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::aws-access-key-id ::aws-secret-access-key ::restic-password])) -(defn k8s-objects [config] +(defn-spec k8s-objects any? + [config (s/merge config? auth?)] (into [] - (concat [(yaml/to-string (postgres/generate-config :postgres-size :2gb :db-name "jira")) - (yaml/to-string (postgres/generate-secret config))] - (when (contains? config :postgres-data-volume-path) - [(yaml/to-string (postgres/generate-persistent-volume config))]) - [(yaml/to-string (postgres/generate-pvc)) + (concat [(yaml/to-string (postgres/generate-config {:postgres-size :2gb :db-name "jira"})) + (yaml/to-string (postgres/generate-secret config)) + (yaml/to-string (postgres/generate-pvc {:pv-storage-size-gb 30 + :pvc-storage-class-name default-storage-class})) (yaml/to-string (postgres/generate-deployment :postgres-image "postgres:14")) - (yaml/to-string (postgres/generate-service))] - (when (contains? config :jira-data-volume-path) - [(yaml/to-string (jira/generate-persistent-volume config))]) - [(yaml/to-string (jira/generate-pvc)) + (yaml/to-string (postgres/generate-service)) + (yaml/to-string (jira/generate-pvc {:pvc-storage-class-name default-storage-class + :pv-storage-size-gb default-jira-storage-size-gb})) (yaml/to-string (jira/generate-deployment config)) (yaml/to-string (jira/generate-service)) (yaml/to-string (jira/generate-certificate config))