-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.tf
168 lines (164 loc) · 4.97 KB
/
main.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
resource "random_string" "kong_name" {
count = var.name == "" ? 1 : 0
length = 8
special = false
upper = false
}
resource "helm_release" "kong" {
name = local.name
atomic = true
repository = var.chart_repository
chart = var.chart_name
version = var.chart_version
namespace = var.namespace
skip_crds = var.create_ingress_controller ? false : true
set_sensitive {
name = "env.pg_password"
value = var.db_pass
}
dynamic "set" {
for_each = var.chart_extra_set_configs
content {
name = set.value["name"]
value = set.value["value"]
}
}
dynamic "set" {
for_each = var.extra_env_configs
content {
name = format("env.%s", set.value["name"])
value = set.value["value"]
}
}
values = [
yamlencode(
{
image = {
repository = local.kong_image
tag = var.kong_tag
pullSecrets = var.reg_cred
}
waitImage = {
repository = local.bash_image
tag = var.bash_image_tag
}
env = {
database = var.database_engine
pg_database = var.db_name
pg_host = var.db_host
pg_user = var.db_user
pg_port = var.db_port
}
ingressController = {
enabled = var.create_ingress_controller
ingressClass = local.ingressclass
installCRDs = var.ingress_controller_install_crds
resources = var.resources
image = {
repository = local.ingress_image
tag = var.ingress_image_tag
}
}
manager = {
enabled = var.enable_manager_service
type = var.manager_service_type
annotations = var.manager_annotations
tls = {
enabled = var.enable_manager_https
}
ingress = {
enabled = var.enable_manager_ingress
ingressClassName = var.manager_ingressClassName
annotations = var.manager_ingress_annotations
hostname = var.manager_ingress_host
path = var.manager_ingress_path
}
}
proxy = {
enabled = var.enable_proxy_service
type = var.proxy_service_type
annotations = var.proxy_annotations
tls = {
enabled = var.enable_proxy_https
}
ingress = {
enabled = var.enable_proxy_ingress
ingressClassName = var.proxy_ingressClassName
annotations = var.proxy_ingress_annotations
hostname = var.proxy_ingress_host
path = var.proxy_ingress_path
}
}
admin = {
enabled = var.enable_admin_service
type = var.admin_service_type
annotations = var.admin_annotations
http = {
enabled = true
}
tls = {
enabled = false
}
ingress = {
enabled = var.enable_admin_ingress
ingressClassName = var.admin_ingressClassName
annotations = var.admin_ingress_annotations
hostname = var.admin_ingress_hostname
path = var.admin_ingress_path
}
}
migrations = {
preUpgrade = var.migrations_pre_upgrade
postUpgrade = var.migrations_post_upgrade
resources = var.migrations_resources
}
replicaCount = var.enable_autoscaling ? var.autoscaling_min_replicas : var.replica_count
autoscaling = {
enabled = var.enable_autoscaling
minReplicas = var.autoscaling_min_replicas
maxReplicas = var.autoscaling_max_replicas
metrics = [
{
type = "Resource"
resource = {
name = "cpu"
target = {
type = "Utilization"
averageUtilization = var.autoscaling_cpu_average_usage
}
}
},
{
type = "Resource"
resource = {
name = "memory"
target = {
type = "Utilization"
averageUtilization = var.autoscaling_mem_average_usage
}
}
}
]
}
affinity = {
podAntiAffinity = {
requiredDuringSchedulingIgnoredDuringExecution = [
{
labelSelector = {
matchLabels = {
"app.kubernetes.io/component" = "app"
"app.kubernetes.io/instance" = local.name
"app.kubernetes.io/name" = "kong"
}
}
topologyKey = "kubernetes.io/hostname"
}
]
}
}
priorityClassName = var.priority_class_name
resources = var.resources
}
)
]
}