-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinstances-controlplane.tf
89 lines (76 loc) · 2.49 KB
/
instances-controlplane.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
locals {
contolplane_labels = "cloud.google.com/gke-boot-disk=pd-ssd"
}
module "controlplane" {
source = "./modules/controlplane"
for_each = toset(local.zones)
name = "${local.cluster_name}-controlplane-${each.value}"
project = local.project
region = local.region
zone = each.value
cluster_name = local.cluster_name
kubernetes = merge(var.kubernetes, {
lbv4_local = google_compute_address.lbv4_local.address
nodeSubnets = local.network_controlplane.ip_cidr_range
region = local.region
zone = each.key
project = local.project
network = local.network
})
controlplane = try(var.controlplane[each.key], {})
network = local.network_controlplane
subnetwork = local.network_controlplane.name
network_cidr = cidrsubnet(local.network_controlplane.ip_cidr_range, 6, 1 + index(local.zones, each.value))
instance_template = google_compute_instance_template.controlplane.id
}
resource "google_compute_instance_template" "controlplane" {
name_prefix = "${local.cluster_name}-controlplane-"
project = local.project
region = local.region
machine_type = "e2-medium"
tags = concat(var.tags, ["${local.cluster_name}-common", "${local.cluster_name}-controlplane"])
labels = {
label = "controlplane"
}
metadata = {
cluster-name = local.cluster_name
cluster-location = local.region
kube-labels = local.contolplane_labels
}
disk {
boot = true
auto_delete = true
disk_size_gb = 30
disk_type = "pd-ssd"
resource_policies = []
source_image = data.google_compute_image.talos.self_link
labels = { label = "${local.cluster_name}-controlplane" }
}
network_interface {
network = local.network_controlplane.network
subnetwork = local.network_controlplane.name
stack_type = "IPV4_IPV6"
access_config {
network_tier = "STANDARD"
}
ipv6_access_config {
network_tier = local.network_controlplane.ipv6_access_type == "EXTERNAL" ? "PREMIUM" : "STANDARD"
}
}
scheduling {
automatic_restart = true
on_host_maintenance = "MIGRATE"
}
shielded_instance_config {
enable_integrity_monitoring = true
enable_secure_boot = false
enable_vtpm = true
}
service_account {
email = google_service_account.controlplane.email
scopes = ["cloud-platform"]
}
lifecycle {
create_before_destroy = "true"
}
}