|
| 1 | +/** |
| 2 | + * Copyright 2018 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 = "simple-regional-private" |
| 19 | +} |
| 20 | + |
| 21 | +data "google_client_config" "default" {} |
| 22 | + |
| 23 | +provider "kubernetes" { |
| 24 | + host = "https://${module.gke.endpoint}" |
| 25 | + token = data.google_client_config.default.access_token |
| 26 | + cluster_ca_certificate = base64decode(module.gke.ca_certificate) |
| 27 | +} |
| 28 | + |
| 29 | +data "google_compute_subnetwork" "subnetwork" { |
| 30 | + name = var.subnetwork |
| 31 | + project = var.project_id |
| 32 | + region = var.region |
| 33 | +} |
| 34 | + |
| 35 | +module "gke" { |
| 36 | + source = "../../modules/private-cluster/" |
| 37 | + project_id = var.project_id |
| 38 | + name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" |
| 39 | + regional = true |
| 40 | + region = var.region |
| 41 | + network = var.network |
| 42 | + kubernetes_version = var.kubernetes_version |
| 43 | + subnetwork = var.subnetwork |
| 44 | + ip_range_pods = var.ip_range_pods |
| 45 | + ip_range_services = var.ip_range_services |
| 46 | + create_service_account = false |
| 47 | + service_account = var.compute_engine_service_account |
| 48 | + enable_private_endpoint = true |
| 49 | + enable_private_nodes = true |
| 50 | + master_ipv4_cidr_block = "172.16.0.0/28" |
| 51 | + default_max_pods_per_node = 20 |
| 52 | + remove_default_node_pool = true |
| 53 | + |
| 54 | + node_pools = [ |
| 55 | + { |
| 56 | + name = "pool-01" |
| 57 | + min_count = 1 |
| 58 | + max_count = 100 |
| 59 | + local_ssd_count = 0 |
| 60 | + disk_size_gb = 100 |
| 61 | + disk_type = "pd-standard" |
| 62 | + auto_repair = true |
| 63 | + auto_upgrade = true |
| 64 | + service_account = var.compute_engine_service_account |
| 65 | + preemptible = false |
| 66 | + max_pods_per_node = 12 |
| 67 | + }, |
| 68 | + ] |
| 69 | + |
| 70 | + master_authorized_networks = [ |
| 71 | + { |
| 72 | + cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range |
| 73 | + display_name = "VPC" |
| 74 | + }, |
| 75 | + ] |
| 76 | +} |
0 commit comments