-
Notifications
You must be signed in to change notification settings - Fork 4
/
kubernetes_deployment.tf
102 lines (93 loc) · 2.91 KB
/
kubernetes_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
resource "kubernetes_deployment" "tfc_agent" {
metadata {
labels = {
"app.kubernetes.io/name" = "terraform-cloud-agent"
"app.kubernetes.io/module-version" = local.module-version
"app.kubernetes.io/managed-by" = "terraform"
}
name = "terraform-cloud-agent"
namespace = var.create_namespace ? kubernetes_namespace.tfc_agent_namespace[0].metadata[0].name : var.namespace
}
spec {
replicas = var.agent_replicas
selector {
match_labels = {
"app.kubernetes.io/name" = "terraform-cloud-agent"
"app.kubernetes.io/managed-by" = "terraform"
}
}
template {
metadata {
labels = {
"app.kubernetes.io/name" = "terraform-cloud-agent"
"app.kubernetes.io/version" = var.agent_version
"app.kubernetes.io/module-version" = local.module-version
"app.kubernetes.io/managed-by" = "terraform"
}
}
spec {
container {
image = "${var.agent_image}:${var.agent_version}"
name = "terraform-cloud-agent"
env {
name = "TFC_AGENT_TOKEN"
value_from {
secret_key_ref {
name = kubernetes_secret.tfc_agent_token.metadata[0].name
key = "token"
}
}
}
env {
name = "TFC_AGENT_NAME"
value_from {
config_map_key_ref {
name = kubernetes_config_map.tfc_agent_configuration.metadata[0].name
key = "name"
}
}
}
env {
name = "TFC_ADDRESS"
value_from {
config_map_key_ref {
name = kubernetes_config_map.tfc_agent_configuration.metadata[0].name
key = "url"
}
}
}
env {
name = "TFC_AGENT_LOG_LEVEL"
value_from {
config_map_key_ref {
name = kubernetes_config_map.tfc_agent_configuration.metadata[0].name
key = "log-level"
}
}
}
env {
name = "TFC_AGENT_AUTO_UPDATE"
value_from {
config_map_key_ref {
name = kubernetes_config_map.tfc_agent_configuration.metadata[0].name
key = "agent-auto-update"
}
}
}
resources {
requests = {
cpu = var.requests_cpu
memory = var.requests_memory
}
limits = {
cpu = var.limits_cpu
memory = var.limits_memory
}
}
}
automount_service_account_token = true
service_account_name = var.cluster_access ? kubernetes_service_account.tfc_agent_service_account[0].metadata[0].name : "default"
}
}
}
}