Add common monitoring support
This commit is contained in:
parent
4f91d397e2
commit
4f65c61c1c
5 changed files with 42 additions and 6 deletions
|
@ -3,12 +3,16 @@
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[dda.c4k-common.yaml :as yaml]
|
[dda.c4k-common.yaml :as yaml]
|
||||||
[dda.c4k-common.common :as cm]
|
[dda.c4k-common.common :as cm]
|
||||||
|
[dda.c4k-common.monitoring :as mon]
|
||||||
[dda.c4k-forgejo.forgejo :as forgejo]
|
[dda.c4k-forgejo.forgejo :as forgejo]
|
||||||
[dda.c4k-forgejo.backup :as backup]
|
[dda.c4k-forgejo.backup :as backup]
|
||||||
[dda.c4k-common.postgres :as postgres]))
|
[dda.c4k-common.postgres :as postgres]))
|
||||||
|
|
||||||
(def config-defaults {:issuer "staging"})
|
(def config-defaults {:issuer "staging"})
|
||||||
|
|
||||||
|
(s/def ::mon-cfg mon/config?)
|
||||||
|
(s/def ::mon-auth mon/auth?)
|
||||||
|
|
||||||
(def config? (s/keys :req-un [::forgejo/fqdn
|
(def config? (s/keys :req-un [::forgejo/fqdn
|
||||||
::forgejo/mailer-from
|
::forgejo/mailer-from
|
||||||
::forgejo/mailer-host-port
|
::forgejo/mailer-host-port
|
||||||
|
@ -16,16 +20,18 @@
|
||||||
:opt-un [::forgejo/issuer
|
:opt-un [::forgejo/issuer
|
||||||
::forgejo/default-app-name
|
::forgejo/default-app-name
|
||||||
::forgejo/service-domain-whitelist
|
::forgejo/service-domain-whitelist
|
||||||
::backup/restic-repository]))
|
::backup/restic-repository
|
||||||
|
::mon-cfg]))
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password
|
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password
|
||||||
::forgejo/mailer-user ::forgejo/mailer-pw
|
::forgejo/mailer-user ::forgejo/mailer-pw
|
||||||
::backup/aws-access-key-id ::backup/aws-secret-access-key]
|
::backup/aws-access-key-id ::backup/aws-secret-access-key]
|
||||||
:opt-un [::backup/restic-password])) ; TODO gec: Is restic password opt or req?
|
:opt-un [::backup/restic-password ; TODO gec: Is restic password opt or req?
|
||||||
|
::mon-cfg]))
|
||||||
|
|
||||||
(def vol? (s/keys :req-un [::forgejo/volume-total-storage-size]))
|
(def vol? (s/keys :req-un [::forgejo/volume-total-storage-size]))
|
||||||
|
|
||||||
(defn k8s-objects [config]
|
(defn k8s-objects [config auth]
|
||||||
(let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)]
|
(let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)]
|
||||||
(map yaml/to-string
|
(map yaml/to-string
|
||||||
(filter #(not (nil? %))
|
(filter #(not (nil? %))
|
||||||
|
@ -50,4 +56,6 @@
|
||||||
[(backup/generate-config config)
|
[(backup/generate-config config)
|
||||||
(backup/generate-secret config)
|
(backup/generate-secret config)
|
||||||
(backup/generate-cron)
|
(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))))))))
|
||||||
|
|
|
@ -4,4 +4,6 @@
|
||||||
:mailer-pw ""
|
:mailer-pw ""
|
||||||
:aws-access-key-id "AWS_KEY_ID"
|
:aws-access-key-id "AWS_KEY_ID"
|
||||||
:aws-secret-access-key "AWS_KEY_SECRET"
|
:aws-secret-access-key "AWS_KEY_SECRET"
|
||||||
:restic-password ""}
|
:restic-password ""
|
||||||
|
:mon-auth {:grafana-cloud-user "user"
|
||||||
|
:grafana-cloud-password "password"}}
|
||||||
|
|
10
valid-auth.yaml
Normal file
10
valid-auth.yaml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
postgres-db-user: "forgejo"
|
||||||
|
postgres-db-password: "forgejo-db-password"
|
||||||
|
mailer-user: ""
|
||||||
|
mailer-pw: ""
|
||||||
|
aws-access-key-id: "AWS_KEY_ID"
|
||||||
|
aws-secret-access-key: "AWS_KEY_SECRET"
|
||||||
|
restic-password: ""
|
||||||
|
mon-auth:
|
||||||
|
grafana-cloud-user: "user"
|
||||||
|
grafana-cloud-password: "password"
|
|
@ -6,4 +6,7 @@
|
||||||
:service-whitelist-domains "test.de"
|
:service-whitelist-domains "test.de"
|
||||||
:service-noreply-address "noreply@test.de"
|
:service-noreply-address "noreply@test.de"
|
||||||
:volume-total-storage-size 6
|
:volume-total-storage-size 6
|
||||||
:restic-repository "repo-path"}
|
:restic-repository "repo-path"
|
||||||
|
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint"
|
||||||
|
:k3s-cluster-name "jitsi"
|
||||||
|
:k3s-cluster-stage "test"}}
|
||||||
|
|
13
valid-config.yaml
Normal file
13
valid-config.yaml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
default-app-name: "Meissas awesome forgejo"
|
||||||
|
fqdn: "test.de"
|
||||||
|
issuer: "staging"
|
||||||
|
mailer-from: "test@test.de"
|
||||||
|
mailer-host-port: "test.de:123"
|
||||||
|
service-whitelist-domains: "test.de"
|
||||||
|
service-noreply-address: "noreply@test.de"
|
||||||
|
volume-total-storage-size: 6
|
||||||
|
restic-repository: "repo-path"
|
||||||
|
mon-cfg:
|
||||||
|
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
|
||||||
|
k3s-cluster-name: "jitsi"
|
||||||
|
k3s-cluster-stage: "test"
|
Loading…
Reference in a new issue