mirror of
https://github.com/carlosedp/cluster-monitoring.git
synced 2024-11-20 19:07:17 +01:00
Merge dynamic_loading branch
This commit is contained in:
commit
01949ea64f
53
main.jsonnet
53
main.jsonnet
@ -1,6 +1,14 @@
|
||||
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
local vars = import 'vars.jsonnet';
|
||||
|
||||
local join_objects(objs) =
|
||||
local aux(arr, i, running) =
|
||||
if i >= std.length(arr) then
|
||||
running
|
||||
else
|
||||
aux(arr, i + 1, running + arr[i]) tailstrict;
|
||||
aux(objs, 0, {});
|
||||
|
||||
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
||||
+ (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
|
||||
+ (import 'kube-prometheus/kube-prometheus-kops-coredns.libsonnet')
|
||||
@ -9,33 +17,26 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
||||
+ (import 'kube-prometheus/kube-prometheus-insecure-kubelet.libsonnet')
|
||||
+ (import 'base_operator_stack.jsonnet')
|
||||
+ (import 'smtp_server.jsonnet')
|
||||
// Additional Modules
|
||||
+ (if vars.installModules['arm-exporter'] then (import 'arm_exporter.jsonnet') else {})
|
||||
+ (if vars.installModules['metallb-exporter'] then (import 'metallb.jsonnet') else {})
|
||||
+ (if vars.installModules['traefik-exporter'] then (import 'traefik.jsonnet') else {})
|
||||
+ (if vars.installModules['ups-exporter'] then (import 'ups_exporter.jsonnet') else {})
|
||||
+ (if vars.installModules['elastic-exporter'] then (import 'elasticsearch_exporter.jsonnet') else {})
|
||||
// Additional modules are loaded dynamically from vars.jsonnet
|
||||
+ join_objects([module.file for module in vars.modules if module.enabled])
|
||||
// Load image versions last to override default from modules
|
||||
+ (import 'image_sources_versions.jsonnet');
|
||||
|
||||
// Generate core modules
|
||||
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) }
|
||||
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
|
||||
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
|
||||
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
|
||||
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
|
||||
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
|
||||
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
|
||||
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
|
||||
{ ['ingress-' + name]: kp.ingress[name] for name in std.objectFields(kp.ingress) } +
|
||||
{ ['smtp-server-' + name]: kp.smtpServer[name] for name in std.objectFields(kp.smtpServer) } +
|
||||
// Additional Modules
|
||||
(if vars.installModules['arm-exporter'] then
|
||||
{ ['arm-exporter-' + name]: kp.armExporter[name] for name in std.objectFields(kp.armExporter) } else {}) +
|
||||
(if vars.installModules['metallb-exporter'] then
|
||||
{ ['metallb-' + name]: kp.metallb[name] for name in std.objectFields(kp.metallb) } else {}) +
|
||||
(if vars.installModules['traefik-exporter'] then
|
||||
{ ['traefik-' + name]: kp.traefik[name] for name in std.objectFields(kp.traefik) } else {}) +
|
||||
(if vars.installModules['ups-exporter'] then
|
||||
{ ['ups-exporter-' + name]: kp.upsExporter[name] for name in std.objectFields(kp.upsExporter) } else {}) +
|
||||
(if vars.installModules['elastic-exporter'] then
|
||||
{ ['elasticexporter-' + name]: kp.elasticExporter[name] for name in std.objectFields(kp.elasticExporter) } else {})
|
||||
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) }
|
||||
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
|
||||
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) }
|
||||
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) }
|
||||
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) }
|
||||
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) }
|
||||
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
|
||||
{ ['ingress-' + name]: kp.ingress[name] for name in std.objectFields(kp.ingress) }
|
||||
{ ['smtp-server-' + name]: kp.smtpServer[name] for name in std.objectFields(kp.smtpServer) }
|
||||
|
||||
{ // Dynamically generate additional modules from vars.jsonnet
|
||||
[std.asciiLower(module.name) + '-' + name]: kp[module.name][name]
|
||||
for module in vars.modules
|
||||
if module.enabled
|
||||
for name in std.objectFields(kp[module.name])
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
|
||||
},
|
||||
|
||||
metallb+:: {
|
||||
metallbExporter+:: {
|
||||
serviceMonitor:
|
||||
{
|
||||
apiVersion: 'monitoring.coreos.com/v1',
|
||||
|
@ -9,7 +9,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
},
|
||||
},
|
||||
|
||||
traefik+:: {
|
||||
traefikExporter+:: {
|
||||
serviceMonitor:
|
||||
{
|
||||
apiVersion: 'monitoring.coreos.com/v1',
|
||||
|
34
vars.jsonnet
34
vars.jsonnet
@ -1,12 +1,32 @@
|
||||
{
|
||||
// Enable or disable additional modules
|
||||
installModules: {
|
||||
'arm-exporter': false,
|
||||
'metallb-exporter': false,
|
||||
'traefik-exporter': false,
|
||||
'ups-exporter': false,
|
||||
'elastic-exporter': false,
|
||||
},
|
||||
modules: [
|
||||
{
|
||||
name: 'armExporter',
|
||||
enabled: false,
|
||||
file: import 'arm_exporter.jsonnet',
|
||||
},
|
||||
{
|
||||
name: 'upsExporter',
|
||||
enabled: false,
|
||||
file: import 'ups_exporter.jsonnet',
|
||||
},
|
||||
{
|
||||
name: 'metallbExporter',
|
||||
enabled: false,
|
||||
file: import 'metallb.jsonnet',
|
||||
},
|
||||
{
|
||||
name: 'traefikExporter',
|
||||
enabled: false,
|
||||
file: import 'traefik.jsonnet',
|
||||
},
|
||||
{
|
||||
name: 'elasticExporter',
|
||||
enabled: false,
|
||||
file: import 'elasticsearch_exporter.jsonnet',
|
||||
},
|
||||
],
|
||||
|
||||
// Setting these to false, defaults to emptyDirs
|
||||
enablePersistence: {
|
||||
|
Loading…
Reference in New Issue
Block a user