-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpromtail.tf
106 lines (95 loc) · 2.33 KB
/
promtail.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
# Config
resource "kubernetes_config_map" "promtail" {
metadata {
name = "${var.promtail_name}-config"
namespace = var.create_namespace ? kubernetes_namespace.namespace[0].id : var.namespace
labels = {
app = var.promtail_name
}
}
data = {
"promtail.yaml" = file("${path.module}/templates/promtail.yaml")
}
}
# Deploy per node
module "promtail_daemonset" {
source = "terraform-iaac/daemonset/kubernetes"
version = "1.4.2"
image = var.promtail_docker_image
name = var.promtail_name
namespace = var.create_namespace ? kubernetes_namespace.namespace[0].id : var.namespace
args = [
"-config.file=/etc/promtail/promtail.yaml", "-client.url=http://${module.loki_service.name}:3100/loki/api/v1/push"
]
service_account_name = kubernetes_service_account.promtail.metadata[0].name
service_account_token = true
resources = var.promtail_resources
toleration = var.promtail_toleration
env_field = {
"HOSTNAME" = "spec.nodeName"
}
internal_port = var.promtail_internal_port
security_context = [
{
read_only_root_filesystem = true
run_as_group = 0
run_as_user = 0
}
]
readiness_probe = [
{
failure_threshold = 5
initial_delay_seconds = 10
period_seconds = 10
success_threshold = 1
timeout_seconds = 1
http_get = {
path = "/ready"
port = var.promtail_internal_port.0.name
scheme = "HTTP"
}
}
]
# Volumes
volume_config_map = [
{
volume_name = "config"
mode = "0420"
name = kubernetes_config_map.promtail.metadata[0].name
}
]
volume_host_path = [
{
path_on_node = "/run/promtail"
volume_name = "run"
},
{
path_on_node = "/var/lib/docker/containers"
volume_name = "docker"
},
{
path_on_node = "/var/log/pods"
volume_name = "pods"
}
]
volume_mount = [
{
mount_path = "/etc/promtail"
volume_name = "config"
},
{
mount_path = "/run/promtail"
volume_name = "run"
},
{
mount_path = "/var/lib/docker/containers"
volume_name = "docker"
read_only = true
},
{
mount_path = "/var/log/pods"
volume_name = "pods"
read_only = true
}
]
}