-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
73 lines (60 loc) · 1.96 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
module "labels" {
source = "clouddrove/labels/gcp"
version = "1.0.0"
name = var.name
environment = var.environment
label_order = var.label_order
}
resource "google_container_cluster" "primary" {
count = var.google_container_cluster_enabled && var.module_enabled ? 1 : 0
name = module.labels.id
location = var.location
network = var.network
subnetwork = var.subnetwork
remove_default_node_pool = var.remove_default_node_pool
initial_node_count = var.initial_node_count
min_master_version = var.gke_version
}
resource "google_container_node_pool" "node_pool" {
provider = google-beta
name = module.labels.id
project = var.project_id
location = var.location
cluster = join("", google_container_cluster.primary.*.id)
initial_node_count = var.initial_node_count
autoscaling {
min_node_count = var.min_node_count
max_node_count = var.max_node_count
location_policy = var.location_policy
}
management {
auto_repair = var.auto_repair
auto_upgrade = var.auto_upgrade
}
node_config {
image_type = var.image_type
machine_type = var.machine_type
service_account = var.service_account
disk_size_gb = var.disk_size_gb
disk_type = var.disk_type
preemptible = var.preemptible
}
lifecycle {
ignore_changes = [initial_node_count]
create_before_destroy = false
}
timeouts {
create = var.cluster_create_timeouts
update = var.cluster_update_timeouts
delete = var.cluster_delete_timeouts
}
}
resource "null_resource" "configure_kubectl" {
provisioner "local-exec" {
command = "gcloud container clusters get-credentials ${var.cluster_name} --region ${var.region} --project ${var.project_id}"
environment = {
KUBECONFIG = var.kubectl_config_path != "" ? var.kubectl_config_path : ""
}
}
depends_on = [google_container_node_pool.node_pool]
}