mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-05-21 16:22:51 +00:00
GCP quotas are fairly limited (on my account, I can only use 8 public IP addresses per zone, which means that I cannot deploy many public clusters in a single zone). I tried to use private clusters, but that causes other problems. This refactoring makes it possible to spread clusters across multiple zones. Since I have access to 20+ zones in Europe and 20+ zones in the US, this lets me create a lot of public clusters and simplifies the module quite a bit.
38 lines
1.2 KiB
HCL
38 lines
1.2 KiB
HCL
/*
|
|
resource "google_compute_network" "_" {
|
|
name = var.cluster_name
|
|
project = local.project
|
|
# The default is to create subnets automatically.
|
|
# However, this creates one subnet per zone in all regions,
|
|
# which causes a quick exhaustion of the subnet quota.
|
|
auto_create_subnetworks = false
|
|
}
|
|
|
|
resource "google_compute_subnetwork" "_" {
|
|
name = var.cluster_name
|
|
ip_cidr_range = "10.254.0.0/16"
|
|
region = local.region
|
|
network = google_compute_network._.id
|
|
project = local.project
|
|
}
|
|
|
|
resource "google_compute_router" "_" {
|
|
name = var.cluster_name
|
|
region = local.region
|
|
network = google_compute_network._.name
|
|
project = local.project
|
|
}
|
|
|
|
resource "google_compute_router_nat" "_" {
|
|
name = var.cluster_name
|
|
router = google_compute_router._.name
|
|
region = local.region
|
|
project = local.project
|
|
# Everyone in the network is allowed to NAT out.
|
|
# (We would change this if we only wanted to allow specific subnets to NAT out.)
|
|
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
|
|
# Pick NAT addresses automatically.
|
|
# (We would change this if we wanted to use specific addresses to NAT out.)
|
|
nat_ip_allocate_option = "AUTO_ONLY"
|
|
}
|
|
*/ |