diff --git a/meta/domain-monitor/apps.tf b/meta/domain-monitor/apps.tf index 1ba6c7e..b61d6a6 100644 --- a/meta/domain-monitor/apps.tf +++ b/meta/domain-monitor/apps.tf @@ -1,39 +1,141 @@ locals { annotations = { - "vynil.solidite.fr/meta" = "domain-monitor" + "vynil.solidite.fr/meta" = var.component "vynil.solidite.fr/name" = var.namespace - "vynil.solidite.fr/domain" = var.domain_name - "vynil.solidite.fr/issuer" = var.issuer - "vynil.solidite.fr/ingress" = var.ingress_class + } + annotations_default = { + "default.vynil.solidite.fr/sso_vynil" = var.sso_vynil + "default.vynil.solidite.fr/domain_name" = var.domain_name + "default.vynil.solidite.fr/timezone" = var.timezone + "default.vynil.solidite.fr/language" = var.language + "default.vynil.solidite.fr/domain" = var.domain + "default.vynil.solidite.fr/issuer" = var.issuer + "default.vynil.solidite.fr/ingress_class" = var.ingress_class + "default.vynil.solidite.fr/app_group" = var.app_group + "default.vynil.solidite.fr/backups.enable" = var.backups.enable + "default.vynil.solidite.fr/backups.use_barman" = var.backups.use_barman + "default.vynil.solidite.fr/backups.endpoint" = var.backups.endpoint + "default.vynil.solidite.fr/backups.secret_name" = var.backups.secret_name + "default.vynil.solidite.fr/backups.key_id_key" = var.backups.key_id_key + "default.vynil.solidite.fr/backups.secret_key" = var.backups.secret_key + "default.vynil.solidite.fr/backups.restic_key" = var.backups.restic_key + "default.vynil.solidite.fr/storage.volume.accessMode" = var.storage.volume.accessMode + "default.vynil.solidite.fr/storage.volume.class" = var.storage.volume.class } global = { - "domain" = var.namespace - "domain_name" = "monitor.${var.domain_name}" - "issuer" = var.issuer - "ingress_class" = var.ingress_class - "backups" = var.backups - "app_group" = var.app_group + "sso_vynil" = var.sso_vynil + "domain_name" = var.domain_name + "timezone" = var.timezone + "language" = var.language + "domain" = var.domain + "issuer" = var.issuer + "ingress_class" = var.ingress_class + "app_group" = var.app_group } - grafana = { for k, v in var.grafana : k => v if k!="enable" } - prometheus = { for k, v in var.prometheus : k => v if k!="enable" } - alertmanager = { for k, v in var.alertmanager : k => v if k!="enable" } - loki = { for k, v in var.loki : k => v if k!="enable" } - promtail = { for k, v in var.promtail : k => v if k!="enable" } - alerts-core = { for k, v in var.alerts-core : k => v if k!="enable" } - alerts-containers = { for k, v in var.alerts-containers : k => v if k!="enable" } + global-backups = { + "enable" = var.backups.enable + "use_barman" = var.backups.use_barman + "endpoint" = var.backups.endpoint + "secret_name" = var.backups.secret_name + "key_id_key" = var.backups.key_id_key + "secret_key" = var.backups.secret_key + "restic_key" = var.backups.restic_key + } + global-volume = { + "accessMode" = var.storage.volume.accessMode + "class" = var.storage.volume.class + } + grafana = merge(local.global,{ for k, v in var.grafana : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.grafana, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.grafana, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.grafana, "storage", {}), "volume", {}), local.global-volume) + }) + }) + prometheus = merge(local.global,{ for k, v in var.prometheus : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.prometheus, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.prometheus, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.prometheus, "storage", {}), "volume", {}), local.global-volume) + }) + }) + alertmanager = merge(local.global,{ for k, v in var.alertmanager : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.alertmanager, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.alertmanager, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.alertmanager, "storage", {}), "volume", {}), local.global-volume) + }) + }) + loki = merge(local.global,{ for k, v in var.loki : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.loki, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.loki, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.loki, "storage", {}), "volume", {}), local.global-volume) + }) + }) + promtail = merge(local.global,{ for k, v in var.promtail : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.promtail, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.promtail, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.promtail, "storage", {}), "volume", {}), local.global-volume) + }) + }) + alerts-core = merge(local.global,{ for k, v in var.alerts-core : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.alerts-core, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.alerts-core, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.alerts-core, "storage", {}), "volume", {}), local.global-volume) + }) + }) + alerts-containers = merge(local.global,{ for k, v in var.alerts-containers : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.alerts-containers, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.alerts-containers, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.alerts-containers, "storage", {}), "volume", {}), local.global-volume) + }) + }) nodeExporter = { for k, v in var.node-exporter : k => v if k!="enable" } - kubeStateMetrics = merge({"cluster-admin" = true}, { for k, v in var.kube-state-metrics : k => v if k!="enable" }) - monitorControlPlan = merge({"cluster-admin" = true}, { for k, v in var.monitor-control-plan : k => v if k!="enable" }) - dashboards-cluster = { for k, v in var.dashboards-cluster : k => v if k!="enable" } - dashboards-minimal = { for k, v in var.dashboards-minimal : k => v if k!="enable" } - dashboards-namespace = { for k, v in var.dashboards-namespace : k => v if k!="enable" } - dashboards-workload = { for k, v in var.dashboards-workload : k => v if k!="enable" } + nodeExporter = merge(local.global,{ for k, v in var.node-exporter : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.node-exporter, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.node-exporter, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.node-exporter, "storage", {}), "volume", {}), local.global-volume) + }) + }) + kubeStateMetrics = merge(local.global,{ for k, v in var.kube-state-metrics : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.kube-state-metrics, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.kube-state-metrics, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.kube-state-metrics, "storage", {}), "volume", {}), local.global-volume) + }) + }) + monitorControlPlan = merge(local.global,{ for k, v in var.monitor-control-plan : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.monitor-control-plan, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.monitor-control-plan, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.monitor-control-plan, "storage", {}), "volume", {}), local.global-volume) + }) + }) + dashboards-cluster = merge(local.global,{ for k, v in var.dashboards-cluster : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.dashboards-cluster, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.dashboards-cluster, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.dashboards-cluster, "storage", {}), "volume", {}), local.global-volume) + }) + }) + dashboards-minimal = merge(local.global,{ for k, v in var.dashboards-minimal : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.dashboards-minimal, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.dashboards-minimal, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.dashboards-minimal, "storage", {}), "volume", {}), local.global-volume) + }) + }) + dashboards-namespace = merge(local.global,{ for k, v in var.dashboards-namespace : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.dashboards-namespace, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.dashboards-namespace, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.dashboards-namespace, "storage", {}), "volume", {}), local.global-volume) + }) + }) + dashboards-workload = merge(local.global,{ for k, v in var.dashboards-workload : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.dashboards-workload, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.dashboards-workload, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.dashboards-workload, "storage", {}), "volume", {}), local.global-volume) + }) + }) } resource "kubernetes_namespace_v1" "monitor-ns" { count = ( var.grafana.enable || var.loki.enable || var.promtail.enable || var.prometheus.enable || var.alertmanager.enable || var.node-exporter.enable || var.kube-state-metrics.enable || var.monitor-control-plan.enable )? 1 : 0 metadata { - annotations = local.annotations + annotations = merge(local.annotations, local.annotations_default) labels = merge(local.common-labels, local.annotations) name = "${var.namespace}-monitor" } @@ -53,7 +155,7 @@ resource "kubectl_manifest" "alertmanager" { distrib: "${var.distributions.domain}" category: "monitor" component: "alertmanager" - options: ${jsonencode(merge(local.global, local.alertmanager))} + options: ${jsonencode(local.alertmanager)} EOF } @@ -70,7 +172,7 @@ resource "kubectl_manifest" "prometheus" { distrib: "${var.distributions.domain}" category: "monitor" component: "prometheus" - options: ${jsonencode(merge(local.global, local.prometheus))} + options: ${jsonencode(local.prometheus)} EOF } @@ -87,7 +189,7 @@ resource "kubectl_manifest" "nodeExporter" { distrib: "${var.distributions.domain}" category: "monitor" component: "node-exporter" - options: ${jsonencode(merge(local.global, local.nodeExporter))} + options: ${jsonencode(local.nodeExporter)} EOF } @@ -105,7 +207,7 @@ resource "kubectl_manifest" "kubeStateMetrics" { distrib: "${var.distributions.domain}" category: "monitor" component: "kube-state-metrics" - options: ${jsonencode(merge(local.global, local.kubeStateMetrics))} + options: ${jsonencode(local.kubeStateMetrics)} EOF } @@ -123,7 +225,7 @@ resource "kubectl_manifest" "monitorControlPlan" { distrib: "${var.distributions.domain}" category: "monitor" component: "monitor-control-plan" - options: ${jsonencode(merge(local.global, local.monitorControlPlan))} + options: ${jsonencode(local.monitorControlPlan)} EOF } @@ -141,7 +243,7 @@ resource "kubectl_manifest" "alerts-core" { distrib: "${var.distributions.domain}" category: "monitor" component: "alerts-core" - options: ${jsonencode(merge(local.global, local.alerts-core))} + options: ${jsonencode(local.alerts-core)} EOF } resource "kubectl_manifest" "alerts-containers" { @@ -158,7 +260,7 @@ resource "kubectl_manifest" "alerts-containers" { distrib: "${var.distributions.domain}" category: "monitor" component: "alerts-containers" - options: ${jsonencode(merge(local.global, local.alerts-containers))} + options: ${jsonencode(local.alerts-containers)} EOF } @@ -175,7 +277,7 @@ resource "kubectl_manifest" "dashboards-cluster" { distrib: "${var.distributions.domain}" category: "monitor" component: "dashboards-cluster" - options: ${jsonencode(merge(local.global, local.dashboards-cluster))} + options: ${jsonencode(local.dashboards-cluster)} EOF } resource "kubectl_manifest" "dashboards-minimal" { @@ -191,7 +293,7 @@ resource "kubectl_manifest" "dashboards-minimal" { distrib: "${var.distributions.domain}" category: "monitor" component: "dashboards-minimal" - options: ${jsonencode(merge(local.global, local.dashboards-minimal))} + options: ${jsonencode(local.dashboards-minimal)} EOF } resource "kubectl_manifest" "dashboards-namespace" { @@ -207,7 +309,7 @@ resource "kubectl_manifest" "dashboards-namespace" { distrib: "${var.distributions.domain}" category: "monitor" component: "dashboards-namespace" - options: ${jsonencode(merge(local.global, local.dashboards-namespace))} + options: ${jsonencode(local.dashboards-namespace)} EOF } resource "kubectl_manifest" "dashboards-workload" { @@ -223,7 +325,7 @@ resource "kubectl_manifest" "dashboards-workload" { distrib: "${var.distributions.domain}" category: "monitor" component: "dashboards-workload" - options: ${jsonencode(merge(local.global, local.dashboards-workload))} + options: ${jsonencode(local.dashboards-workload)} EOF } @@ -240,7 +342,7 @@ resource "kubectl_manifest" "grafana" { distrib: "${var.distributions.domain}" category: "monitor" component: "grafana" - options: ${jsonencode(merge(local.global, local.grafana))} + options: ${jsonencode(local.grafana)} EOF } @@ -257,7 +359,7 @@ resource "kubectl_manifest" "promtail" { distrib: "${var.distributions.domain}" category: "monitor" component: "promtail" - options: ${jsonencode(merge(local.global, local.promtail))} + options: ${jsonencode(local.promtail)} EOF } @@ -274,6 +376,6 @@ resource "kubectl_manifest" "loki" { distrib: "${var.distributions.domain}" category: "monitor" component: "loki" - options: ${jsonencode(merge(local.global, local.loki))} + options: ${jsonencode(local.loki)} EOF } diff --git a/meta/domain-monitor/index.yaml b/meta/domain-monitor/index.yaml index fa204a2..69ecad7 100644 --- a/meta/domain-monitor/index.yaml +++ b/meta/domain-monitor/index.yaml @@ -6,6 +6,137 @@ metadata: name: domain-monitor description: null options: + prometheus: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: prometheus + domain: + default: your-company + examples: + - your-company + type: string + app_group: + default: infra + examples: + - infra + type: string + language: + default: fr_FR + examples: + - fr_FR + type: string + node-exporter: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: node-exporter + kube-state-metrics: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: kube-state-metrics + alerts-containers: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: alerts-containers + monitor-control-plan: + default: + enable: false + examples: + - enable: false + properties: + enable: + default: false + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: monitor-control-plan + domain_name: + default: your-company.com + examples: + - your-company.com + type: string + sso_vynil: + default: true + examples: + - true + type: boolean + ingress_class: + default: traefik + examples: + - traefik + type: string + grafana: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: grafana + alertmanager: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: alertmanager + promtail: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: promtail + timezone: + default: Europe/Paris + examples: + - Europe/Paris + type: string dashboards-minimal: default: enable: true @@ -18,6 +149,65 @@ options: type: object x-vynil-category: monitor x-vynil-package: dashboards-minimal + storage: + default: + volume: + accessMode: ReadWriteOnce + class: '' + examples: + - volume: + accessMode: ReadWriteOnce + class: '' + properties: + volume: + default: + accessMode: ReadWriteOnce + class: '' + properties: + accessMode: + default: ReadWriteOnce + type: string + class: + default: '' + type: string + type: object + type: object + dashboards-namespace: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: dashboards-namespace + loki: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: loki + alerts-core: + default: + enable: true + examples: + - enable: true + properties: + enable: + default: true + type: boolean + type: object + x-vynil-category: monitor + x-vynil-package: alerts-core dashboards-workload: default: enable: true @@ -35,7 +225,7 @@ options: examples: - letsencrypt-prod type: string - alerts-core: + dashboards-cluster: default: enable: true examples: @@ -46,36 +236,47 @@ options: type: boolean type: object x-vynil-category: monitor - x-vynil-package: alerts-core - alertmanager: + x-vynil-package: dashboards-cluster + backups: default: - enable: true + enable: false + endpoint: '' + key_id_key: s3-id + restic_key: bck-password + secret_key: s3-secret + secret_name: backup-settings + use_barman: false examples: - - enable: true + - enable: false + endpoint: '' + key_id_key: s3-id + restic_key: bck-password + secret_key: s3-secret + secret_name: backup-settings + use_barman: false properties: enable: - default: true + default: false + type: boolean + endpoint: + default: '' + type: string + key_id_key: + default: s3-id + type: string + restic_key: + default: bck-password + type: string + secret_key: + default: s3-secret + type: string + secret_name: + default: backup-settings + type: string + use_barman: + default: false type: boolean type: object - x-vynil-category: monitor - x-vynil-package: alertmanager - dashboards-namespace: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: dashboards-namespace - ingress_class: - default: traefik - examples: - - traefik - type: string distributions: default: core: core @@ -91,184 +292,6 @@ options: default: domain type: string type: object - dashboards-cluster: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: dashboards-cluster - prometheus: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: prometheus - grafana: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: grafana - kube-state-metrics: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: kube-state-metrics - app_group: - default: monitor - examples: - - monitor - type: string - backups: - default: - enable: false - endpoint: '' - key-id-key: s3-id - secret-key: s3-secret - secret-name: backup-settings - examples: - - enable: false - endpoint: '' - key-id-key: s3-id - secret-key: s3-secret - secret-name: backup-settings - properties: - enable: - default: false - type: boolean - endpoint: - default: '' - type: string - key-id-key: - default: s3-id - type: string - secret-key: - default: s3-secret - type: string - secret-name: - default: backup-settings - type: string - type: object - domain_name: - default: your_company.com - examples: - - your_company.com - type: string - promtail: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: promtail - alerts-containers: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: alerts-containers - domain: - default: your-company - examples: - - your-company - type: string - monitor-control-plan: - default: - enable: false - examples: - - enable: false - properties: - enable: - default: false - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: monitor-control-plan - node-exporter: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: node-exporter - loki: - default: - enable: true - examples: - - enable: true - properties: - enable: - default: true - type: boolean - type: object - x-vynil-category: monitor - x-vynil-package: loki - storage-classes: - default: - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' - examples: - - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' - properties: - BlockReadWriteMany: - default: '' - type: string - BlockReadWriteOnce: - default: '' - type: string - FilesystemReadWriteMany: - default: '' - type: string - FilesystemReadWriteOnce: - default: '' - type: string - type: object dependencies: [] providers: kubernetes: true