From 0c8ab91c31904af54576ed7f5c419474ee7bbe95 Mon Sep 17 00:00:00 2001 From: Kenechukwu Akabueze Date: Mon, 20 May 2024 11:26:42 -0400 Subject: [PATCH 01/24] updated project ids --- environments/dev/backend.tf | 2 +- environments/dev/terraform.tfvars | 2 +- environments/prod/backend.tf | 2 +- environments/prod/terraform.tfvars | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/environments/dev/backend.tf b/environments/dev/backend.tf index 33a807a336..9583748527 100644 --- a/environments/dev/backend.tf +++ b/environments/dev/backend.tf @@ -15,7 +15,7 @@ terraform { backend "gcs" { - bucket = "PROJECT_ID-tfstate" + bucket = "aksgkelearning-tfstate" prefix = "env/dev" } } diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index cb8a5a1bbc..2b71dc6eb4 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -1 +1 @@ -project="PROJECT_ID" \ No newline at end of file +project="aksgkelearning" \ No newline at end of file diff --git a/environments/prod/backend.tf b/environments/prod/backend.tf index 7ed343b1a2..02cbbf2ae8 100644 --- a/environments/prod/backend.tf +++ b/environments/prod/backend.tf @@ -15,7 +15,7 @@ terraform { backend "gcs" { - bucket = "PROJECT_ID-tfstate" + bucket = "aksgkelearning-tfstate" prefix = "env/prod" } } diff --git a/environments/prod/terraform.tfvars b/environments/prod/terraform.tfvars index cb8a5a1bbc..2b71dc6eb4 100644 --- a/environments/prod/terraform.tfvars +++ b/environments/prod/terraform.tfvars @@ -1 +1 @@ -project="PROJECT_ID" \ No newline at end of file +project="aksgkelearning" \ No newline at end of file From 20c1abf5a4b8e2aeab32e2bdb5e06c11045a17fd Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Mon, 20 May 2024 13:07:15 -0400 Subject: [PATCH 02/24] fixing http server tag --- modules/firewall/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/firewall/main.tf b/modules/firewall/main.tf index 5e40f7089f..1d2e549134 100644 --- a/modules/firewall/main.tf +++ b/modules/firewall/main.tf @@ -27,6 +27,6 @@ resource "google_compute_firewall" "allow-http" { ports = ["80"] } - target_tags = ["http-server2"] + target_tags = ["http-server"] source_ranges = ["0.0.0.0/0"] } From 9a34721185cae992e063aa5658fa50f889d4a80f Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Mon, 20 May 2024 13:09:44 -0400 Subject: [PATCH 03/24] fixing http server tag --- cloudbuild.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 2bca928879..89d4b4fef6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -90,3 +90,5 @@ steps: echo "*******************************************************************************" fi # [END tf-apply] +options: + logging: CLOUD_LOGGING_ONLY \ No newline at end of file From 906f1a6ae2c8bb9c0fa1ebf5321f55cf7d036ed2 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Mon, 20 May 2024 14:18:54 -0400 Subject: [PATCH 04/24] fixing http server tag --- environments/dev/main.tf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index a28b76be75..ecafa6e054 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -38,3 +38,17 @@ module "firewall" { project = "${var.project}" subnet = "${module.vpc.subnet}" } + +module "vpc2" { + source = "../../modules/vpc" + project = "${var.project}" + env = "${local.env}" + network_name="ken" + subnets = [ + { + subnet_name = "ken-subnet-01" + subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/16" + subnet_region = "us-west1" + }, +] +} \ No newline at end of file From cdc12ac8be7643740b782c540cb08ed25ae3de18 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 08:39:18 -0400 Subject: [PATCH 05/24] deploying a vpc --- environments/dev/main.tf | 8 -------- modules/vpc/main.tf | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index ecafa6e054..60e5d3e16a 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -43,12 +43,4 @@ module "vpc2" { source = "../../modules/vpc" project = "${var.project}" env = "${local.env}" - network_name="ken" - subnets = [ - { - subnet_name = "ken-subnet-01" - subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/16" - subnet_region = "us-west1" - }, -] } \ No newline at end of file diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 8fce4ab20d..082fdf6574 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -32,3 +32,11 @@ module "vpc" { "${var.env}-subnet-01" = [] } } + +module "vpc2" { + source = "terraform-google-modules/network/google" + version = "3.3.0" + + project_id = "${var.project}" + network_name = "${var.env}-ken" +} \ No newline at end of file From 6c14b4dc3248cb209ceb0fd0dab3d2561e3f42a3 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 08:44:22 -0400 Subject: [PATCH 06/24] deploying a vpc --- modules/vpc/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 082fdf6574..4335eb23ee 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -39,4 +39,11 @@ module "vpc2" { project_id = "${var.project}" network_name = "${var.env}-ken" + subnets = [ + { + subnet_name = "${var.env}-subnet-ken" + subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/16" + subnet_region = "us-west2" + }, + ] } \ No newline at end of file From 4fc5a765af6a5dcf7c2c0f26ac3fc0e72cf43080 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 08:48:31 -0400 Subject: [PATCH 07/24] deploying a vpc --- environments/dev/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 60e5d3e16a..9407356a4b 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -40,7 +40,7 @@ module "firewall" { } module "vpc2" { - source = "../../modules/vpc" + source = "../../modules/vpc2" project = "${var.project}" env = "${local.env}" } \ No newline at end of file From b99f5bb0ce634ba164708d6e21d9d4d06d6b389c Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 08:51:23 -0400 Subject: [PATCH 08/24] deploying a vpc --- environments/dev/main.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 9407356a4b..5c8bdc5623 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -39,8 +39,8 @@ module "firewall" { subnet = "${module.vpc.subnet}" } -module "vpc2" { - source = "../../modules/vpc2" - project = "${var.project}" - env = "${local.env}" -} \ No newline at end of file +# module "vpc2" { +# source = "../../modules/vpc" +# project = "${var.project}" +# env = "${local.env}" +# } \ No newline at end of file From a9bd6b507705b12f809db97bd1b209d875b3aeec Mon Sep 17 00:00:00 2001 From: kenechukwu akabueze Date: Tue, 21 May 2024 09:05:33 -0400 Subject: [PATCH 09/24] Revert "testing vpc" --- environments/dev/main.tf | 6 ------ modules/vpc/main.tf | 15 --------------- 2 files changed, 21 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 5c8bdc5623..a28b76be75 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -38,9 +38,3 @@ module "firewall" { project = "${var.project}" subnet = "${module.vpc.subnet}" } - -# module "vpc2" { -# source = "../../modules/vpc" -# project = "${var.project}" -# env = "${local.env}" -# } \ No newline at end of file diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 4335eb23ee..8fce4ab20d 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -32,18 +32,3 @@ module "vpc" { "${var.env}-subnet-01" = [] } } - -module "vpc2" { - source = "terraform-google-modules/network/google" - version = "3.3.0" - - project_id = "${var.project}" - network_name = "${var.env}-ken" - subnets = [ - { - subnet_name = "${var.env}-subnet-ken" - subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/16" - subnet_region = "us-west2" - }, - ] -} \ No newline at end of file From 096e1a11694bd440f0a6d6b43361ed77c2e828fc Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 12:07:52 -0400 Subject: [PATCH 10/24] deploying a vpc --- environments/dev/main.tf | 20 +------------------- modules/vpc/main.tf | 20 +++++--------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 5c8bdc5623..05ab05877b 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -25,22 +25,4 @@ module "vpc" { source = "../../modules/vpc" project = "${var.project}" env = "${local.env}" -} - -module "http_server" { - source = "../../modules/http_server" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} - -module "firewall" { - source = "../../modules/firewall" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} - -# module "vpc2" { -# source = "../../modules/vpc" -# project = "${var.project}" -# env = "${local.env}" -# } \ No newline at end of file +} \ No newline at end of file diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 4335eb23ee..03c95a5336 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -26,24 +26,14 @@ module "vpc" { subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/24" subnet_region = "us-west1" }, + { + subnet_name = "${var.env}-subnet-02" + subnet_ip = "10.${var.env == "dev" ? 10 : 20}.11.0/24" + subnet_region = "us-west1" + }, ] secondary_ranges = { "${var.env}-subnet-01" = [] } -} - -module "vpc2" { - source = "terraform-google-modules/network/google" - version = "3.3.0" - - project_id = "${var.project}" - network_name = "${var.env}-ken" - subnets = [ - { - subnet_name = "${var.env}-subnet-ken" - subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/16" - subnet_region = "us-west2" - }, - ] } \ No newline at end of file From c743702b4d1187806b8ae263c056d5fc0148fde5 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 12:12:50 -0400 Subject: [PATCH 11/24] deploying a vpc --- environments/dev/outputs.tf | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 0ae139e4f7..18d8f03898 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -20,15 +20,3 @@ output "network" { output "subnet" { value = "${module.vpc.subnet}" } - -output "firewall_rule" { - value = "${module.firewall.firewall_rule}" -} - -output "instance_name" { - value = "${module.http_server.instance_name}" -} - -output "external_ip" { - value = "${module.http_server.external_ip}" -} From 3f19325ebb73a41321ae43cca33afe3bfdd08e54 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 12:27:30 -0400 Subject: [PATCH 12/24] updating code --- environments/dev/main.tf | 20 ++++++++++---------- environments/dev/outputs.tf | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index a28b76be75..92014711e1 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -27,14 +27,14 @@ module "vpc" { env = "${local.env}" } -module "http_server" { - source = "../../modules/http_server" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} +# module "http_server" { +# source = "../../modules/http_server" +# project = "${var.project}" +# subnet = "${module.vpc.subnet}" +# } -module "firewall" { - source = "../../modules/firewall" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} +# module "firewall" { +# source = "../../modules/firewall" +# project = "${var.project}" +# subnet = "${module.vpc.subnet}" +# } diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 0ae139e4f7..08878ec4da 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -21,14 +21,14 @@ output "subnet" { value = "${module.vpc.subnet}" } -output "firewall_rule" { - value = "${module.firewall.firewall_rule}" -} +# output "firewall_rule" { +# value = "${module.firewall.firewall_rule}" +# } -output "instance_name" { - value = "${module.http_server.instance_name}" -} +# output "instance_name" { +# value = "${module.http_server.instance_name}" +# } -output "external_ip" { - value = "${module.http_server.external_ip}" -} +# output "external_ip" { +# value = "${module.http_server.external_ip}" +# } From 0eef716af4508cd5344e5d6888fcd1b6bcba9eb9 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 17:24:06 -0400 Subject: [PATCH 13/24] deploying gke --- environments/dev/main.tf | 6 ++++++ modules/gke/main.tf | 41 ++++++++++++++++++++++++++++++++++++++++ modules/gke/outputs.tf | 14 ++++++++++++++ modules/gke/variables.tf | 17 +++++++++++++++++ modules/gke/versions.tf | 18 ++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 modules/gke/main.tf create mode 100644 modules/gke/outputs.tf create mode 100644 modules/gke/variables.tf create mode 100644 modules/gke/versions.tf diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 92014711e1..9e24ff167c 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -27,6 +27,12 @@ module "vpc" { env = "${local.env}" } +module "gke" { + source = "../../modules/gke" + project = "${var.project}" + subnet = "${module.vpc.subnet}" +} + # module "http_server" { # source = "../../modules/http_server" # project = "${var.project}" diff --git a/modules/gke/main.tf b/modules/gke/main.tf new file mode 100644 index 0000000000..af23f59b80 --- /dev/null +++ b/modules/gke/main.tf @@ -0,0 +1,41 @@ +# Copyright 2019 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 +# +# https://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. + + +locals { + network = "${element(split("-", var.subnet), 0)}" +} + +resource "google_container_cluster" "ken" { + name = "ken-gke-cluster" + location = "us-west1" + remove_default_node_pool = true + initial_node_count = 1 +} + +resource "google_container_node_pool" "ken_preemptible_nodes" { + name = "ken-node-pool" + location = "us-west1" + cluster = google_container_cluster.ken.name + node_count = 1 + + node_config { + preemptible = true + machine_type = "e2-micro" + service_account = "id-420039265868-ken@aksgkelearning.iam.gserviceaccount.com" + oauth_scopes = [ + "https://www.googleapis.com/auth/cloud-platform" + ] + } +} diff --git a/modules/gke/outputs.tf b/modules/gke/outputs.tf new file mode 100644 index 0000000000..2c31d84ad0 --- /dev/null +++ b/modules/gke/outputs.tf @@ -0,0 +1,14 @@ +# Copyright 2019 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 +# +# https://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. + diff --git a/modules/gke/variables.tf b/modules/gke/variables.tf new file mode 100644 index 0000000000..2301355111 --- /dev/null +++ b/modules/gke/variables.tf @@ -0,0 +1,17 @@ +# Copyright 2019 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 +# +# https://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. + + +variable "project" {} +variable "subnet" {} diff --git a/modules/gke/versions.tf b/modules/gke/versions.tf new file mode 100644 index 0000000000..4cc81b29fa --- /dev/null +++ b/modules/gke/versions.tf @@ -0,0 +1,18 @@ +# Copyright 2019 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 +# +# https://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. + + +terraform { + required_version = "~> 1.0.0" +} From 87b1ddaa9841a99da8a0fcf93a3644e937b11fab Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Tue, 21 May 2024 18:17:16 -0400 Subject: [PATCH 14/24] deploying gke --- environments/dev/main.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 9e24ff167c..46b6b43fd5 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -27,11 +27,11 @@ module "vpc" { env = "${local.env}" } -module "gke" { - source = "../../modules/gke" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} +# module "gke" { +# source = "../../modules/gke" +# project = "${var.project}" +# subnet = "${module.vpc.subnet}" +# } # module "http_server" { # source = "../../modules/http_server" From 95bafa52e482ba02e9e5b3ef728cfd0186c68f17 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 07:27:01 -0400 Subject: [PATCH 15/24] deployig gke cluster --- environments/dev/main.tf | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 46b6b43fd5..237affe287 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -27,20 +27,25 @@ module "vpc" { env = "${local.env}" } -# module "gke" { -# source = "../../modules/gke" -# project = "${var.project}" -# subnet = "${module.vpc.subnet}" -# } +resource "google_container_cluster" "learning" { + name = "ken-gke-cluster" + location = "us-west1" + remove_default_node_pool = true + initial_node_count = 1 +} -# module "http_server" { -# source = "../../modules/http_server" -# project = "${var.project}" -# subnet = "${module.vpc.subnet}" -# } +resource "google_container_node_pool" "learning_preemptible_nodes" { + name = "ken-node-pool" + location = "us-west1" + cluster = google_container_cluster.learning.name + node_count = 1 -# module "firewall" { -# source = "../../modules/firewall" -# project = "${var.project}" -# subnet = "${module.vpc.subnet}" -# } + node_config { + preemptible = true + machine_type = "e2-micro" + service_account = "id-420039265868-ken@aksgkelearning.iam.gserviceaccount.com" + oauth_scopes = [ + "https://www.googleapis.com/auth/cloud-platform" + ] + } +} From 1e9f75714b37cbc77fb11bafcfba6157ce04b08f Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 07:38:18 -0400 Subject: [PATCH 16/24] deployig gke cluster --- environments/dev/main.tf | 2 ++ environments/dev/outputs.tf | 12 ------------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 237affe287..8983b51b23 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -30,6 +30,8 @@ module "vpc" { resource "google_container_cluster" "learning" { name = "ken-gke-cluster" location = "us-west1" + network = "dev" + subnetwork = "dev-subnet-01" remove_default_node_pool = true initial_node_count = 1 } diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 08878ec4da..18d8f03898 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -20,15 +20,3 @@ output "network" { output "subnet" { value = "${module.vpc.subnet}" } - -# output "firewall_rule" { -# value = "${module.firewall.firewall_rule}" -# } - -# output "instance_name" { -# value = "${module.http_server.instance_name}" -# } - -# output "external_ip" { -# value = "${module.http_server.external_ip}" -# } From 196483abd1b5f8106fd48c71054eb88cd46029de Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 09:31:34 -0400 Subject: [PATCH 17/24] deployig gke cluster --- environments/dev/main.tf | 29 +++++------------------------ modules/gke/main.tf | 32 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 8983b51b23..30b00404bf 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -27,27 +27,8 @@ module "vpc" { env = "${local.env}" } -resource "google_container_cluster" "learning" { - name = "ken-gke-cluster" - location = "us-west1" - network = "dev" - subnetwork = "dev-subnet-01" - remove_default_node_pool = true - initial_node_count = 1 -} - -resource "google_container_node_pool" "learning_preemptible_nodes" { - name = "ken-node-pool" - location = "us-west1" - cluster = google_container_cluster.learning.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-micro" - service_account = "id-420039265868-ken@aksgkelearning.iam.gserviceaccount.com" - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } -} +module "gke_cluster" { + source = "../../modules/gke" + project = "${var.project}" + env = "${local.env}" +} \ No newline at end of file diff --git a/modules/gke/main.tf b/modules/gke/main.tf index af23f59b80..75fbe47596 100644 --- a/modules/gke/main.tf +++ b/modules/gke/main.tf @@ -17,25 +17,27 @@ locals { network = "${element(split("-", var.subnet), 0)}" } -resource "google_container_cluster" "ken" { +resource "google_container_cluster" "learning" { name = "ken-gke-cluster" location = "us-west1" + network = "dev" + subnetwork = "dev-subnet-01" remove_default_node_pool = true initial_node_count = 1 } -resource "google_container_node_pool" "ken_preemptible_nodes" { - name = "ken-node-pool" - location = "us-west1" - cluster = google_container_cluster.ken.name - node_count = 1 +# resource "google_container_node_pool" "learning_preemptible_nodes" { +# name = "ken-node-pool" +# location = "us-west1" +# cluster = google_container_cluster.learning.name +# node_count = 1 - node_config { - preemptible = true - machine_type = "e2-micro" - service_account = "id-420039265868-ken@aksgkelearning.iam.gserviceaccount.com" - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } -} +# node_config { +# preemptible = true +# machine_type = "e2-micro" +# service_account = "id-420039265868-ken@aksgkelearning.iam.gserviceaccount.com" +# oauth_scopes = [ +# "https://www.googleapis.com/auth/cloud-platform" +# ] +# } +# } From bb02927bc2c10d442a9302248281da2457f9ef28 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 09:33:51 -0400 Subject: [PATCH 18/24] deployig gke cluster --- environments/dev/main.tf | 1 - modules/gke/main.tf | 1 - 2 files changed, 2 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 30b00404bf..61015d743f 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -30,5 +30,4 @@ module "vpc" { module "gke_cluster" { source = "../../modules/gke" project = "${var.project}" - env = "${local.env}" } \ No newline at end of file diff --git a/modules/gke/main.tf b/modules/gke/main.tf index 75fbe47596..ee40a9057e 100644 --- a/modules/gke/main.tf +++ b/modules/gke/main.tf @@ -21,7 +21,6 @@ resource "google_container_cluster" "learning" { name = "ken-gke-cluster" location = "us-west1" network = "dev" - subnetwork = "dev-subnet-01" remove_default_node_pool = true initial_node_count = 1 } From d0124fa3a7b5f1b1a5b9ac7f0187742aeeed66b7 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 09:35:44 -0400 Subject: [PATCH 19/24] deployig gke cluster --- environments/dev/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 61015d743f..0decfd1b09 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -30,4 +30,5 @@ module "vpc" { module "gke_cluster" { source = "../../modules/gke" project = "${var.project}" + subnet = "${module.vpc.subnet}" } \ No newline at end of file From c2134c43092698189ef66b3b715f66576af6d7c5 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 09:46:09 -0400 Subject: [PATCH 20/24] deployig gke cluster --- modules/gke/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gke/main.tf b/modules/gke/main.tf index ee40a9057e..77a5562418 100644 --- a/modules/gke/main.tf +++ b/modules/gke/main.tf @@ -21,6 +21,7 @@ resource "google_container_cluster" "learning" { name = "ken-gke-cluster" location = "us-west1" network = "dev" + subnetwork="dev-subnet-01" remove_default_node_pool = true initial_node_count = 1 } From a554c44b3cbecb302a913bab7d4fba875a5302bd Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 10:02:02 -0400 Subject: [PATCH 21/24] deployig gke cluster --- environments/dev/main.tf | 20 ++++++++++---------- modules/gke/main.tf | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 0decfd1b09..a9bc0bf940 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -21,14 +21,14 @@ provider "google" { project = "${var.project}" } -module "vpc" { - source = "../../modules/vpc" - project = "${var.project}" - env = "${local.env}" -} +# module "vpc" { +# source = "../../modules/vpc" +# project = "${var.project}" +# env = "${local.env}" +# } -module "gke_cluster" { - source = "../../modules/gke" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} \ No newline at end of file +# module "gke_cluster" { +# source = "../../modules/gke" +# project = "${var.project}" +# subnet = "${module.vpc.subnet}" +# } \ No newline at end of file diff --git a/modules/gke/main.tf b/modules/gke/main.tf index 77a5562418..375da24920 100644 --- a/modules/gke/main.tf +++ b/modules/gke/main.tf @@ -20,8 +20,8 @@ locals { resource "google_container_cluster" "learning" { name = "ken-gke-cluster" location = "us-west1" - network = "dev" - subnetwork="dev-subnet-01" + network = google_compute_network.dev.id + subnetwork= google_compute_subnetwork.dev-subnet-01.id remove_default_node_pool = true initial_node_count = 1 } From 0cbb8baf254c3057ca3e37495e6903dac26be27b Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 10:07:06 -0400 Subject: [PATCH 22/24] deployig gke cluster --- environments/dev/outputs.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 18d8f03898..0cf9b0e81a 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -17,6 +17,6 @@ output "network" { value = "${module.vpc.network}" } -output "subnet" { - value = "${module.vpc.subnet}" -} +# output "subnet" { +# value = "${module.vpc.subnet}" +# } From a1ec3ada528ff206f6cbbc3453c8c9b3ef1e5faf Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 10:20:53 -0400 Subject: [PATCH 23/24] deployig gke cluster --- modules/gke/main.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/gke/main.tf b/modules/gke/main.tf index 375da24920..0b8250c061 100644 --- a/modules/gke/main.tf +++ b/modules/gke/main.tf @@ -15,13 +15,14 @@ locals { network = "${element(split("-", var.subnet), 0)}" + subnetwork= "${var.subnet[0]}" } resource "google_container_cluster" "learning" { name = "ken-gke-cluster" location = "us-west1" - network = google_compute_network.dev.id - subnetwork= google_compute_subnetwork.dev-subnet-01.id + network = "${local.network}" + subnetwork="${local.subnetwork}" remove_default_node_pool = true initial_node_count = 1 } From 3c9a675246e788e076be0fc78e2d555738f03684 Mon Sep 17 00:00:00 2001 From: keneobum881 Date: Wed, 22 May 2024 10:21:14 -0400 Subject: [PATCH 24/24] deployig gke cluster --- environments/dev/outputs.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 0cf9b0e81a..f0b6effeb7 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -13,9 +13,9 @@ # limitations under the License. -output "network" { - value = "${module.vpc.network}" -} +# output "network" { +# value = "${module.vpc.network}" +# } # output "subnet" { # value = "${module.vpc.subnet}"