mirror of
https://github.com/carlosedp/cluster-monitoring.git
synced 2024-11-20 19:07:17 +01:00
Load additional modules dynamically from vars module definition
This commit is contained in:
parent
ad1677dad5
commit
87ed1bf665
54
main.jsonnet
54
main.jsonnet
@ -1,6 +1,5 @@
|
|||||||
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||||
local vars = import 'vars.jsonnet';
|
local vars = import 'vars.jsonnet';
|
||||||
local enabledModules = [module.name for module in vars.modules if module.enabled];
|
|
||||||
|
|
||||||
local join_objects(objs) =
|
local join_objects(objs) =
|
||||||
local aux(arr, i, running) =
|
local aux(arr, i, running) =
|
||||||
@ -18,49 +17,26 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
|||||||
+ (import 'kube-prometheus/kube-prometheus-insecure-kubelet.libsonnet')
|
+ (import 'kube-prometheus/kube-prometheus-insecure-kubelet.libsonnet')
|
||||||
+ (import 'base_operator_stack.jsonnet')
|
+ (import 'base_operator_stack.jsonnet')
|
||||||
+ (import 'smtp_server.jsonnet')
|
+ (import 'smtp_server.jsonnet')
|
||||||
// Additional Modules
|
// Additional modules are loaded dynamically from vars.jsonnet
|
||||||
+ join_objects([module.file for module in vars.modules if module.enabled])
|
+ join_objects([module.file for module in vars.modules if module.enabled])
|
||||||
// Load image versions last to override default from modules
|
// Load image versions last to override default from modules
|
||||||
+ (import 'image_sources_versions.jsonnet');
|
+ (import 'image_sources_versions.jsonnet');
|
||||||
|
|
||||||
|
// Generate core modules
|
||||||
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) }
|
{ ['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) } +
|
{ ['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-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
|
||||||
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
|
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) }
|
||||||
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
|
{ ['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) } +
|
{ ['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) } +
|
{ ['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) } +
|
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
|
||||||
{ ['ingress-' + name]: kp.ingress[name] for name in std.objectFields(kp.ingress) } +
|
{ ['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) }
|
{ ['smtp-server-' + name]: kp.smtpServer[name] for name in std.objectFields(kp.smtpServer) }
|
||||||
// Additional Modules
|
|
||||||
|
|
||||||
{
|
{ // Dynamically generate additional modules from vars.jsonnet
|
||||||
[std.asciiLower(moduleName) + '-' + objName]: {kp.moduleName[objName]}
|
[std.asciiLower(module.name) + '-' + name]: kp[module.name][name]
|
||||||
for objName in [std.objectFields(kp[moduleName]] for moduleName in enabledModules
|
for module in vars.modules
|
||||||
|
if module.enabled
|
||||||
|
for name in std.objectFields(kp[module.name])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// {
|
|
||||||
// local items = ["a", "b", "c"],
|
|
||||||
// joined: {
|
|
||||||
// [x + i]: {
|
|
||||||
// data: "x = %s and i = %s" % [x, i],
|
|
||||||
// } for i in ["1", "2"] for x in items
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// { ['arm-exporter-' + name]: kp.armExporter[name] for name in std.objectFields(kp.armExporter) }
|
|
||||||
|
|
||||||
// {[std.asciiLower(moduleName) + '-' + objName]: kp.moduleName[objName] for objName in [std.objectFields(kp[moduleName]) for moduleName in enabledModules]}
|
|
||||||
|
|
||||||
// (if vars.installModules['arm-exporter'] then
|
|
||||||
// { ['arm-exporter-' + name]: kp.armExporter[name] for name in std.objectFields(kp.armExporter) } else {}) +
|
|
||||||
// (if vars.installModules.metallb then
|
|
||||||
// { ['metallb-' + name]: kp.metallb[name] for name in std.objectFields(kp.metallb) } else {}) +
|
|
||||||
// (if vars.installModules.traefik 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 {})
|
|
||||||
|
@ -5,7 +5,7 @@ metadata:
|
|||||||
namespace: monitoring
|
namespace: monitoring
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: alertmanager.192.168.99.102.nip.io
|
- host: alertmanager.192.168.99.100.nip.io
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
|
@ -5,7 +5,7 @@ metadata:
|
|||||||
namespace: monitoring
|
namespace: monitoring
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: grafana.192.168.99.102.nip.io
|
- host: grafana.192.168.99.100.nip.io
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
|
@ -5,7 +5,7 @@ metadata:
|
|||||||
namespace: monitoring
|
namespace: monitoring
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: prometheus.192.168.99.102.nip.io
|
- host: prometheus.192.168.99.100.nip.io
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
|
@ -26,7 +26,7 @@ spec:
|
|||||||
namespace: monitoring
|
namespace: monitoring
|
||||||
port: web
|
port: web
|
||||||
baseImage: carlosedp/prometheus
|
baseImage: carlosedp/prometheus
|
||||||
externalUrl: http://prometheus.192.168.99.102.nip.io
|
externalUrl: http://prometheus.192.168.99.100.nip.io
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
beta.kubernetes.io/os: linux
|
beta.kubernetes.io/os: linux
|
||||||
replicas: 1
|
replicas: 1
|
||||||
|
10
vars.jsonnet
10
vars.jsonnet
@ -3,27 +3,27 @@
|
|||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
name: 'armExporter',
|
name: 'armExporter',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
file: import 'arm_exporter.jsonnet',
|
file: import 'arm_exporter.jsonnet',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'upsExporter',
|
name: 'upsExporter',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
file: import 'ups_exporter.jsonnet',
|
file: import 'ups_exporter.jsonnet',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'metallbExporter',
|
name: 'metallbExporter',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
file: import 'metallb.jsonnet',
|
file: import 'metallb.jsonnet',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'traefikExporter',
|
name: 'traefikExporter',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
file: import 'traefik.jsonnet',
|
file: import 'traefik.jsonnet',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'elasticExporter',
|
name: 'elasticExporter',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
file: import 'elasticsearch_exporter.jsonnet',
|
file: import 'elasticsearch_exporter.jsonnet',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user