-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment-api.tf
101 lines (84 loc) · 1.94 KB
/
deployment-api.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
resource "kubernetes_deployment" "deployment-api" {
metadata {
name = "${var.app}-api"
namespace = "${kubernetes_namespace.ns.metadata.0.name}"
}
spec {
replicas = 2
# strategy = {
# type = "RollingUpdate"
# rolling_update = {
# max_surge = 1
# max_unavailable = 1
# }
# }
min_ready_seconds = 5
selector {
match_labels {
image_name = "${var.app}-api"
}
}
template {
metadata {
labels {
image_name = "${var.app}-api"
}
}
spec {
container {
name = "${var.app}-api"
image = "${var.container_registry}/${var.app}-api:${var.image_version}"
image_pull_policy = "Always"
port = [{
name = "http"
container_port = 3000
}]
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
liveness_probe {
http_get {
path = "/api/health"
port = 3000
}
initial_delay_seconds = 5
period_seconds = 10
timeout_seconds = 1
}
readiness_probe {
http_get {
path = "/api/health/ready"
port = 3000
}
initial_delay_seconds = 10
period_seconds = 10
timeout_seconds = 1
}
}
}
}
}
}
resource "kubernetes_service" "service-api" {
metadata {
name = "${var.app}-api"
namespace = "${kubernetes_namespace.ns.metadata.0.name}"
}
spec {
selector {
image_name = "${var.app}-api"
}
port {
port = 80
target_port = 3000
}
type = "NodePort"
}
}