split monitoring into config and auth

This commit is contained in:
Clemens 2024-07-17 10:48:44 +02:00
parent 0085111abe
commit ca8ab8d708
4 changed files with 45 additions and 8 deletions

View file

@ -101,6 +101,7 @@
(println
(expound/expound-str auth-spec? auth-edn {:print-specs? false})))))))))))
; REVIEW gec: should this also be changed to main-cm? This would mean a breaking change.
(defn -main [& cmd-args]
(main-common "c4k-common"
core/config?

View file

@ -12,16 +12,17 @@
(s/def ::cluster-name ::int/cluster-name)
(s/def ::cluster-stage ::int/cluster-stage)
(s/def ::mon-cfg (s/keys :req-un [::grafana-cloud-url
::cluster-name
::cluster-stage]))
(s/def ::mon-auth (s/keys :req-un [::grafana-cloud-user
::grafana-cloud-password]))
::cluster-name
::cluster-stage]))
(s/def ::mon-auth (s/keys :req-un [::grafana-cloud-user
::grafana-cloud-password]))
(def filter-regex-string int/filter-regex-string)
(defn-spec generate seq?
(defn-spec ^{:deprecated "6.4.1"} generate seq?
"use generate-config and generate-auth instead"
[config ::mon-cfg
auth ::mon-auth]
[(yaml/load-as-edn "monitoring/namespace.yaml")
@ -29,7 +30,7 @@
(yaml/load-as-edn "monitoring/prometheus-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/prometheus-service.yaml")
(yaml/load-as-edn "monitoring/prometheus-service-account.yaml")
(int/generate-config config auth)
(int/generate-config-secret config auth)
(yaml/load-as-edn "monitoring/prometheus-deployment.yaml")
(yaml/load-as-edn "monitoring/node-exporter-service-account.yaml")
(yaml/load-as-edn "monitoring/node-exporter-cluster-role.yaml")
@ -41,3 +42,28 @@
(yaml/load-as-edn "monitoring/kube-state-metrics-deployment.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service-account.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service.yaml")])
(defn-spec generate-config seq?
[config ::mon-cfg
auth ::mon-auth]
[(yaml/load-as-edn "monitoring/namespace.yaml")
(yaml/load-as-edn "monitoring/prometheus-cluster-role.yaml")
(yaml/load-as-edn "monitoring/prometheus-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/prometheus-service.yaml")
(yaml/load-as-edn "monitoring/prometheus-service-account.yaml")
(yaml/load-as-edn "monitoring/prometheus-deployment.yaml")
(yaml/load-as-edn "monitoring/node-exporter-service-account.yaml")
(yaml/load-as-edn "monitoring/node-exporter-cluster-role.yaml")
(yaml/load-as-edn "monitoring/node-exporter-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/node-exporter-daemon-set.yaml")
(yaml/load-as-edn "monitoring/node-exporter-service.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-cluster-role.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-deployment.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service-account.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service.yaml")])
(defn-spec generate-auth seq?
[config ::mon-cfg
auth ::mon-auth]
[(int/generate-config-secret config auth)])

View file

@ -82,11 +82,21 @@
grafana-cloud-password)
(cm/replace-all-matching "FILTER_REGEX" filter-regex-string))))
(defn-spec generate-config map?
(defn-spec generate-config-secret map?
[config ::mon-cfg
auth ::mon-auth]
(->
(yaml/load-as-edn "monitoring/prometheus-config.yaml")
(yaml/load-as-edn "monitoring/prometheus-config-secret.yaml")
(assoc-in [:stringData :prometheus.yaml]
(yaml/to-string
(generate-prometheus-config config auth)))))
(defn-spec ^{:deprecated "6.4.1"} generate-config map?
"Use generate-config-secret instead"
[config ::mon-cfg
auth ::mon-auth]
(->
(yaml/load-as-edn "monitoring/prometheus-config-secret.yaml")
(assoc-in [:stringData :prometheus.yaml]
(yaml/to-string
(generate-prometheus-config config auth)))))