From 1c179daf2cbbcd044a991c5dcf6de7f3171099eb Mon Sep 17 00:00:00 2001 From: see Date: Fri, 18 Mar 2022 12:13:40 +0100 Subject: [PATCH] updated pvc, mob --- src/main/cljc/dda/c4k_nextcloud/core.cljc | 9 +++----- .../cljc/dda/c4k_nextcloud/nextcloud.cljc | 22 +++++++++++++++---- src/main/resources/nextcloud/pvc.yaml | 4 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/cljc/dda/c4k_nextcloud/core.cljc b/src/main/cljc/dda/c4k_nextcloud/core.cljc index ebdc1b2..374cb2a 100644 --- a/src/main/cljc/dda/c4k_nextcloud/core.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/core.cljc @@ -11,10 +11,7 @@ (def config-defaults {:issuer :staging}) -(def config? (s/keys :req-un [::nextcloud/fqdn] - :opt-un [::nextcloud/issuer ::nextcloud/nextcloud-data-volume-path - ::postgres/postgres-data-volume-path ::restic-repository - ::nextcloud/storage-size])) + (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::nextcloud/nextcloud-admin-user ::nextcloud/nextcloud-admin-password @@ -24,7 +21,7 @@ (defn-spec k8s-objects any? - [config (s/merge config? auth?)] + [config (s/merge nextcloud/config? auth?)] (let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)] (into [] @@ -51,7 +48,7 @@ (yaml/to-string (backup/generate-backup-restore-deployment config))]))))) (defn-spec generate any? - [my-config config? + [my-config nextcloud/config? my-auth auth?] (let [resulting-config (merge config-defaults my-config my-auth)] (cs/join diff --git a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc index 6ee2617..274ede8 100644 --- a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc @@ -5,7 +5,8 @@ [dda.c4k-common.yaml :as yaml] [dda.c4k-common.base64 :as b64] [dda.c4k-common.predicate :as cp] - [dda.c4k-common.common :as cm])) + [dda.c4k-common.common :as cm] + [dda.c4k-common.postgres :as postgres])) (s/def ::fqdn any?) ; TODO: Fix fqdn-string? to include localhost (s/def ::issuer cp/letsencrypt-issuer?) @@ -13,6 +14,13 @@ (s/def ::nextcloud-data-volume-path string?) (s/def ::nextcloud-admin-user cp/bash-env-string?) (s/def ::nextcloud-admin-password cp/bash-env-string?) +(s/def ::pvc-storage-class-name cp/pvc-storage-class-name?) +(s/def ::pv-storage-size-gb pos?) + +(def config? (s/keys :req-un [::fqdn] + :opt-un [::issuer ::nextcloud-data-volume-path + ::postgres/postgres-data-volume-path ::restic-repository + ::pv-storage-size-gb ::pvc-storage-class-name])) #?(:cljs (defmethod yaml/load-resource :nextcloud [resource-name] @@ -57,9 +65,15 @@ ;(assoc-in [:spec :capacity :storage] (str storage-size "Gi")) ))) -(defn generate-pvc [] - (let [{:keys [nextcloud-data-volume-path storage-size]} config]) - (yaml/from-string (yaml/load-resource "nextcloud/pvc.yaml"))) +(defn-spec generate-pvc cp/map-or-seq? + [config config?] + (let [{:keys [pv-storage-size-gb pvc-storage-class-name] + :or {pv-storage-size-gb 50 + pvc-storage-class-name :manual}} config] + (-> + (yaml/from-string (yaml/load-resource "nextcloud/pvc.yaml")) + (assoc-in [:spec :resources :requests :storage] (str pv-storage-size-gb "Gi")) + (assoc-in [:spec :storageClassName] (name pvc-storage-class-name))))) (defn generate-service [] (yaml/from-string (yaml/load-resource "nextcloud/service.yaml"))) diff --git a/src/main/resources/nextcloud/pvc.yaml b/src/main/resources/nextcloud/pvc.yaml index 1068bc2..b87db6f 100644 --- a/src/main/resources/nextcloud/pvc.yaml +++ b/src/main/resources/nextcloud/pvc.yaml @@ -5,12 +5,12 @@ metadata: labels: app.kubernetes.io/application: cloud spec: - storageClassName: manual + storageClassName: REPLACEME accessModes: - ReadWriteOnce resources: requests: - storage: 200Gi + storage: REPLACEME selector: matchLabels: app.kubernetes.io/application: cloud