Skip to content

Commit e271b78

Browse files
feat: prometheus/grafana with longhorn
1 parent ec079c9 commit e271b78

File tree

4 files changed

+10
-86
lines changed

4 files changed

+10
-86
lines changed

main.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ module "monitoring" {
103103
cluster_monitoring_telegram_token = data.azurerm_key_vault_secret.cluster_monitoring_telegram_token.value
104104

105105
grafana_admin_password = data.azurerm_key_vault_secret.grafana_admin_password.value
106-
persistent_storage = true
107-
persistent_storage_size_gi = "10"
108-
persistent_storage_location = azurerm_resource_group.rg.location
109-
persistent_storage_rg_name = azurerm_resource_group.rg.name
110106
}
111107

112108
module "bot_mod_prod" {

modules/monitoring/main.tf

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,3 @@ resource "helm_release" "prometheus-stack" {
3030
kubernetes_persistent_volume_claim.storage_pvc
3131
]
3232
}
33-
34-
resource "azurerm_managed_disk" "storage" {
35-
count = var.persistent_storage ? 1 : 0
36-
name = "md-polinetwork-${random_uuid.volume.result}"
37-
location = var.persistent_storage_location
38-
resource_group_name = var.persistent_storage_rg_name
39-
storage_account_type = "Standard_LRS"
40-
create_option = "Empty"
41-
disk_size_gb = var.persistent_storage_size_gi
42-
}
43-
44-
resource "kubernetes_persistent_volume" "storage" {
45-
count = var.persistent_storage ? 1 : 0
46-
47-
metadata {
48-
name = "${random_uuid.volume.result}-grafana-pv"
49-
}
50-
spec {
51-
capacity = {
52-
storage = "${var.persistent_storage_size_gi}Gi"
53-
}
54-
storage_class_name = "managed-csi"
55-
access_modes = ["ReadWriteOnce"]
56-
persistent_volume_source {
57-
csi {
58-
driver = "disk.csi.azure.com"
59-
volume_handle = azurerm_managed_disk.storage[0].id
60-
}
61-
}
62-
}
63-
64-
depends_on = [
65-
azurerm_managed_disk.storage
66-
]
67-
}
68-
69-
resource "kubernetes_persistent_volume_claim" "storage_pvc" {
70-
count = var.persistent_storage ? 1 : 0
71-
metadata {
72-
name = "grafana-pvc"
73-
namespace = var.namespace
74-
}
75-
spec {
76-
access_modes = ["ReadWriteOnce"]
77-
storage_class_name = "managed-csi"
78-
resources {
79-
requests = {
80-
storage = "${var.persistent_storage_size_gi}Gi"
81-
}
82-
}
83-
volume_name = kubernetes_persistent_volume.storage[0].metadata[0].name
84-
}
85-
}

modules/monitoring/values/grafana.yaml.tftpl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,28 @@ grafana:
2525
persistence:
2626
enabled: true
2727
type: pvc
28-
existingClaim: grafana-pvc
28+
storageClassName: "longhorn-static"
29+
accessModes:
30+
- ReadWriteOnce
31+
size: 5Gi
2932

3033
prometheus:
3134
prometheusSpec:
32-
retention: 5d
35+
retention: 30d
3336
storageSpec:
3437
volumeClaimTemplate:
3538
spec:
36-
storageClassName: managed-csi
39+
storageClassName: longhorn-static
3740
accessModes:
3841
- ReadWriteOnce
3942
resources:
4043
requests:
41-
storage: 32Gi
44+
storage: 12Gi
4245
resources:
4346
limits:
44-
memory: 1500Mi
45-
requests:
4647
memory: 700Mi
48+
requests:
49+
memory: 100Mi
4750

4851
alertmanager:
4952
config:

modules/monitoring/variables.tf

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,8 @@
1-
variable "persistent_storage" {
2-
type = bool
3-
description = "Volume claim for the bot"
4-
default = false
5-
}
6-
71
variable "grafana_admin_password" {
82
type = string
93
sensitive = true
104
}
115

12-
variable "persistent_storage_location" {
13-
type = string
14-
default = ""
15-
}
16-
17-
variable "persistent_storage_rg_name" {
18-
type = string
19-
default = ""
20-
}
21-
22-
variable "persistent_storage_size_gi" {
23-
type = string
24-
description = "Requested storage"
25-
default = ""
26-
}
27-
286
variable "namespace" {
297
type = string
308
description = "Grafana namespace"
@@ -36,4 +14,4 @@ variable "cluster_monitoring_app_password" {
3614

3715
variable "cluster_monitoring_telegram_token" {
3816
type = string
39-
}
17+
}

0 commit comments

Comments
 (0)