-
Notifications
You must be signed in to change notification settings - Fork 8
/
daemonset.tf
121 lines (103 loc) · 2.86 KB
/
daemonset.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
110
111
112
113
114
115
116
117
118
119
120
# Create a deployment for the service
resource "kubernetes_daemonset" "this" {
count = var.daemon_set ? 1 : 0
metadata {
name = var.name
namespace = var.namespace_name
}
spec {
selector {
match_labels = {
app = var.name
}
}
template {
metadata {
annotations = {
"sidecar.istio.io/inject" = false
"prometheus.io/port" = 8877
"prometheus.io/scrape" = true
"prometheus.io/path" = "/metrics"
}
labels = {
terraform = "true",
app = var.name
}
}
spec {
service_account_name = var.name
automount_service_account_token = true
restart_policy = "Always"
container {
name = var.name
image = "${var.ambassador_image}:${var.ambassador_image_tag}"
image_pull_policy = var.image_pull_policy
termination_message_path = "/dev/termination-log"
resources {
requests {
memory = var.resources_requests_memory
cpu = var.resources_requests_cpu
}
limits {
memory = var.resources_limits_memory
cpu = var.resources_limits_cpu
}
}
env {
name = "AMBASSADOR_ID"
value = var.ambassador_id
}
env {
name = "AMBASSADOR_DEBUG"
value = var.ambassador_debug
}
env {
name = "AMBASSADOR_NAMESPACE"
value_from {
field_ref {
field_path = var.ambassador_namespace_name
}
}
}
dynamic "port" {
for_each = var.loadbalance_service_target_ports
content {
name = port.value.name
container_port = port.value.container_port
protocol = "TCP"
}
}
port {
name = "admin"
container_port = 8877
protocol = "TCP"
}
liveness_probe {
initial_delay_seconds = 3
success_threshold = 1
timeout_seconds = 1
http_get {
path = "/ambassador/v0/check_alive"
port = 8877
scheme = "HTTP"
}
}
readiness_probe {
initial_delay_seconds = 3
success_threshold = 1
timeout_seconds = 1
http_get {
path = "/ambassador/v0/check_ready"
port = 8877
scheme = "HTTP"
}
}
}
}
}
}
depends_on = [
kubernetes_namespace.this,
kubernetes_service_account.this,
]
}