mirror of
https://github.com/carlosedp/cluster-monitoring.git
synced 2024-11-20 19:07:17 +01:00
Separate variables into new file. Add persistence options
This commit is contained in:
parent
d4114769e2
commit
3487ade880
@ -1,13 +1,15 @@
|
||||
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
local vars = import 'vars.jsonnet';
|
||||
|
||||
{
|
||||
_config+:: {
|
||||
namespace: 'monitoring',
|
||||
|
||||
urls+:: {
|
||||
prom_ingress: 'prometheus.internal.carlosedp.com',
|
||||
alert_ingress: 'alertmanager.internal.carlosedp.com',
|
||||
grafana_ingress: 'grafana.internal.carlosedp.com',
|
||||
grafana_ingress_external: 'grafana.cloud.carlosedp.com',
|
||||
prom_ingress: 'prometheus.' + vars.suffixDomain,
|
||||
alert_ingress: 'alertmanager.' + vars.suffixDomain,
|
||||
grafana_ingress: 'grafana.' + vars.suffixDomain,
|
||||
grafana_ingress_external: 'grafana.' + vars.suffixDomain,
|
||||
},
|
||||
|
||||
prometheus+:: {
|
||||
@ -41,13 +43,6 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
grafana+:: {
|
||||
config: {
|
||||
sections: {
|
||||
// database: { path: '/data/grafana.db' },
|
||||
// paths: {
|
||||
// data: '/var/lib/grafana',
|
||||
// logs: '/var/lib/grafana/log',
|
||||
// plugins: '/var/lib/grafana/plugins',
|
||||
// provisioning: '/etc/grafana/provisioning',
|
||||
// },
|
||||
session: { provider: 'memory' },
|
||||
'auth.basic': { enabled: false },
|
||||
'auth.anonymous': { enabled: false },
|
||||
@ -56,7 +51,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
host: 'smtp-server.monitoring.svc:25',
|
||||
user: '',
|
||||
password: '',
|
||||
from_address: 'carlosedp@gmail.com',
|
||||
from_address: vars.grafana.from_address,
|
||||
from_name: 'Grafana Alert',
|
||||
skip_verify: true,
|
||||
},
|
||||
@ -74,6 +69,8 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
spec+: {
|
||||
retention: '15d',
|
||||
externalUrl: 'http://' + $._config.urls.prom_ingress,
|
||||
}
|
||||
+ ( if vars.enablePersistence['prometheus'] then {
|
||||
storage: {
|
||||
volumeClaimTemplate:
|
||||
pvc.new() +
|
||||
@ -82,12 +79,12 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
// Uncomment below to define a StorageClass name
|
||||
//+ pvc.mixin.spec.withStorageClassName('nfs-master-ssd'),
|
||||
},
|
||||
},
|
||||
} else {}),
|
||||
},
|
||||
},
|
||||
|
||||
// Override deployment for Grafana data persistence
|
||||
grafana+:: {
|
||||
grafana+:: if vars.enablePersistence['grafana'] then {
|
||||
deployment+: {
|
||||
spec+: {
|
||||
template+: {
|
||||
@ -116,7 +113,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
pvc.mixin.metadata.withName('grafana-storage') +
|
||||
pvc.mixin.spec.withAccessModes('ReadWriteMany') +
|
||||
pvc.mixin.spec.resources.withRequests({ storage: '2Gi' }),
|
||||
},
|
||||
} else {},
|
||||
|
||||
grafanaDashboards+:: $._config.grafanaDashboards,
|
||||
|
||||
|
30
main.jsonnet
30
main.jsonnet
@ -1,13 +1,5 @@
|
||||
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||
|
||||
// Enable or disable additional modules
|
||||
local installModules = {
|
||||
'arm-exporter': true,
|
||||
metallb: true,
|
||||
traefik: true,
|
||||
'ups-exporter': true,
|
||||
'elastic-exporter': true,
|
||||
};
|
||||
local vars = import 'vars.jsonnet';
|
||||
|
||||
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
||||
+ (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
|
||||
@ -16,11 +8,11 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
||||
+ (import 'base_operator_stack.jsonnet')
|
||||
+ (import 'smtp_server.jsonnet')
|
||||
// Additional Modules
|
||||
+ (if installModules['arm-exporter'] then (import 'arm_exporter.jsonnet') else {})
|
||||
+ (if installModules.metallb then (import 'metallb.jsonnet') else {})
|
||||
+ (if installModules.traefik then (import 'traefik.jsonnet') else {})
|
||||
+ (if installModules['ups-exporter'] then (import 'ups_exporter.jsonnet') else {})
|
||||
+ (if installModules['elastic-exporter'] then (import 'elasticsearch_exporter.jsonnet') else {})
|
||||
+ (if vars.installModules['arm-exporter'] then (import 'arm_exporter.jsonnet') else {})
|
||||
+ (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
|
||||
+ (import 'image_sources_versions.jsonnet');
|
||||
|
||||
@ -35,13 +27,13 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
|
||||
{ ['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 installModules['arm-exporter'] then
|
||||
(if vars.installModules['arm-exporter'] then
|
||||
{ ['arm-exporter-' + name]: kp.armExporter[name] for name in std.objectFields(kp.armExporter) } else {}) +
|
||||
(if installModules.metallb then
|
||||
(if vars.installModules.metallb then
|
||||
{ ['metallb-' + name]: kp.metallb[name] for name in std.objectFields(kp.metallb) } else {}) +
|
||||
(if installModules.traefik then
|
||||
(if vars.installModules.traefik then
|
||||
{ ['traefik-' + name]: kp.traefik[name] for name in std.objectFields(kp.traefik) } else {}) +
|
||||
(if installModules['ups-exporter'] then
|
||||
(if vars.installModules['ups-exporter'] then
|
||||
{ ['ups-exporter-' + name]: kp.upsExporter[name] for name in std.objectFields(kp.upsExporter) } else {}) +
|
||||
(if installModules['elastic-exporter'] then
|
||||
(if vars.installModules['elastic-exporter'] then
|
||||
{ ['elasticexporter-' + name]: kp.elasticExporter[name] for name in std.objectFields(kp.elasticExporter) } else {})
|
||||
|
24
vars.jsonnet
Normal file
24
vars.jsonnet
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
// Enable or disable additional modules
|
||||
installModules: {
|
||||
'arm-exporter': false,
|
||||
metallb: false,
|
||||
traefik: false,
|
||||
'ups-exporter': false,
|
||||
'elastic-exporter': false,
|
||||
},
|
||||
|
||||
// Setting these to false, defaults to emptyDirs
|
||||
enablePersistence: {
|
||||
prometheus: false,
|
||||
grafana: false,
|
||||
},
|
||||
|
||||
// Domain suffix for the ingresses
|
||||
suffixDomain: "internal.carlosedp.com",
|
||||
|
||||
// Grafana from email
|
||||
grafana: {
|
||||
from_address: 'carlosedp@gmail.com',
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user