-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigmap.tf
50 lines (43 loc) · 1.5 KB
/
configmap.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
locals {
default_response_headers = {
# set by nginx: x-request-id header or auto generated
"x-request-id" = "$req_id"
}
default_request_headers = {
"true-client-ip" = "$http_true_client_ip"
"x-request-id" = "$req_id"
}
}
resource "kubernetes_config_map" "request_headers" {
metadata {
name = "${local.app_name}-nginx-request-headers"
namespace = data.kubernetes_namespace.ns.metadata.0.name
labels = local.labels
}
data = merge(local.default_request_headers, try(var.nginx_extra_request_headers, {}))
}
resource "kubernetes_config_map" "response_headers" {
metadata {
name = "${local.app_name}-nginx-response-headers"
namespace = data.kubernetes_namespace.ns.metadata.0.name
labels = local.labels
}
data = merge(local.default_response_headers, try(var.nginx_extra_response_headers, {}))
}
resource "kubernetes_config_map" "nginx_ingress" {
metadata {
name = "${local.app_name}-nginx"
namespace = data.kubernetes_namespace.ns.metadata.0.name
labels = local.labels
}
data = merge(
var.nginx_configmap_entries,
{
# sent upstream
proxy-set-headers = "${kubernetes_config_map.request_headers.metadata.0.namespace}/${kubernetes_config_map.request_headers.metadata.0.name}"
# added to response
add-headers = "${kubernetes_config_map.response_headers.metadata.0.namespace}/${kubernetes_config_map.response_headers.metadata.0.name}"
large-client-header-buffers = "8 16k"
}
)
}