-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.tf
100 lines (82 loc) · 1.93 KB
/
cluster.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
locals {
cluster_network_tag = "gke-${var.name}"
}
resource "google_container_cluster" "this" {
name = var.name
description = var.description
project = var.project_id
location = var.region
network = data.google_compute_network.this.id
subnetwork = data.google_compute_subnetwork.this.id
enable_autopilot = true
release_channel {
channel = var.release_channel
}
cost_management_config {
enabled = true
}
cluster_autoscaling {
auto_provisioning_defaults {
service_account = google_service_account.cluster_sa.email
}
}
vertical_pod_autoscaling {
enabled = true
}
master_authorized_networks_config {
dynamic "cidr_blocks" {
for_each = var.is_private ? [
{
display_name = "Bastion Host"
cidr_block = "${module.bastion[0].ip_address}/32"
}
] : [
{
display_name = "allow all"
cidr_block = "0.0.0.0/0"
}
]
content {
display_name = cidr_blocks.value.display_name
cidr_block = cidr_blocks.value.cidr_block
}
}
}
node_pool_auto_config {
network_tags {
tags = concat(var.network_tags, [local.cluster_network_tag])
}
}
addons_config {
http_load_balancing {
disabled = false
}
horizontal_pod_autoscaling {
disabled = false
}
gcs_fuse_csi_driver_config {
enabled = true
}
}
dynamic "fleet" {
for_each = var.fleet_project != null ? [1] : []
content {
project = var.fleet_project
}
}
dynamic "private_cluster_config" {
for_each = var.is_private ? [1] : []
content {
enable_private_nodes = true
enable_private_endpoint = true
master_global_access_config {
enabled = false
}
}
}
deletion_protection = var.deletion_protection
depends_on = [
google_project_iam_member.cluster_sa_role_bindings,
module.bastion
]
}