breaking: fixed spec for monitoring
This commit is contained in:
parent
a85e3c3b24
commit
50f269e8d4
5 changed files with 46 additions and 45 deletions
|
@ -2,7 +2,7 @@
|
||||||
"name": "c4k-common-cljs",
|
"name": "c4k-common-cljs",
|
||||||
"description": "Contains predicates and tools for c4k",
|
"description": "Contains predicates and tools for c4k",
|
||||||
"author": "meissa GmbH",
|
"author": "meissa GmbH",
|
||||||
"version": "4.1.0-SNAPSHOT",
|
"version": "5.0.0",
|
||||||
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme",
|
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme",
|
||||||
"repository": "https://www.npmjs.com/package/c4k-common",
|
"repository": "https://www.npmjs.com/package/c4k-common",
|
||||||
"license": "APACHE2",
|
"license": "APACHE2",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject org.domaindrivenarchitecture/c4k-common-cljs "4.1.0-SNAPSHOT"
|
(defproject org.domaindrivenarchitecture/c4k-common-cljs "5.0.0"
|
||||||
:description "Contains predicates and tools for c4k"
|
:description "Contains predicates and tools for c4k"
|
||||||
:url "https://domaindrivenarchitecture.org"
|
:url "https://domaindrivenarchitecture.org"
|
||||||
:license {:name "Apache License, Version 2.0"
|
:license {:name "Apache License, Version 2.0"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject org.domaindrivenarchitecture/c4k-common-clj "4.1.0-SNAPSHOT"
|
(defproject org.domaindrivenarchitecture/c4k-common-clj "5.0.0-SNAPSHOT"
|
||||||
:description "Contains predicates and tools for c4k"
|
:description "Contains predicates and tools for c4k"
|
||||||
:url "https://domaindrivenarchitecture.org"
|
:url "https://domaindrivenarchitecture.org"
|
||||||
:license {:name "Apache License, Version 2.0"
|
:license {:name "Apache License, Version 2.0"
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
(s/def ::grafana-cloud-user cp/bash-env-string?)
|
(s/def ::grafana-cloud-user cp/bash-env-string?)
|
||||||
(s/def ::grafana-cloud-password cp/bash-env-string?)
|
(s/def ::grafana-cloud-password cp/bash-env-string?)
|
||||||
(s/def ::grafana-cloud-url cp/fqdn-string?)
|
(s/def ::grafana-cloud-url string?)
|
||||||
(s/def ::k3s-cluster-name cp/bash-env-string?)
|
(s/def ::cluster-name string?)
|
||||||
(s/def ::k3s-cluster-stage cp/stage?)
|
(s/def ::cluster-stage cp/stage?)
|
||||||
(s/def ::pvc-storage-class-name cp/pvc-storage-class-name?)
|
(s/def ::pvc-storage-class-name cp/pvc-storage-class-name?)
|
||||||
(s/def ::node-regex string?)
|
(s/def ::node-regex string?)
|
||||||
(s/def ::traefik-regex string?)
|
(s/def ::traefik-regex string?)
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
(defn config? [input]
|
(defn config? [input]
|
||||||
(s/keys :req-un [::grafana-cloud-url
|
(s/keys :req-un [::grafana-cloud-url
|
||||||
::k3s-cluster-name
|
::cluster-name
|
||||||
::k3s-cluster-stage]))
|
::cluster-stage]))
|
||||||
|
|
||||||
(defn auth? [input]
|
(defn auth? [input]
|
||||||
(s/keys :req-un [::grafana-cloud-user ::grafana-cloud-password]))
|
(s/keys :req-un [::grafana-cloud-user ::grafana-cloud-password]))
|
||||||
|
@ -55,23 +55,24 @@
|
||||||
(defmethod yaml/load-resource :monitoring [resource-name]
|
(defmethod yaml/load-resource :monitoring [resource-name]
|
||||||
(case resource-name
|
(case resource-name
|
||||||
"monitoring/namespace.yaml" (rc/inline "monitoring/namespace.yaml")
|
"monitoring/namespace.yaml" (rc/inline "monitoring/namespace.yaml")
|
||||||
"monitoring/prometheus/config.yaml" (rc/inline "monitoring/prometheus/config.yaml")
|
|
||||||
"monitoring/prometheus/cluster-role.yaml" (rc/inline "monitoring/prometheus/cluster-role.yaml")
|
|
||||||
"monitoring/prometheus/cluster-role-binding.yaml" (rc/inline "monitoring/prometheus/cluster-role-binding.yaml")
|
|
||||||
"monitoring/prometheus/deployment.yaml" (rc/inline "monitoring/prometheus/deployment.yaml")
|
|
||||||
"monitoring/prometheus/prometheus.yaml" (rc/inline "monitoring/prometheus/prometheus.yaml")
|
|
||||||
"monitoring/prometheus/service.yaml" (rc/inline "monitoring/prometheus/service.yaml")
|
|
||||||
"monitoring/prometheus/service-account.yaml" (rc/inline "monitoring/prometheus/service-account.yaml")
|
|
||||||
"monitoring/node-exporter/daemon-set.yaml" (rc/inline "monitoring/node-exporter/daemon-set.yaml")
|
|
||||||
"monitoring/node-exporter/service.yaml" (rc/inline "monitoring/node-exporter/service.yaml")
|
|
||||||
"monitoring/node-exporter/cluster-role-binding.yaml" (rc/inline "monitoring/node-exporter/cluster-role-binding.yaml")
|
|
||||||
"monitoring/node-exporter/cluster-role.yaml" (rc/inline "monitoring/node-exporter/cluster-role.yaml")
|
|
||||||
"monitoring/node-exporter/service-account.yaml" (rc/inline "monitoring/node-exporter/service-account.yaml")
|
|
||||||
"monitoring/kube-state-metrics/cluster-role-binding.yaml" (rc/inline "monitoring/kube-state-metrics/cluster-role-binding.yaml")
|
"monitoring/kube-state-metrics/cluster-role-binding.yaml" (rc/inline "monitoring/kube-state-metrics/cluster-role-binding.yaml")
|
||||||
"monitoring/kube-state-metrics/cluster-role.yaml" (rc/inline "monitoring/kube-state-metrics/cluster-role.yaml")
|
"monitoring/kube-state-metrics/cluster-role.yaml" (rc/inline "monitoring/kube-state-metrics/cluster-role.yaml")
|
||||||
"monitoring/kube-state-metrics/deployment.yaml" (rc/inline "monitoring/kube-state-metrics/deployment.yaml")
|
"monitoring/kube-state-metrics/deployment.yaml" (rc/inline "monitoring/kube-state-metrics/deployment.yaml")
|
||||||
"monitoring/kube-state-metrics/service-account.yaml" (rc/inline "monitoring/kube-state-metrics/service-account.yaml")
|
"monitoring/kube-state-metrics/service-account.yaml" (rc/inline "monitoring/kube-state-metrics/service-account.yaml")
|
||||||
"monitoring/kube-state-metrics/service.yaml" (rc/inline "monitoring/kube-state-metrics/service.yaml")
|
"monitoring/kube-state-metrics/service.yaml" (rc/inline "monitoring/kube-state-metrics/service.yaml")
|
||||||
|
"monitoring/node-exporter/cluster-role-binding.yaml" (rc/inline "monitoring/node-exporter/cluster-role-binding.yaml")
|
||||||
|
"monitoring/node-exporter/cluster-role.yaml" (rc/inline "monitoring/node-exporter/cluster-role.yaml")
|
||||||
|
"monitoring/node-exporter/daemon-set.yaml" (rc/inline "monitoring/node-exporter/daemon-set.yaml")
|
||||||
|
"monitoring/node-exporter/service-account.yaml" (rc/inline "monitoring/node-exporter/service-account.yaml")
|
||||||
|
"monitoring/node-exporter/service.yaml" (rc/inline "monitoring/node-exporter/service.yaml")
|
||||||
|
"monitoring/prometheus/cluster-role-binding.yaml" (rc/inline "monitoring/prometheus/cluster-role-binding.yaml")
|
||||||
|
"monitoring/prometheus/cluster-role.yaml" (rc/inline "monitoring/prometheus/cluster-role.yaml")
|
||||||
|
"monitoring/prometheus/config.yaml" (rc/inline "monitoring/prometheus/config.yaml")
|
||||||
|
"monitoring/prometheus/deployment.yaml" (rc/inline "monitoring/prometheus/deployment.yaml")
|
||||||
|
"monitoring/prometheus/prometheus.yaml" (rc/inline "monitoring/prometheus/prometheus.yaml")
|
||||||
|
"monitoring/prometheus/service-account.yaml" (rc/inline "monitoring/prometheus/service-account.yaml")
|
||||||
|
"monitoring/prometheus/service.yaml" (rc/inline "monitoring/prometheus/service.yaml")
|
||||||
(throw (js/Error. "Undefined Resource!")))))
|
(throw (js/Error. "Undefined Resource!")))))
|
||||||
|
|
||||||
(defn-spec generate-stateful-set cp/map-or-seq?
|
(defn-spec generate-stateful-set cp/map-or-seq?
|
||||||
|
@ -79,20 +80,20 @@
|
||||||
(let [{:keys [pvc-storage-class-name]
|
(let [{:keys [pvc-storage-class-name]
|
||||||
:or {pvc-storage-class-name :manual}} config]
|
:or {pvc-storage-class-name :manual}} config]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/stateful-set.yaml"))
|
(yaml/load-as-edn "monitoring/stateful-set.yaml")
|
||||||
(assoc-in [:spec :volumeClaimTemplates 0 :spec :storageClassName] (name pvc-storage-class-name)))))
|
(assoc-in [:spec :volumeClaimTemplates 0 :spec :storageClassName] (name pvc-storage-class-name)))))
|
||||||
|
|
||||||
(defn-spec generate-prometheus-config cp/map-or-seq?
|
(defn-spec generate-prometheus-config cp/map-or-seq?
|
||||||
[config config?
|
[config config?
|
||||||
auth auth?]
|
auth auth?]
|
||||||
(let [{:keys [grafana-cloud-url k3s-cluster-name k3s-cluster-stage]} config
|
(let [{:keys [grafana-cloud-url cluster-name cluster-stage]} config
|
||||||
{:keys [grafana-cloud-user grafana-cloud-password]} auth]
|
{:keys [grafana-cloud-user grafana-cloud-password]} auth]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/prometheus.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/prometheus.yaml")
|
||||||
(assoc-in [:global :external_labels :cluster]
|
(assoc-in [:global :external_labels :cluster]
|
||||||
k3s-cluster-name)
|
cluster-name)
|
||||||
(assoc-in [:global :external_labels :stage]
|
(assoc-in [:global :external_labels :stage]
|
||||||
k3s-cluster-stage)
|
cluster-stage)
|
||||||
(assoc-in [:remote_write 0 :url]
|
(assoc-in [:remote_write 0 :url]
|
||||||
grafana-cloud-url)
|
grafana-cloud-url)
|
||||||
(assoc-in [:remote_write 0 :basic_auth :username]
|
(assoc-in [:remote_write 0 :basic_auth :username]
|
||||||
|
@ -105,7 +106,7 @@
|
||||||
[config config?
|
[config config?
|
||||||
auth auth?]
|
auth auth?]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/config.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/config.yaml")
|
||||||
(assoc-in [:stringData :prometheus.yaml]
|
(assoc-in [:stringData :prometheus.yaml]
|
||||||
(yaml/to-string
|
(yaml/to-string
|
||||||
(generate-prometheus-config config auth)))))
|
(generate-prometheus-config config auth)))))
|
||||||
|
@ -113,20 +114,20 @@
|
||||||
(defn-spec generate cp/map-or-seq?
|
(defn-spec generate cp/map-or-seq?
|
||||||
[config config?
|
[config config?
|
||||||
auth auth?]
|
auth auth?]
|
||||||
[(yaml/from-string (yaml/load-resource "monitoring/namespace.yaml"))
|
[(yaml/load-as-edn "monitoring/namespace.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/cluster-role.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/cluster-role.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/cluster-role-binding.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/cluster-role-binding.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/service.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/service.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/service-account.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/service-account.yaml")
|
||||||
(generate-config config auth)
|
(generate-config config auth)
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/prometheus/deployment.yaml"))
|
(yaml/load-as-edn "monitoring/prometheus/deployment.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/node-exporter/service-account.yaml"))
|
(yaml/load-as-edn "monitoring/node-exporter/service-account.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/node-exporter/cluster-role.yaml"))
|
(yaml/load-as-edn "monitoring/node-exporter/cluster-role.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/node-exporter/cluster-role-binding.yaml"))
|
(yaml/load-as-edn "monitoring/node-exporter/cluster-role-binding.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/node-exporter/daemon-set.yaml"))
|
(yaml/load-as-edn "monitoring/node-exporter/daemon-set.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/node-exporter/service.yaml"))
|
(yaml/load-as-edn "monitoring/node-exporter/service.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/kube-state-metrics/cluster-role-binding.yaml"))
|
(yaml/load-as-edn "monitoring/kube-state-metrics/cluster-role-binding.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/kube-state-metrics/cluster-role.yaml"))
|
(yaml/load-as-edn "monitoring/kube-state-metrics/cluster-role.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/kube-state-metrics/deployment.yaml"))
|
(yaml/load-as-edn "monitoring/kube-state-metrics/deployment.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/kube-state-metrics/service-account.yaml"))
|
(yaml/load-as-edn "monitoring/kube-state-metrics/service-account.yaml")
|
||||||
(yaml/from-string (yaml/load-resource "monitoring/kube-state-metrics/service.yaml"))])
|
(yaml/load-as-edn "monitoring/kube-state-metrics/service.yaml")])
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
(st/instrument `cut/generate-agent-config)
|
(st/instrument `cut/generate-agent-config)
|
||||||
(st/instrument `cut/generate-config)
|
(st/instrument `cut/generate-config)
|
||||||
|
|
||||||
(def conf {:k3s-cluster-name "clustername"
|
(def conf {:cluster-name "clustername"
|
||||||
:k3s-cluster-stage :test
|
:cluster-stage :test
|
||||||
:grafana-cloud-url "url"})
|
:grafana-cloud-url "https://some.url/with/path"})
|
||||||
|
|
||||||
(def auth {:grafana-cloud-user "user"
|
(def auth {:grafana-cloud-user "user"
|
||||||
:grafana-cloud-password "password"
|
:grafana-cloud-password "password"
|
||||||
|
|
Loading…
Reference in a new issue