grafana now is working
This commit is contained in:
parent
7498ff42ea
commit
b21a0f6b07
5 changed files with 98 additions and 13 deletions
src/dda/build
test/dda/build
|
@ -47,8 +47,10 @@
|
|||
[devops ::c4k
|
||||
tf-out ::tg/tf-out]
|
||||
(let [config (default-cfg devops)]
|
||||
(->> (cfg/read-config (domain/config-path config))
|
||||
(merge {:fqdn (:fqdn (:value (:out tf-out)))})
|
||||
(->> (domain/create-c4k-config
|
||||
(cfg/read-config (domain/config-path config))
|
||||
config
|
||||
tf-out)
|
||||
(pr-str)
|
||||
(spit (domain/config-path config)))
|
||||
(->> (cfg/read-config (domain/auth-path config))
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
(ns dda.build.c4k.domain
|
||||
(:require [clojure.spec.alpha :as s]
|
||||
[orchestra.core :refer [defn-spec]]
|
||||
[dda.build.devops.domain :as d]))
|
||||
[dda.build.devops.domain :as d]
|
||||
[dda.build.terragrunt.domain :as td]))
|
||||
|
||||
(s/def ::c4k-app-name string?)
|
||||
(s/def ::c4k-output string?)
|
||||
(s/def ::c4k-config-input string?)
|
||||
(s/def ::c4k-auth-input string?)
|
||||
(s/def ::grafana-cloud-url string?)
|
||||
|
||||
(s/def ::config
|
||||
(s/merge ::d/devops
|
||||
(s/keys :req-un [::c4k-output ::c4k-config-input ::c4k-auth-input ::c4k-app-name])))
|
||||
(s/keys :req-un [::c4k-output ::c4k-config-input ::c4k-auth-input ::c4k-app-name]
|
||||
:opt-un [::grafana-cloud-url ::grafana-cloud-user ::grafana-cloud-password])))
|
||||
|
||||
(defn-spec config-path string?
|
||||
[config ::config]
|
||||
|
@ -42,3 +45,16 @@
|
|||
(let [{:keys [c4k-app-name]} config
|
||||
executable-name (str "c4k-" c4k-app-name)]
|
||||
[["bash" "-c" (str executable-name " " (config-path config) " " (auth-path config) " > " (output-path config))]]))
|
||||
|
||||
(defn-spec create-c4k-config map?
|
||||
[module-config map?
|
||||
config ::config
|
||||
tf-out ::td/tf-out]
|
||||
(let [{:keys [name module stage]} config]
|
||||
(merge
|
||||
{:fqdn (:fqdn (:value (:out tf-out)))}
|
||||
(when (contains? config :grafana-cloud-url)
|
||||
{:mon-cfg {:grafana-cloud-url (:grafana-cloud-url config)
|
||||
:cluster-name (str name "-" module)
|
||||
:cluster-stage stage}})
|
||||
module-config)))
|
||||
|
|
|
@ -18,12 +18,14 @@
|
|||
(s/def ::k3s-provision-user pred/bash-env-string?)
|
||||
(s/def ::k3s-hcloudApiToken string?)
|
||||
(s/def ::k3s-encryptionPassphrase string?)
|
||||
(s/def ::k3s-grafana-url string?)
|
||||
(s/def ::k3s-grafana-user string?)
|
||||
(s/def ::k3s-grafana-token string?)
|
||||
(s/def ::config
|
||||
(s/merge ::c4k-d/config
|
||||
(s/keys :req-un [::email ::echo ::k3s-output-filename ::k3s-auth-input ::k3s-provision-user]
|
||||
:opt-un [::k3s-hcloudApiToken ::k3s-encryptionPassphrase ::k3s-grafana-user ::k3s-grafana-token])))
|
||||
:opt-un [::k3s-hcloudApiToken ::k3s-encryptionPassphrase
|
||||
::k3s-grafana-user ::k3s-grafana-token ::k3s-grafana-url])))
|
||||
|
||||
(s/def ::node
|
||||
(s/keys :req-un [::ipv4 ::ipv6]))
|
||||
|
@ -36,9 +38,14 @@
|
|||
(s/def ::hcloudApiToken k3s-credential?)
|
||||
(s/def ::encryptionPassphrase k3s-credential?)
|
||||
(s/def ::hetzner (s/keys :req-un [::hcloudApiToken ::encryptionPassphrase]))
|
||||
(s/def ::user string?)
|
||||
(s/def ::url string?)
|
||||
(s/def ::password k3s-credential?)
|
||||
(s/def ::cluster string?)
|
||||
(s/def ::grafana (s/keys :req-un [::cluster]))
|
||||
(s/def ::server-config
|
||||
(s/keys :req-un [::fqdn ::node ::certmanager ::echo]
|
||||
:opt-un [::hetzner]))
|
||||
:opt-un [::hetzner ::grafana]))
|
||||
|
||||
(defn-spec auth-path string?
|
||||
[config ::config]
|
||||
|
@ -79,7 +86,6 @@
|
|||
:encryptionPassphrase {:source "PLAIN"
|
||||
:parameter (:k3s-encryptionPassphrase config)}}})
|
||||
(when (and (contains? config :k3s-grafana-token)
|
||||
(contains? config :k3s-grafana-user))
|
||||
{:grafana {:user (:k3s-grafana-user config)
|
||||
:password {:source "PLAIN", :parameter (:k3s-grafana-token config)}
|
||||
:cluster (str name "-" module)}}))))
|
||||
(contains? config :k3s-grafana-user)
|
||||
(contains? config :k3s-grafana-url))
|
||||
{:grafana {:cluster (str name "-" module)}}))))
|
||||
|
|
|
@ -138,3 +138,65 @@
|
|||
:c4k-auth-input "auth.yaml"
|
||||
:c4k-output "out.yaml"}))))
|
||||
|
||||
(deftest should-create-c4k-config
|
||||
(is (= {:fqdn "cloud.test.meissa.de",
|
||||
:issue "staging",
|
||||
:restic-repository "restic-repo",
|
||||
:pv-storage-size-gb 40,
|
||||
:pvc-storage-class-name "hcloud-volumes-encrypted"}
|
||||
(cut/create-c4k-config
|
||||
{:issue "staging"
|
||||
:restic-repository "restic-repo"
|
||||
:pv-storage-size-gb 40
|
||||
:pvc-storage-class-name "hcloud-volumes-encrypted"}
|
||||
{:name "dda"
|
||||
:module "backup"
|
||||
:project-root-path "../.."
|
||||
:build-dir-name "target"
|
||||
:version "4.11.8-dev"
|
||||
:stage "dev"
|
||||
:debug false
|
||||
:dry-run false
|
||||
:c4k-app-name "backup"
|
||||
:c4k-config-input "config.yaml"
|
||||
:c4k-auth-input "auth.yaml"
|
||||
:c4k-output "out.yaml"}
|
||||
{:out
|
||||
{:sensitive false,
|
||||
:type [],
|
||||
:value {:fqdn "cloud.test.meissa.de",
|
||||
:ipv4 "91.107.220.172",
|
||||
:ipv6 "2a01:4f8:c17:86c6::1"}}})))
|
||||
(is (= {:fqdn "cloud.test.meissa.de",
|
||||
:issue "staging",
|
||||
:restic-repository "restic-repo",
|
||||
:pv-storage-size-gb 40,
|
||||
:pvc-storage-class-name "hcloud-volumes-encrypted"
|
||||
:mon-cfg
|
||||
{:grafana-cloud-url "https://prometheus-endpoint",
|
||||
:cluster-name "dda-backup",
|
||||
:cluster-stage "dev"}}
|
||||
(cut/create-c4k-config
|
||||
{:issue "staging"
|
||||
:restic-repository "restic-repo"
|
||||
:pv-storage-size-gb 40
|
||||
:pvc-storage-class-name "hcloud-volumes-encrypted"}
|
||||
{:name "dda"
|
||||
:module "backup"
|
||||
:project-root-path "../.."
|
||||
:build-dir-name "target"
|
||||
:version "4.11.8-dev"
|
||||
:stage "dev"
|
||||
:debug false
|
||||
:dry-run false
|
||||
:grafana-cloud-url "https://prometheus-endpoint"
|
||||
:c4k-app-name "backup"
|
||||
:c4k-config-input "config.yaml"
|
||||
:c4k-auth-input "auth.yaml"
|
||||
:c4k-output "out.yaml"}
|
||||
{:out
|
||||
{:sensitive false,
|
||||
:type [],
|
||||
:value {:fqdn "cloud.test.meissa.de",
|
||||
:ipv4 "91.107.220.172",
|
||||
:ipv6 "2a01:4f8:c17:86c6::1"}}}))))
|
||||
|
|
|
@ -33,9 +33,7 @@
|
|||
:node {:ipv4 "91.107.220.172", :ipv6 "2a01:4f8:c17:86c6::1"},
|
||||
:certmanager {:email "test@test.t", :letsencryptEndpoint "staging"},
|
||||
:echo false,
|
||||
:grafana {:user "grafana-user"
|
||||
:password {:source "PLAIN", :parameter "grafana-token"}
|
||||
:cluster "dda-backup-"}
|
||||
:grafana {:cluster "dda-backup-"}
|
||||
:hetzner
|
||||
{:hcloudApiToken {:source "PLAIN", :parameter "hcloud-token"},
|
||||
:encryptionPassphrase {:source "PLAIN", :parameter "passphrase"}}}
|
||||
|
@ -55,6 +53,7 @@
|
|||
:k3s-encryptionPassphrase "passphrase"
|
||||
:k3s-grafana-user "grafana-user"
|
||||
:k3s-grafana-token "grafana-token"
|
||||
:k3s-grafana-url "grafana-url"
|
||||
:c4k-config-input "config.yaml"
|
||||
:c4k-auth-input "auth.yaml"
|
||||
:c4k-output "out.yaml"
|
||||
|
|
Loading…
Add table
Reference in a new issue