mirror of
https://github.com/carlosedp/cluster-monitoring.git
synced 2024-11-20 19:07:17 +01:00
Start working on dynamic jsonnet loading for modules
This commit is contained in:
parent
056dd8a8b0
commit
ad1677dad5
@ -67,24 +67,24 @@ local vars = import 'vars.jsonnet';
|
|||||||
local pvc = k.core.v1.persistentVolumeClaim,
|
local pvc = k.core.v1.persistentVolumeClaim,
|
||||||
prometheus+: {
|
prometheus+: {
|
||||||
spec+: {
|
spec+: {
|
||||||
retention: '15d',
|
retention: '15d',
|
||||||
externalUrl: 'http://' + $._config.urls.prom_ingress,
|
externalUrl: 'http://' + $._config.urls.prom_ingress,
|
||||||
}
|
}
|
||||||
+ ( if vars.enablePersistence['prometheus'] then {
|
+ (if vars.enablePersistence.prometheus then {
|
||||||
storage: {
|
storage: {
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
pvc.new() +
|
pvc.new() +
|
||||||
pvc.mixin.spec.withAccessModes('ReadWriteOnce') +
|
pvc.mixin.spec.withAccessModes('ReadWriteOnce') +
|
||||||
pvc.mixin.spec.resources.withRequests({ storage: '20Gi' }),
|
pvc.mixin.spec.resources.withRequests({ storage: '20Gi' }),
|
||||||
// Uncomment below to define a StorageClass name
|
// Uncomment below to define a StorageClass name
|
||||||
//+ pvc.mixin.spec.withStorageClassName('nfs-master-ssd'),
|
//+ pvc.mixin.spec.withStorageClassName('nfs-master-ssd'),
|
||||||
},
|
},
|
||||||
} else {}),
|
} else {}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// Override deployment for Grafana data persistence
|
// Override deployment for Grafana data persistence
|
||||||
grafana+:: if vars.enablePersistence['grafana'] then {
|
grafana+:: if vars.enablePersistence.grafana then {
|
||||||
deployment+: {
|
deployment+: {
|
||||||
spec+: {
|
spec+: {
|
||||||
template+: {
|
template+: {
|
||||||
|
57
main.jsonnet
57
main.jsonnet
@ -1,5 +1,14 @@
|
|||||||
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 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')
|
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
||||||
+ (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
|
+ (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
|
||||||
@ -10,11 +19,7 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
|||||||
+ (import 'base_operator_stack.jsonnet')
|
+ (import 'base_operator_stack.jsonnet')
|
||||||
+ (import 'smtp_server.jsonnet')
|
+ (import 'smtp_server.jsonnet')
|
||||||
// Additional Modules
|
// Additional Modules
|
||||||
+ (if vars.installModules['arm-exporter'] then (import 'arm_exporter.jsonnet') else {})
|
+ join_objects([module.file for module in vars.modules if module.enabled])
|
||||||
+ (if vars.installModules.metallb then (import 'metallb.jsonnet') else {})
|
|
||||||
+ (if vars.installModules.traefik 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 {})
|
|
||||||
// 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');
|
||||||
|
|
||||||
@ -27,15 +32,35 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
|||||||
{ ['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
|
// 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 then
|
[std.asciiLower(moduleName) + '-' + objName]: {kp.moduleName[objName]}
|
||||||
{ ['metallb-' + name]: kp.metallb[name] for name in std.objectFields(kp.metallb) } else {}) +
|
for objName in [std.objectFields(kp[moduleName]] for moduleName in enabledModules
|
||||||
(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
|
// local items = ["a", "b", "c"],
|
||||||
{ ['elasticexporter-' + name]: kp.elasticExporter[name] for name in std.objectFields(kp.elasticExporter) } else {})
|
// 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 {})
|
||||||
|
@ -10,7 +10,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
metallb+:: {
|
metallbExporter+:: {
|
||||||
serviceMonitor:
|
serviceMonitor:
|
||||||
{
|
{
|
||||||
apiVersion: 'monitoring.coreos.com/v1',
|
apiVersion: 'monitoring.coreos.com/v1',
|
||||||
|
@ -9,7 +9,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
traefik+:: {
|
traefikExporter+:: {
|
||||||
serviceMonitor:
|
serviceMonitor:
|
||||||
{
|
{
|
||||||
apiVersion: 'monitoring.coreos.com/v1',
|
apiVersion: 'monitoring.coreos.com/v1',
|
||||||
|
36
vars.jsonnet
36
vars.jsonnet
@ -1,12 +1,32 @@
|
|||||||
{
|
{
|
||||||
// Enable or disable additional modules
|
// Enable or disable additional modules
|
||||||
installModules: {
|
modules: [
|
||||||
'arm-exporter': false,
|
{
|
||||||
metallb: false,
|
name: 'armExporter',
|
||||||
traefik: false,
|
enabled: true,
|
||||||
'ups-exporter': false,
|
file: import 'arm_exporter.jsonnet',
|
||||||
'elastic-exporter': false,
|
},
|
||||||
},
|
{
|
||||||
|
name: 'upsExporter',
|
||||||
|
enabled: true,
|
||||||
|
file: import 'ups_exporter.jsonnet',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'metallbExporter',
|
||||||
|
enabled: true,
|
||||||
|
file: import 'metallb.jsonnet',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'traefikExporter',
|
||||||
|
enabled: true,
|
||||||
|
file: import 'traefik.jsonnet',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'elasticExporter',
|
||||||
|
enabled: true,
|
||||||
|
file: import 'elasticsearch_exporter.jsonnet',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
// Setting these to false, defaults to emptyDirs
|
// Setting these to false, defaults to emptyDirs
|
||||||
enablePersistence: {
|
enablePersistence: {
|
||||||
@ -15,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Domain suffix for the ingresses
|
// Domain suffix for the ingresses
|
||||||
suffixDomain: "192.168.99.102.nip.io",
|
suffixDomain: '192.168.99.100.nip.io',
|
||||||
|
|
||||||
// Grafana "from" email
|
// Grafana "from" email
|
||||||
grafana: {
|
grafana: {
|
||||||
|
Loading…
Reference in New Issue
Block a user