Skip to content

Commit 30c62eb

Browse files
authored
fix: rollback customizations made in GoogleCloudPlatform#1566 (GoogleCloudPlatform#1573)
Undo GKE node pool customization. Undo GKE provisioning in the non autopilot mode. Apply namespace scope when provisioning kustomize manifests.
1 parent 095c2ce commit 30c62eb

File tree

6 files changed

+5
-118
lines changed

6 files changed

+5
-118
lines changed

kustomize/cloud-ops-sandbox/base/kustomization.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

kustomize/cloud-ops-sandbox/kustomization.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

kustomize/cloud-ops-sandbox/without-loadgenerator/kustomization.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

terraform/main.tf

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ locals {
2121
"cloudprofiler.googleapis.com"
2222
]
2323
memorystore_apis = ["redis.googleapis.com"]
24-
cluster_name = var.enable_autopilot == true ? google_container_cluster.my_autopilot_cluster[0].name : google_container_cluster.my_cluster[0].name
24+
cluster_name = google_container_cluster.my_cluster.name
2525
}
2626

2727
# Enable Google Cloud APIs
@@ -37,8 +37,7 @@ module "enable_google_apis" {
3737
}
3838

3939
# Create GKE cluster
40-
resource "google_container_cluster" "my_autopilot_cluster" {
41-
count = var.enable_autopilot == true ? 1 : 0
40+
resource "google_container_cluster" "my_cluster" {
4241

4342
name = var.name
4443
location = var.region
@@ -55,34 +54,6 @@ resource "google_container_cluster" "my_autopilot_cluster" {
5554
]
5655
}
5756

58-
# TODO: merge my_autopilot_cluster and my_cluster resource into one after
59-
# fixing https://github.com/hashicorp/terraform-provider-google/issues/13857
60-
resource "google_container_cluster" "my_cluster" {
61-
count = var.enable_autopilot == false && var.gke_node_pool != null ? 1 : 0
62-
63-
name = var.name
64-
location = var.region
65-
66-
node_pool {
67-
node_config {
68-
machine_type = var.gke_node_pool.machine_type
69-
oauth_scopes = var.gke_node_pool.oauth_scopes
70-
labels = var.gke_node_pool.labels
71-
}
72-
73-
initial_node_count = var.gke_node_pool.initial_node_count
74-
75-
autoscaling {
76-
min_node_count = var.gke_node_pool.autoscaling.min_node_count
77-
max_node_count = var.gke_node_pool.autoscaling.max_node_count
78-
}
79-
}
80-
81-
depends_on = [
82-
module.enable_google_apis
83-
]
84-
}
85-
8657
# Get credentials for cluster
8758
module "gcloud" {
8859
source = "terraform-google-modules/gcloud/google"
@@ -101,7 +72,7 @@ module "gcloud" {
10172
resource "null_resource" "apply_deployment" {
10273
provisioner "local-exec" {
10374
interpreter = ["bash", "-exc"]
104-
command = "kubectl apply -k ${var.filepath_manifest}"
75+
command = "kubectl apply -k ${var.filepath_manifest} -n ${var.namespace}"
10576
}
10677

10778
depends_on = [

terraform/output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
output "cluster_location" {
1616
description = "Location of the cluster"
17-
value = var.enable_autopilot == true ? resource.google_container_cluster.my_autopilot_cluster[0].location : resource.google_container_cluster.my_cluster[0].location
17+
value = resource.google_container_cluster.my_cluster.location
1818
}
1919

2020
output "cluster_name" {
2121
description = "Name of the cluster"
22-
value = var.name
22+
value = resource.google_container_cluster.my_cluster.name
2323
}

terraform/variables.tf

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,3 @@ variable "memorystore" {
4545
type = bool
4646
description = "If true, Online Boutique's in-cluster Redis cache will be replaced with a Google Cloud Memorystore Redis cache"
4747
}
48-
49-
variable "enable_autopilot" {
50-
type = bool
51-
description = "If true, GKE cluster is provisioned in autopilot mode. Provisioning in autopilot mode ignores values set in 'gke_node_pool' variable"
52-
default = true
53-
}
54-
55-
variable "gke_node_pool" {
56-
type = object({
57-
machine_type = string
58-
59-
oauth_scopes = list(string)
60-
61-
labels = map(string)
62-
63-
initial_node_count = number
64-
65-
autoscaling = object({
66-
min_node_count = number
67-
max_node_count = number
68-
})
69-
})
70-
nullable = true
71-
description = "Defines machine type and size of the default GKE cluster node pool"
72-
default = null
73-
}

0 commit comments

Comments
 (0)