-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment.tf
129 lines (124 loc) · 3.78 KB
/
deployment.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
121
122
123
124
125
126
127
128
129
resource "kubernetes_deployment" "main" {
wait_for_rollout = var.wait_for_deployment_rollout
metadata {
name = var.app_name
namespace = var.namespace
labels = {
env = var.env
app = var.app_name
}
}
spec {
replicas = var.replicas
selector {
match_labels = {
env = var.env
app = var.app_name
}
}
template {
metadata {
labels = {
env = var.env
app = var.app_name
}
}
spec {
dynamic "volume" {
for_each = var.volume_enabled == true ? [1] : []
content {
name = var.volume_name
persistent_volume_claim {
claim_name = var.persistent_volume_claim_name
}
}
}
node_selector = var.node_selector
container {
dynamic "volume_mount" {
for_each = var.volume_enabled == true ? [1] : []
content {
mount_path = var.volume_mount_path
name = var.volume_name
}
}
image_pull_policy = var.image_pull_policy
image = lower(var.app_docker_image)
name = var.app_name
dynamic "env" {
for_each = var.envs_from_value
content {
name = env.value.name
value = env.value.value
}
}
dynamic "env" {
for_each = var.envs_from_secrets
content {
name = env.value.name
value_from {
secret_key_ref {
name = env.value.secret_name
key = env.value.secret_key
}
}
}
}
dynamic "env" {
for_each = var.envs_from_configmaps
content {
name = env.value.name
value_from {
config_map_key_ref {
name = env.value.config_name
key = env.value.config_key
}
}
}
}
port {
container_port = var.container_port
}
resources {
limits = var.resources_limits
requests = var.resources_requests
}
dynamic "readiness_probe" {
for_each = var.readiness_probe_enabled == true ? [1] : []
content {
http_get {
path = var.readiness_probe_path
port = var.container_port
}
initial_delay_seconds = var.readiness_probe_initial_delay_seconds
period_seconds = var.readiness_probe_period_seconds
timeout_seconds = var.readiness_probe_timeout_seconds
success_threshold = var.readiness_probe_success_threshold
failure_threshold = var.readiness_probe_failure_threshold
}
}
dynamic "liveness_probe" {
for_each = var.liveness_probe_enabled == true ? [1] : []
content {
http_get {
path = var.liveness_probe_path
port = var.container_port
}
initial_delay_seconds = var.liveness_probe_initial_delay_seconds
period_seconds = var.liveness_probe_period_seconds
timeout_seconds = var.liveness_probe_timeout_seconds
success_threshold = var.liveness_probe_success_threshold
failure_threshold = var.liveness_probe_failure_threshold
}
}
}
dynamic "image_pull_secrets" {
for_each = var.image_pull_secrets_enabled == true ? [1] : []
content {
name = var.image_pull_secrets
}
}
}
}
}
}