Skip to content

Commit

Permalink
fix: Explicitly specify VPC-native clusters for beta modules. (#598)
Browse files Browse the repository at this point in the history
* fix: Explicitly specify VPC-native clusters for beta modules.

* Use local module for safer cluster example.

* Specify machine_type for GPU nodes.
  • Loading branch information
morgante committed Jul 10, 2020
1 parent 1de41ef commit d9f7782
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 21 deletions.
3 changes: 3 additions & 0 deletions autogen/main/cluster.tf.tmpl
Expand Up @@ -171,6 +171,9 @@ resource "google_container_cluster" "primary" {
{% endif %}
}

{% if beta_cluster %}
networking_mode = "VPC_NATIVE"
{% endif %}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
2 changes: 1 addition & 1 deletion autogen/main/versions.tf.tmpl
Expand Up @@ -19,7 +19,7 @@ terraform {

required_providers {
{% if beta_cluster %}
google-beta = ">= 3.23.0, <4.0.0"
google-beta = ">= 3.29.0, <4.0.0"
{% else %}
google = ">= 3.16, <4.0.0"
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion examples/node_pool/main.tf
Expand Up @@ -19,7 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
region = var.region
}

Expand Down Expand Up @@ -48,6 +48,7 @@ module "gke" {
},
{
name = "pool-02"
machine_type = "n1-standard-2"
min_count = 1
max_count = 2
local_ssd_count = 0
Expand Down
1 change: 1 addition & 0 deletions examples/node_pool_update_variant/main.tf
Expand Up @@ -63,6 +63,7 @@ module "gke" {
},
{
name = "pool-02"
machine_type = "n1-standard-2"
min_count = 1
max_count = 2
disk_size_gb = 30
Expand Down
3 changes: 2 additions & 1 deletion examples/node_pool_update_variant_beta/main.tf
Expand Up @@ -19,7 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
credentials = file(var.credentials_path)
region = var.region
}
Expand Down Expand Up @@ -64,6 +64,7 @@ module "gke" {
},
{
name = "pool-02"
machine_type = "n1-standard-2"
min_count = 1
max_count = 2
disk_size_gb = 30
Expand Down
4 changes: 2 additions & 2 deletions examples/regional_private_node_pool_oauth_scopes/provider.tf
Expand Up @@ -15,9 +15,9 @@
*/

provider "google" {
version = "3.16.0"
version = "~> 3.16.0"
}

provider "google-beta" {
version = "3.23.0"
version = "~> 3.29.0"
}
2 changes: 1 addition & 1 deletion examples/safer_cluster/main.tf
Expand Up @@ -34,7 +34,7 @@ provider "google" {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
}

module "gke" {
Expand Down
4 changes: 2 additions & 2 deletions examples/safer_cluster_iap_bastion/cluster.tf
Expand Up @@ -15,8 +15,8 @@
*/

module "gke" {
source = "terraform-google-modules/kubernetes-engine/google//modules/safer-cluster"
version = "~> 9.0"
source = "../../modules/safer-cluster"

project_id = module.enabled_google_apis.project_id
name = var.cluster_name
region = var.region
Expand Down
4 changes: 2 additions & 2 deletions examples/safer_cluster_iap_bastion/provider.tf
Expand Up @@ -15,9 +15,9 @@
*/

provider "google" {
version = "~> 3.23"
version = "~> 3.29.0"
}

provider "google-beta" {
version = "~> 3.23"
version = "~> 3.29.0"
}
2 changes: 1 addition & 1 deletion examples/simple_regional_beta/main.tf
Expand Up @@ -19,7 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
region = var.region
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_regional_private_beta/main.tf
Expand Up @@ -24,7 +24,7 @@ provider "google" {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
region = var.region
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_zonal_with_asm/main.tf
Expand Up @@ -19,7 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
region = var.region
}

Expand Down
2 changes: 1 addition & 1 deletion examples/workload_metadata_config/main.tf
Expand Up @@ -19,7 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 3.23.0"
version = "~> 3.29.0"
region = var.region
}

Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Expand Up @@ -155,6 +155,7 @@ resource "google_container_cluster" "primary" {
}
}

networking_mode = "VPC_NATIVE"
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = "~> 0.12.6"

required_providers {
google-beta = ">= 3.23.0, <4.0.0"
google-beta = ">= 3.29.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/beta-private-cluster/cluster.tf
Expand Up @@ -155,6 +155,7 @@ resource "google_container_cluster" "primary" {
}
}

networking_mode = "VPC_NATIVE"
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = "~> 0.12.6"

required_providers {
google-beta = ">= 3.23.0, <4.0.0"
google-beta = ">= 3.29.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Expand Up @@ -155,6 +155,7 @@ resource "google_container_cluster" "primary" {
}
}

networking_mode = "VPC_NATIVE"
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster-update-variant/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = "~> 0.12.6"

required_providers {
google-beta = ">= 3.23.0, <4.0.0"
google-beta = ">= 3.29.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/beta-public-cluster/cluster.tf
Expand Up @@ -155,6 +155,7 @@ resource "google_container_cluster" "primary" {
}
}

networking_mode = "VPC_NATIVE"
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = "~> 0.12.6"

required_providers {
google-beta = ">= 3.23.0, <4.0.0"
google-beta = ">= 3.29.0, <4.0.0"
}
}
5 changes: 3 additions & 2 deletions test/fixtures/sandbox_enabled/example.tf
Expand Up @@ -32,8 +32,9 @@ module "example" {

node_pools = [
{
name = "default-node-pool"
image_type = "COS_CONTAINERD"
name = "default-node-pool"
image_type = "COS_CONTAINERD"
machine_type = "n1-standard-2"
},
]
}
2 changes: 1 addition & 1 deletion test/integration/node_pool/controls/gcloud.rb
Expand Up @@ -190,7 +190,7 @@
including(
"name" => "pool-02",
"config" => including(
"machineType" => "e2-medium",
"machineType" => "n1-standard-2",
),
)
)
Expand Down

0 comments on commit d9f7782

Please sign in to comment.