From d6ab7c555ae1ecf8b201125ef357e427dc8f7191 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 3 Feb 2023 12:07:00 +0100 Subject: [PATCH] Use common monitoring --- doc/SetupOnHetzner.md | 14 ++++++++------ src/main/cljc/dda/c4k_nextcloud/core.cljc | 7 +++++-- src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc | 9 ++++++--- src/test/resources/nextcloud-test/valid-auth.edn | 4 +++- src/test/resources/nextcloud-test/valid-config.edn | 5 ++++- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/doc/SetupOnHetzner.md b/doc/SetupOnHetzner.md index 9872457..359eddf 100644 --- a/doc/SetupOnHetzner.md +++ b/doc/SetupOnHetzner.md @@ -45,15 +45,17 @@ output "ipv4" { ## k8s minicluster -For k8s installation we use our [dda-k8s-crate](https://github.com/DomainDrivenArchitecture/dda-k8s-crate) with the following configuation: +For k8s installation we use our [provs](https://repo.prod.meissa.de/meissa/provs) with the following configuation: ``` -{:user :k8s - :k8s {:external-ip "ip-from-above"} - :cert-manager :letsencrypt-prod-issuer - :persistent-dirs ["cloud", "postgres"] - } +postgres-db-user: "nextcloud" +postgres-db-password: "nextcloud-db-password" +nextcloud-admin-user: "cloudadmin" +nextcloud-admin-password: "cloudpassword" +aws-access-key-id: "aws-id" +aws-secret-access-key: "aws-secret" +restic-password: "restic-password" ``` ## kubectl apply c4k-nextcloud diff --git a/src/main/cljc/dda/c4k_nextcloud/core.cljc b/src/main/cljc/dda/c4k_nextcloud/core.cljc index 78453bb..0156b89 100644 --- a/src/main/cljc/dda/c4k_nextcloud/core.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/core.cljc @@ -8,7 +8,8 @@ [dda.c4k-common.yaml :as yaml] [dda.c4k-common.postgres :as postgres] [dda.c4k-nextcloud.nextcloud :as nextcloud] - [dda.c4k-nextcloud.backup :as backup])) + [dda.c4k-nextcloud.backup :as backup] + [dda.c4k-common.monitoring :as mon])) (def default-storage-class :local-path) @@ -35,4 +36,6 @@ [(backup/generate-config config) (backup/generate-secret auth) (backup/generate-cron) - (backup/generate-backup-restore-deployment config)])))) + (backup/generate-backup-restore-deployment config)]) + (when (:contains? config :mon-cfg) + (mon/generate (:mon-cfg config) (:mon-auth auth)))))) diff --git a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc index cf08a4a..d2f9e4b 100644 --- a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc @@ -9,7 +9,8 @@ [dda.c4k-common.base64 :as b64] [dda.c4k-common.predicate :as cp] [dda.c4k-common.postgres :as postgres] - [dda.c4k-common.common :as cm])) + [dda.c4k-common.common :as cm] + [dda.c4k-common.monitoring :as mon])) (s/def ::fqdn cp/fqdn-string?) (s/def ::issuer cp/letsencrypt-issuer?) @@ -27,12 +28,14 @@ :opt-un [::issuer ::restic-repository ::pv-storage-size-gb - ::pvc-storage-class-name])) + ::pvc-storage-class-name + ::mon/mon-cfg])) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::nextcloud-admin-user ::nextcloud-admin-password ::aws-access-key-id ::aws-secret-access-key - ::restic-password])) + ::restic-password] + :opt-un [::mon/mon-auth])) #?(:cljs (defmethod yaml/load-resource :nextcloud [resource-name] diff --git a/src/test/resources/nextcloud-test/valid-auth.edn b/src/test/resources/nextcloud-test/valid-auth.edn index 60f0255..5cee93d 100644 --- a/src/test/resources/nextcloud-test/valid-auth.edn +++ b/src/test/resources/nextcloud-test/valid-auth.edn @@ -4,4 +4,6 @@ :nextcloud-admin-password "cloudpassword" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" - :restic-password "restic-password"} \ No newline at end of file + :restic-password "restic-password" + :mon-auth {:grafana-cloud-user "user" + :grafana-cloud-password "password"}} \ No newline at end of file diff --git a/src/test/resources/nextcloud-test/valid-config.edn b/src/test/resources/nextcloud-test/valid-config.edn index b50ced9..374f961 100644 --- a/src/test/resources/nextcloud-test/valid-config.edn +++ b/src/test/resources/nextcloud-test/valid-config.edn @@ -2,4 +2,7 @@ :issuer "staging" :nextcloud-data-volume-path "/var/cloud" :postgres-data-volume-path "/var/postgres" - :restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder"} \ No newline at end of file + :restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder" + :mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint" + :k3s-cluster-name "jitsi" + :k3s-cluster-stage "test"}} \ No newline at end of file