|
| 1 | +/** |
| 2 | + * Copyright 2024 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +locals { |
| 18 | + cluster_type = "autopilot-private-firewalls" |
| 19 | + network_name = "${local.cluster_type}-network" |
| 20 | + subnet_name = "${local.cluster_type}-subnet" |
| 21 | + master_auth_subnetwork = "${local.cluster_type}-master-subnet" |
| 22 | + pods_range_name = "ip-range-pods-${local.cluster_type}" |
| 23 | + svc_range_name = "ip-range-svc-${local.cluster_type}" |
| 24 | + subnet_names = [for subnet_self_link in module.gcp-network.subnets_self_links : split("/", subnet_self_link)[length(split("/", subnet_self_link)) - 1]] |
| 25 | +} |
| 26 | + |
| 27 | +data "google_client_config" "default" {} |
| 28 | + |
| 29 | +provider "kubernetes" { |
| 30 | + host = "https://${module.gke.endpoint}" |
| 31 | + token = data.google_client_config.default.access_token |
| 32 | + cluster_ca_certificate = base64decode(module.gke.ca_certificate) |
| 33 | +} |
| 34 | + |
| 35 | +module "gke" { |
| 36 | + source = "../../modules/beta-autopilot-private-cluster/" |
| 37 | + project_id = var.project_id |
| 38 | + name = "${local.cluster_type}-cluster" |
| 39 | + regional = true |
| 40 | + region = var.region |
| 41 | + network = module.gcp-network.network_name |
| 42 | + subnetwork = local.subnet_names[index(module.gcp-network.subnets_names, local.subnet_name)] |
| 43 | + ip_range_pods = local.pods_range_name |
| 44 | + ip_range_services = local.svc_range_name |
| 45 | + release_channel = "REGULAR" |
| 46 | + enable_vertical_pod_autoscaling = true |
| 47 | + enable_private_endpoint = true |
| 48 | + enable_private_nodes = true |
| 49 | + master_ipv4_cidr_block = "172.16.0.0/28" |
| 50 | + add_cluster_firewall_rules = true |
| 51 | + add_master_webhook_firewall_rules = true |
| 52 | + add_shadow_firewall_rules = true |
| 53 | + network_tags = ["allow-google-apis"] |
| 54 | + deletion_protection = false |
| 55 | + |
| 56 | + master_authorized_networks = [ |
| 57 | + { |
| 58 | + cidr_block = "10.60.0.0/17" |
| 59 | + display_name = "VPC" |
| 60 | + }, |
| 61 | + ] |
| 62 | +} |
| 63 | + |
0 commit comments