Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move network to node_pool examples #1339

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The node_pools variable takes the following parameters:
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. | 0 | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
| name | The name of the node pool | | Required |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | | Optional |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
Expand Down
17 changes: 8 additions & 9 deletions examples/deploy_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ provider "kubernetes" {
}

module "gke" {
source = "../../"
project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = var.region
network = var.network
subnetwork = var.subnetwork

ip_range_pods = var.ip_range_pods
ip_range_services = var.ip_range_services
source = "../../"
project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = var.region
network = google_compute_network.main.name
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
create_service_account = false
service_account = var.compute_engine_service_account
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ resource "random_string" "suffix" {
upper = false
}

provider "google" {
project = var.project_ids[0]
}

resource "google_compute_network" "main" {
name = "cft-gke-test-${random_string.suffix.result}"
auto_create_subnetworks = false
project = var.project_id
}

resource "google_compute_subnetwork" "main" {
Expand Down
16 changes: 0 additions & 16 deletions examples/deploy_service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ variable "region" {
description = "The region to host the cluster in"
}

variable "network" {
description = "The VPC network to host the cluster in"
}

variable "subnetwork" {
description = "The subnetwork to host the cluster in"
}

variable "ip_range_pods" {
description = "The secondary ip range to use for pods"
}

variable "ip_range_services" {
description = "The secondary ip range to use for services"
}

variable "compute_engine_service_account" {
description = "Service account to associate to the nodes in the cluster"
}
15 changes: 8 additions & 7 deletions examples/disable_client_cert/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ provider "kubernetes" {
module "gke" {
source = "../../"

project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = var.region
network = var.network
project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = var.region
network = google_compute_network.main.name

network_project_id = var.network_project_id
subnetwork = var.subnetwork
ip_range_pods = var.ip_range_pods
ip_range_services = var.ip_range_services
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
create_service_account = false
service_account = var.compute_engine_service_account
issue_client_certificate = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@ resource "random_string" "suffix" {
upper = false
}

provider "google" {
project = var.project_ids[0]
}

resource "google_compute_network" "main" {
name = "cft-gke-test-${random_string.suffix.result}"
auto_create_subnetworks = false
project = var.project_id
}

resource "google_compute_subnetwork" "main" {
name = "cft-gke-test-${random_string.suffix.result}"
ip_cidr_range = "10.0.0.0/17"
region = var.region
region = "europe-west4"
network = google_compute_network.main.self_link

secondary_ip_range {
Expand All @@ -44,5 +41,9 @@ resource "google_compute_subnetwork" "main" {
range_name = "cft-gke-test-services-${random_string.suffix.result}"
ip_cidr_range = "192.168.64.0/18"
}
}

secondary_ip_range {
range_name = "test"
ip_cidr_range = "172.16.0.0/18"
}
}
16 changes: 0 additions & 16 deletions examples/disable_client_cert/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,10 @@ variable "region" {
description = "The region to host the cluster in"
}

variable "network" {
description = "The VPC network to host the cluster in"
}

variable "network_project_id" {
description = "The GCP project housing the VPC network to host the cluster in"
}

variable "subnetwork" {
description = "The subnetwork to host the cluster in"
}

variable "ip_range_pods" {
description = "The secondary ip range to use for pods"
}

variable "ip_range_services" {
description = "The secondary ip range to use for services"
}

variable "compute_engine_service_account" {
description = "Service account to associate to the nodes in the cluster"
}
Expand Down
4 changes: 0 additions & 4 deletions examples/node_pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ This example illustrates how to create a cluster with multiple custom node-pool
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({<br> resource_type = string<br> minimum = number<br> maximum = number<br> }))<br> })</pre> | <pre>{<br> "autoscaling_profile": "BALANCED",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |
| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes |
| network | The VPC network to host the cluster in | `any` | n/a | yes |
| project\_id | The project ID to host the cluster in | `any` | n/a | yes |
| region | The region to host the cluster in | `any` | n/a | yes |
| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes |

## Outputs
Expand Down
8 changes: 4 additions & 4 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ module "gke" {
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = var.region
zones = var.zones
network = var.network
subnetwork = var.subnetwork
ip_range_pods = var.ip_range_pods
ip_range_services = var.ip_range_services
network = google_compute_network.main.name
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
create_service_account = false
remove_default_node_pool = true
disable_legacy_metadata_endpoints = false
Expand Down
49 changes: 49 additions & 0 deletions examples/node_pool/network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

resource "random_string" "suffix" {
length = 4
special = false
upper = false
}

resource "google_compute_network" "main" {
name = "cft-gke-test-${random_string.suffix.result}"
auto_create_subnetworks = false
project = var.project_id
}

resource "google_compute_subnetwork" "main" {
name = "cft-gke-test-${random_string.suffix.result}"
ip_cidr_range = "10.0.0.0/17"
region = "europe-west4"
network = google_compute_network.main.self_link

secondary_ip_range {
range_name = "cft-gke-test-pods-${random_string.suffix.result}"
ip_cidr_range = "192.168.0.0/18"
}

secondary_ip_range {
range_name = "cft-gke-test-services-${random_string.suffix.result}"
ip_cidr_range = "192.168.64.0/18"
}

secondary_ip_range {
range_name = "test"
ip_cidr_range = "172.16.0.0/18"
}
}
1 change: 0 additions & 1 deletion examples/node_pool/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ output "service_account" {
description = "The default service account used for running nodes."
value = module.gke.service_account
}

16 changes: 0 additions & 16 deletions examples/node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,6 @@ variable "zones" {
description = "The zone to host the cluster in (required if is a zonal cluster)"
}

variable "network" {
description = "The VPC network to host the cluster in"
}

variable "subnetwork" {
description = "The subnetwork to host the cluster in"
}

variable "ip_range_pods" {
description = "The secondary ip range to use for pods"
}

variable "ip_range_services" {
description = "The secondary ip range to use for services"
}

variable "compute_engine_service_account" {
description = "Service account to associate to the nodes in the cluster"
}
Expand Down
4 changes: 0 additions & 4 deletions examples/node_pool_update_variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ This example illustrates how to create a cluster with multiple custom node-pool
|------|-------------|------|---------|:--------:|
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |
| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes |
| network | The VPC network to host the cluster in | `any` | n/a | yes |
| project\_id | The project ID to host the cluster in | `any` | n/a | yes |
| region | The region to host the cluster in | `any` | n/a | yes |
| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes |

## Outputs
Expand Down
16 changes: 5 additions & 11 deletions examples/node_pool_update_variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ locals {
cluster_type = "node-pool-update-variant"
}

data "google_compute_subnetwork" "subnetwork" {
name = var.subnetwork
project = var.project_id
region = var.region
}

data "google_client_config" "default" {}

provider "kubernetes" {
Expand All @@ -39,10 +33,10 @@ module "gke" {
regional = false
region = var.region
zones = var.zones
network = var.network
subnetwork = var.subnetwork
ip_range_pods = var.ip_range_pods
ip_range_services = var.ip_range_services
network = google_compute_network.main.name
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
create_service_account = false
service_account = var.compute_engine_service_account
enable_private_endpoint = true
Expand All @@ -51,7 +45,7 @@ module "gke" {

master_authorized_networks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
cidr_block = google_compute_subnetwork.main.ip_cidr_range
display_name = "VPC"
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ resource "random_string" "suffix" {
upper = false
}

provider "google" {
project = var.project_ids[0]
}

resource "google_compute_network" "main" {
name = "cft-gke-test-${random_string.suffix.result}"
auto_create_subnetworks = false
project = var.project_id
}

resource "google_compute_subnetwork" "main" {
Expand Down
8 changes: 4 additions & 4 deletions examples/node_pool_update_variant/test_outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ output "cluster_name" {
}

output "network" {
value = var.network
value = google_compute_network.main.name
}

output "subnetwork" {
value = var.subnetwork
value = google_compute_subnetwork.main.name
}

output "location" {
Expand All @@ -44,12 +44,12 @@ output "location" {

output "ip_range_pods" {
description = "The secondary IP range used for pods"
value = var.ip_range_pods
value = google_compute_subnetwork.main.secondary_ip_range[0].range_name
}

output "ip_range_services" {
description = "The secondary IP range used for services"
value = var.ip_range_services
value = google_compute_subnetwork.main.secondary_ip_range[1].range_name
}

output "zones" {
Expand Down
16 changes: 0 additions & 16 deletions examples/node_pool_update_variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,6 @@ variable "zones" {
description = "The zone to host the cluster in (required if is a zonal cluster)"
}

variable "network" {
description = "The VPC network to host the cluster in"
}

variable "subnetwork" {
description = "The subnetwork to host the cluster in"
}

variable "ip_range_pods" {
description = "The secondary ip range to use for pods"
}

variable "ip_range_services" {
description = "The secondary ip range to use for services"
}

variable "compute_engine_service_account" {
description = "Service account to associate to the nodes in the cluster"
}
Expand Down
4 changes: 0 additions & 4 deletions examples/node_pool_update_variant_beta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ This example illustrates how to create a cluster with multiple custom node-pool
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
| credentials\_path | The path to the GCP credentials JSON file | `any` | n/a | yes |
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |
| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes |
| network | The VPC network to host the cluster in | `any` | n/a | yes |
| project\_id | The project ID to host the cluster in | `any` | n/a | yes |
| region | The region to host the cluster in | `any` | n/a | yes |
| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes |

## Outputs
Expand Down
Loading