-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment.tf
76 lines (74 loc) · 3.71 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
module "deployment" {
# source = "../terraform-kubernetes-deployment"
source = "djangoflow/deployment/kubernetes"
version = ">=2.5.1"
for_each = local.deployments
depends_on = [kubernetes_secret_v1.secrets]
pre_install_job_command = length(each.value.pre_install_command) > 0 ? each.value.pre_install_command : (each.value.pre_install_migrate == true ? [
"python", "manage.py", "migrate"
] : [])
service_account_name = var.service_account_name
object_prefix = "${var.name}-${each.key}"
replicas = each.value.replicas
command = each.value.command
arguments = each.value.args
image_name = var.image_name
image_tag = var.image_tag
image_pull_secrets = var.image_pull_secrets
pull_policy = var.image_pull_policy
namespace = var.namespace
volumes = var.volumes
readiness_probe_enabled = each.value.readiness_probe.enabled
readiness_probe_type = length(each.value.readiness_probe.command)> 0 ? "exec" : "http_get"
readiness_probe_path = var.readiness_probe.http_get.path
readiness_probe_port = var.readiness_probe.http_get.port
readiness_probe_scheme = var.readiness_probe.http_get.scheme
readiness_probe_initial_delay = var.readiness_probe.initial_delay_seconds
readiness_probe_timeout = var.readiness_probe.timeout_seconds
readiness_probe_failure = var.readiness_probe.failure_threshold
readiness_probe_success = var.readiness_probe.success_threshold
readiness_probe_command = each.value.readiness_probe.command
liveness_probe_enabled = each.value.liveness_probe.enabled
liveness_probe_type = length(each.value.liveness_probe.command)> 0 ? "exec" : "http_get"
liveness_probe_path = var.liveness_probe.http_get.path
liveness_probe_port = var.liveness_probe.http_get.port
liveness_probe_scheme = var.liveness_probe.http_get.scheme
liveness_probe_initial_delay = var.liveness_probe.initial_delay_seconds
liveness_probe_timeout = var.liveness_probe.timeout_seconds
liveness_probe_failure = var.liveness_probe.failure_threshold
liveness_probe_success = var.liveness_probe.success_threshold
liveness_probe_command = each.value.liveness_probe.command
startup_probe_enabled = false
security_context_enabled = var.security_context_enabled
security_context_gid = var.security_context_gid
security_context_uid = var.security_context_uid
security_context_fsgroup = var.security_context_fsgroup
env = each.value.env == null ? var.env : merge(var.env, each.value.env)
resources_limits_cpu = each.value.resources_limits_cpu
resources_limits_memory = each.value.resources_limits_memory
resources_requests_cpu = each.value.resources_requests_cpu
resources_requests_memory = each.value.resources_requests_memory
labels = merge(local.common_labels, {
"app.kubernetes.io/instance" = "${var.name}-${each.key}"
"app.kubernetes.io/version" = var.image_tag
})
env_secret = [
for k, v in var.secret_env : {
secret = "${var.name}-secrets"
name = k
key = k
}
]
node_selector = var.gcp_bucket_name != null && var.cloud_sa_name != null ? {
"iam.gke.io/gke-metadata-server-enabled" = "true"
} : {}
service_links = true
ports = each.value.port > 0 ? [
{
name = "http"
protocol = "TCP"
container_port = each.value.port
service_port = "80"
}
] : []
}