-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path6.monitoring.tf
109 lines (92 loc) · 2.6 KB
/
6.monitoring.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
resource "kubernetes_namespace" "monitoring" {
metadata {
name = "monitoring"
}
depends_on = [
aws_eks_node_group.private_nodes
]
}
######################################## Prometheus (helm) ######################################
resource "helm_release" "prometheus" {
chart = "prometheus"
name = "prometheus"
namespace = kubernetes_namespace.monitoring.id
repository = "https://prometheus-community.github.io/helm-charts"
version = "19.3.3"
values = [
"${file("6.prometheus-values.yaml")}"
]
depends_on = [
helm_release.aws_load_balancer_controller,
aws_eks_addon.ebs_csi_driver
]
}
######################################## loki (helm) ######################################
# https://artifacthub.io/packages/helm/grafana/loki-stack
resource "helm_release" "loki" {
chart = "loki-stack"
name = "loki"
namespace = kubernetes_namespace.monitoring.id
repository = "https://grafana.github.io/helm-charts"
version = "2.9.9"
depends_on = [
helm_release.aws_load_balancer_controller
]
}
######################################## Grafana (helm) ######################################
resource "helm_release" "grafana" {
chart = "grafana"
name = "grafana"
repository = "https://grafana.github.io/helm-charts"
namespace = kubernetes_namespace.monitoring.id
version = "6.50.7"
values = [
"${file("6.grafana-values.yaml")}"
]
depends_on = [
aws_eks_addon.ebs_csi_driver
]
}
# because of "Failed to create Ingress 'monitoring/grafana' because: Unauthorized" error (probably service account is not ready yet)
resource "time_sleep" "wait_grafana" {
create_duration = "30s"
depends_on = [
helm_release.grafana
]
}
# since helm chart ingress gives problems we have to create it by our own
resource "kubernetes_ingress_v1" "grafana_ingress" {
metadata {
name = "grafana-ingress"
namespace = "monitoring"
annotations = {
"alb.ingress.kubernetes.io/load-balancer-name" = "grafana-ingress"
"alb.ingress.kubernetes.io/target-type" = "ip"
"alb.ingress.kubernetes.io/healthcheck-path" = "/login"
}
}
spec {
ingress_class_name = "alb"
rule {
host = "grafana.djangoapp.lan"
http {
path {
backend {
service {
name = "grafana"
port {
number = 80
}
}
}
path = "/*"
}
}
}
}
depends_on = [
kubernetes_namespace.monitoring,
time_sleep.wait_grafana,
helm_release.aws_load_balancer_controller
]
}