From 951c8b7fbc69b16289e090a7e89e158a5dde13fe Mon Sep 17 00:00:00 2001 From: monika Date: Tue, 14 Sep 2021 07:48:27 +0000 Subject: [PATCH 01/82] Update project IDs and buckets --- 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..26c454deb5 100644 --- a/environments/dev/backend.tf +++ b/environments/dev/backend.tf @@ -15,7 +15,7 @@ terraform { backend "gcs" { - bucket = "PROJECT_ID-tfstate" + bucket = "yash-innovation-tfstate" prefix = "env/dev" } } diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index cb8a5a1bbc..ab2a0e269c 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -1 +1 @@ -project="PROJECT_ID" \ No newline at end of file +project="yash-innovation" \ No newline at end of file diff --git a/environments/prod/backend.tf b/environments/prod/backend.tf index 7ed343b1a2..ea29eca5c4 100644 --- a/environments/prod/backend.tf +++ b/environments/prod/backend.tf @@ -15,7 +15,7 @@ terraform { backend "gcs" { - bucket = "PROJECT_ID-tfstate" + bucket = "yash-innovation-tfstate" prefix = "env/prod" } } diff --git a/environments/prod/terraform.tfvars b/environments/prod/terraform.tfvars index cb8a5a1bbc..ab2a0e269c 100644 --- a/environments/prod/terraform.tfvars +++ b/environments/prod/terraform.tfvars @@ -1 +1 @@ -project="PROJECT_ID" \ No newline at end of file +project="yash-innovation" \ No newline at end of file From 3b64613cf0fbace4b8c6689c5ab20ad298783a29 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 14:27:14 +0530 Subject: [PATCH 02/82] Fixing http firewall target --- 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 68bfa016c45429044a2706d71eff690fe651edc2 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:37:46 +0530 Subject: [PATCH 03/82] Update main.tf --- modules/vpc/main.tf | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 8fce4ab20d..cb806c0919 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -13,22 +13,36 @@ # limitations under the License. -module "vpc" { - source = "terraform-google-modules/network/google" - version = "3.3.0" +resource "google_container_cluster" "primary" { + name = var.k8s_cluster_name + location = var.k8s_cluster_location + # We can't create a cluster with no node pool defined, but we want to only use + # separately managed node pools. So we create the smallest possible default + # node pool and immediately delete it. + remove_default_node_pool = var.k8s_remove_default_node_pool + initial_node_count = var.k8s_initial_node_count + + master_auth { + username = var.k8s_username + password = var.k8s_password - project_id = "${var.project}" - network_name = "${var.env}" - - subnets = [ - { - subnet_name = "${var.env}-subnet-01" - subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/24" - subnet_region = "us-west1" - }, - ] + client_certificate_config { + issue_client_certificate = var.k8s_issue_client_certificate + } + } +} - secondary_ranges = { - "${var.env}-subnet-01" = [] +resource "google_container_node_pool" "primary_preemptible_nodes" { + name = var.k8s_pool_name + location = var.k8s_pool_location + cluster = google_container_cluster.primary.name + node_count = var.k8s_pool_node_count + node_config { + preemptible = var.k8s_pool_preemptible + machine_type = var.k8s_pool_machine_type + metadata = { + disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints + } + oauth_scopes = var.k8s_pool_oauth_scopes } } From 45523654f9529d270f10a4ebe3e24ec336b7deca Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:39:00 +0530 Subject: [PATCH 04/82] Update variables.tf --- modules/vpc/variables.tf | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/modules/vpc/variables.tf b/modules/vpc/variables.tf index f1fc7b13b6..9bfdc9560d 100644 --- a/modules/vpc/variables.tf +++ b/modules/vpc/variables.tf @@ -15,3 +15,59 @@ variable "project" {} variable "env" {} +variable "k8s_cluster_name" { + type = string +} + +variable "k8s_cluster_location" { + type = string +} + +variable "k8s_remove_default_node_pool" { + type = bool +} + +variable "k8s_initial_node_count" { + type = number +} + +variable "k8s_username" { + type = string +} + +variable "k8s_password" { + type = string +} + +variable "k8s_issue_client_certificate" { + type = bool +} + +variable "k8s_pool_name" { + type = string +} + +variable "k8s_pool_location" { + type = string + default = "us-central1-a" +} + +variable "k8s_pool_node_count" { + type = number +} + +variable "k8s_pool_preemptible" { + type = bool +} + +variable "k8s_pool_machine_type" { + type = string +} + +variable "k8s_pool_disable-legacy-endpoints" { + type = bool +} + +variable "k8s_pool_oauth_scopes" { + type = list(string) +} From 5be80fe5a00eedb2e213af642e1b8952de247c12 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:40:51 +0530 Subject: [PATCH 05/82] Update outputs.tf --- modules/vpc/outputs.tf | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/vpc/outputs.tf b/modules/vpc/outputs.tf index 35877bbd08..7ce6843f7f 100644 --- a/modules/vpc/outputs.tf +++ b/modules/vpc/outputs.tf @@ -12,11 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +output "cluster_id" { + value = google_container_cluster.primary.id +} + +output "cluster_endpoint" { + value = google_container_cluster.primary.endpoint +} -output "network" { - value = "${module.vpc.network_name}" +output "pool_id" { + value = google_container_node_pool.primary_preemptible_nodes.id } -output "subnet" { - value = "${element(module.vpc.subnets_names, 0)}" +output "pool_instance_group_urls" { + value = google_container_node_pool.primary_preemptible_nodes.instance_group_urls } From d828eeac5be22017e9b8094975235655b51844e2 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:45:16 +0530 Subject: [PATCH 06/82] Update main.tf --- environments/dev/main.tf | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index a28b76be75..95d16aba7a 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -21,20 +21,26 @@ provider "google" { project = "${var.project}" } -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" +module "kubernetes_engine" { + source = "./modules/kubernetes_engine" + count = var.kubernetes_engine-create ? var.kubernetes_engine-count : 0 + k8s_cluster_name = var.k8s_cluster_name + k8s_cluster_location = var.k8s_cluster_location + k8s_remove_default_node_pool = var.k8s_remove_default_node_pool + k8s_initial_node_count = var.k8s_initial_node_count + k8s_username = var.k8s_username + k8s_password = var.k8s_password + k8s_issue_client_certificate = var.k8s_issue_client_certificate + k8s_pool_name = var.k8s_pool_name + k8s_pool_location = var.k8s_pool_location + k8s_pool_node_count = var.k8s_pool_node_count + k8s_pool_preemptible = var.k8s_pool_preemptible + k8s_pool_machine_type = var.k8s_pool_machine_type + k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints + k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes project = "${var.project}" - subnet = "${module.vpc.subnet}" + env = "${local.env}" } + From e15cb450e0cc9a3292a1e958485fff7395b0d489 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:47:35 +0530 Subject: [PATCH 07/82] Update variables.tf --- environments/dev/variables.tf | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 2b0a363f94..51441f2fc9 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -14,3 +14,85 @@ variable "project" {} +variable "kubernetes_engine-create" { + type = bool + default = false +} + +variable "kubernetes_engine-count" { + type = number + default = 1 +} + +variable "k8s_cluster_name" { + type = string + default = "tf-gke-cluster" +} + +variable "k8s_cluster_location" { + type = string + default = "us-central1-a" +} + +variable "k8s_remove_default_node_pool" { + type = bool + default = true +} + +variable "k8s_initial_node_count" { + type = number + default = 1 +} + +variable "k8s_username" { + type = string + default = "clusterusername" +} + +variable "k8s_password" { + type = string + default = "clusterspassword" +} + +variable "k8s_issue_client_certificate" { + type = bool + default = false +} + +variable "k8s_pool_name" { + type = string + default = "tf-node-pool" +} + +variable "k8s_pool_location" { + type = string + default = "us-central1-a" +} + +variable "k8s_pool_node_count" { + type = number + default = 1 +} + +variable "k8s_pool_preemptible" { + type = bool + default = true +} + +variable "k8s_pool_machine_type" { + type = string + default = "e2-micro" +} + +variable "k8s_pool_disable-legacy-endpoints" { + type = bool + default = true +} + +variable "k8s_pool_oauth_scopes" { + type = list(string) + default = [ + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring", + ] +} From 6d7176f3b063c5003ba15606dc130c13868eba86 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:49:29 +0530 Subject: [PATCH 08/82] Update outputs.tf --- environments/dev/outputs.tf | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 0ae139e4f7..6f350a511d 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -13,22 +13,18 @@ # limitations under the License. -output "network" { - value = "${module.vpc.network}" +output "cluster_id" { + value = module.kubernetes_engine[*].cluster_id } -output "subnet" { - value = "${module.vpc.subnet}" +output "cluster_endpoint" { + value = module.kubernetes_engine[*].cluster_endpoint } -output "firewall_rule" { - value = "${module.firewall.firewall_rule}" +output "pool_id" { + value = module.kubernetes_engine[*].pool_id } -output "instance_name" { - value = "${module.http_server.instance_name}" -} - -output "external_ip" { - value = "${module.http_server.external_ip}" +output "pool_instance_group_urls" { + value = module.kubernetes_engine[*].pool_instance_group_urls } From d8f652ccef71124c9363ab9d654cd504bc74f1bd Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:53:43 +0530 Subject: [PATCH 09/82] Update main.tf --- environments/dev/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 95d16aba7a..c0e3dd582c 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -40,7 +40,7 @@ module "kubernetes_engine" { k8s_pool_machine_type = var.k8s_pool_machine_type k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes - project = "${var.project}" - env = "${local.env}" + project = "${var.project}" + env = "${local.env}" } From d1d138db5c974b88fa00f0d82d9af4cc165022d2 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 18:31:16 +0530 Subject: [PATCH 10/82] Update variables.tf --- environments/dev/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 51441f2fc9..5e8a0056eb 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -26,7 +26,7 @@ variable "kubernetes_engine-count" { variable "k8s_cluster_name" { type = string - default = "tf-gke-cluster" + default = "tf-gke-cluster1" } variable "k8s_cluster_location" { From 2e9b80e36e0a1384115491387f688c728c82ab1e Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 18:52:39 +0530 Subject: [PATCH 11/82] Update main.tf --- 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 1d2e549134..5e40f7089f 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-server"] + target_tags = ["http-server2"] source_ranges = ["0.0.0.0/0"] } From cc81eb4410241f21ce832ca5161a3bc6d3852eb8 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 18:54:37 +0530 Subject: [PATCH 12/82] Update main.tf --- 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 752a9acc0b34659ef4ab7a192e7965b1d512f87d Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 19:20:30 +0530 Subject: [PATCH 13/82] Update cloudbuild.yaml --- cloudbuild.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index a2e241289d..581cb7e4d7 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -21,7 +21,7 @@ steps: - '-c' - | echo "***********************" - echo "$BRANCH_NAME" + echo "dev" echo "***********************" - id: 'tf init' @@ -30,8 +30,8 @@ steps: args: - '-c' - | - if [ -d "environments/$BRANCH_NAME/" ]; then - cd environments/$BRANCH_NAME + if [ -d "environments/dev/" ]; then + cd environments/dev terraform init else for dir in environments/*/ @@ -55,8 +55,8 @@ steps: args: - '-c' - | - if [ -d "environments/$BRANCH_NAME/" ]; then - cd environments/$BRANCH_NAME + if [ -d "environments/dev/" ]; then + cd environments/dev terraform plan else for dir in environments/*/ @@ -81,12 +81,12 @@ steps: args: - '-c' - | - if [ -d "environments/$BRANCH_NAME/" ]; then - cd environments/$BRANCH_NAME + if [ -d "environments/dev/" ]; then + cd environments/dev terraform apply -auto-approve else echo "***************************** SKIPPING APPLYING *******************************" - echo "Branch '$BRANCH_NAME' does not represent an oficial environment." + echo "Branch 'dev' does not represent an oficial environment." echo "*******************************************************************************" fi # [END tf-apply] From ea65a1c551bfbf3302195402e7d97dc8ee339aed Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 20:45:29 +0530 Subject: [PATCH 14/82] Update main.tf --- 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 c0e3dd582c..1bb5fd9826 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -24,7 +24,7 @@ provider "google" { module "kubernetes_engine" { - source = "./modules/kubernetes_engine" + source = "../../modules/kubernetes_engine" count = var.kubernetes_engine-create ? var.kubernetes_engine-count : 0 k8s_cluster_name = var.k8s_cluster_name k8s_cluster_location = var.k8s_cluster_location From 300eb04c7d23ce65f16b2799755323e27a90fa81 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 20:46:21 +0530 Subject: [PATCH 15/82] Update main.tf --- 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 1d2e549134..5e40f7089f 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-server"] + target_tags = ["http-server2"] source_ranges = ["0.0.0.0/0"] } From ec2f9307fc057672d3c950699fffdc2a115eb0fc Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 20:56:10 +0530 Subject: [PATCH 16/82] Update main.tf --- 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 1bb5fd9826..81c4d14217 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -24,7 +24,7 @@ provider "google" { module "kubernetes_engine" { - source = "../../modules/kubernetes_engine" + source = "../../modules/vpc" count = var.kubernetes_engine-create ? var.kubernetes_engine-count : 0 k8s_cluster_name = var.k8s_cluster_name k8s_cluster_location = var.k8s_cluster_location From e1a5dc286ee1463259b4dc4c8e24520ef84414d7 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 14 Sep 2021 20:57:41 +0530 Subject: [PATCH 17/82] Update main.tf --- 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 b1ae987251c433f2f8d442673485d7c8cf14b3be Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 11:39:18 +0530 Subject: [PATCH 18/82] Update variables.tf --- environments/dev/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 5e8a0056eb..6a1ffbe2f2 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -16,7 +16,7 @@ variable "project" {} variable "kubernetes_engine-create" { type = bool - default = false + default = true } variable "kubernetes_engine-count" { From 0fc9ab8e63036808b920a3dbeee6fa77c9446372 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 11:48:38 +0530 Subject: [PATCH 19/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index ab2a0e269c..0127bb4100 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -1 +1,41 @@ -project="yash-innovation" \ No newline at end of file +project="yash-innovation" +kubernetes_engine-create=true + + +kubernetes_engine-count=1 + + +k8s_cluster_name="tf-gke-cluster1" + +k8s_cluster_location="us-central1-a" + + +k8s_remove_default_node_pool=true + +k8s_initial_node_count=1 + +k8s_username="clusterusername" + + +k8s_password="clusterspassword" + +k8s_issue_client_certificate=false + +k8s_pool_name="tf-node-pool" + + +k8s_pool_location="us-central1-a" + + +k8s_pool_node_count=1 + +k8s_pool_preemptible=true + +k8s_pool_machine_type="e2-micro" + + +k8s_pool_disable-legacy-endpoints=true +k8s_pool_oauth_scopes= [ + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring" + ] From 27785daac19f6df0692efbd11fc27c3d53c0bd68 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 11:54:12 +0530 Subject: [PATCH 20/82] Update cloudbuild.yaml --- cloudbuild.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 581cb7e4d7..a2e241289d 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -21,7 +21,7 @@ steps: - '-c' - | echo "***********************" - echo "dev" + echo "$BRANCH_NAME" echo "***********************" - id: 'tf init' @@ -30,8 +30,8 @@ steps: args: - '-c' - | - if [ -d "environments/dev/" ]; then - cd environments/dev + if [ -d "environments/$BRANCH_NAME/" ]; then + cd environments/$BRANCH_NAME terraform init else for dir in environments/*/ @@ -55,8 +55,8 @@ steps: args: - '-c' - | - if [ -d "environments/dev/" ]; then - cd environments/dev + if [ -d "environments/$BRANCH_NAME/" ]; then + cd environments/$BRANCH_NAME terraform plan else for dir in environments/*/ @@ -81,12 +81,12 @@ steps: args: - '-c' - | - if [ -d "environments/dev/" ]; then - cd environments/dev + if [ -d "environments/$BRANCH_NAME/" ]; then + cd environments/$BRANCH_NAME terraform apply -auto-approve else echo "***************************** SKIPPING APPLYING *******************************" - echo "Branch 'dev' does not represent an oficial environment." + echo "Branch '$BRANCH_NAME' does not represent an oficial environment." echo "*******************************************************************************" fi # [END tf-apply] From b0dd835c8ab639a9063b9e8aae5f9b1ec52aefa2 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 11:56:37 +0530 Subject: [PATCH 21/82] Update main.tf --- 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 1d2e549134..5e40f7089f 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-server"] + target_tags = ["http-server2"] source_ranges = ["0.0.0.0/0"] } From 38646fea3e99f9b90c49f0edee87d35be6aeb3df Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 12:32:50 +0530 Subject: [PATCH 22/82] Update main.tf --- 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 ba76806d753efd414f78ec42db030fd0fd503b34 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:22:06 +0530 Subject: [PATCH 23/82] Update variables.tf --- environments/dev/variables.tf | 9 --------- 1 file changed, 9 deletions(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 6a1ffbe2f2..fcae41b22c 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -44,15 +44,6 @@ variable "k8s_initial_node_count" { default = 1 } -variable "k8s_username" { - type = string - default = "clusterusername" -} - -variable "k8s_password" { - type = string - default = "clusterspassword" -} variable "k8s_issue_client_certificate" { type = bool From 8d8fd1e429d4dd9fb7d85356a21708413b63b3b8 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:22:36 +0530 Subject: [PATCH 24/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 5 ----- 1 file changed, 5 deletions(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index 0127bb4100..237517c662 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -14,11 +14,6 @@ k8s_remove_default_node_pool=true k8s_initial_node_count=1 -k8s_username="clusterusername" - - -k8s_password="clusterspassword" - k8s_issue_client_certificate=false k8s_pool_name="tf-node-pool" From f1c12cdc0066bf06e552f1471a25503ea21a780f Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:23:11 +0530 Subject: [PATCH 25/82] Update main.tf --- environments/dev/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 81c4d14217..a3b8bfe852 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -30,8 +30,8 @@ module "kubernetes_engine" { k8s_cluster_location = var.k8s_cluster_location k8s_remove_default_node_pool = var.k8s_remove_default_node_pool k8s_initial_node_count = var.k8s_initial_node_count - k8s_username = var.k8s_username - k8s_password = var.k8s_password + #k8s_username = var.k8s_username + #k8s_password = var.k8s_password k8s_issue_client_certificate = var.k8s_issue_client_certificate k8s_pool_name = var.k8s_pool_name k8s_pool_location = var.k8s_pool_location From a4d0729c984cb5ea583d7022ad2cbfba95e7b16b Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:23:49 +0530 Subject: [PATCH 26/82] Update variables.tf --- modules/vpc/variables.tf | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/vpc/variables.tf b/modules/vpc/variables.tf index 9bfdc9560d..f91f697ef6 100644 --- a/modules/vpc/variables.tf +++ b/modules/vpc/variables.tf @@ -31,14 +31,6 @@ variable "k8s_initial_node_count" { type = number } -variable "k8s_username" { - type = string -} - -variable "k8s_password" { - type = string -} - variable "k8s_issue_client_certificate" { type = bool } From 88ce177a8b839d60eda330bef424574977625634 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:25:01 +0530 Subject: [PATCH 27/82] Update main.tf --- modules/vpc/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index cb806c0919..c4ea7a4a87 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -23,8 +23,8 @@ resource "google_container_cluster" "primary" { initial_node_count = var.k8s_initial_node_count master_auth { - username = var.k8s_username - password = var.k8s_password + username = {} + password = {} client_certificate_config { issue_client_certificate = var.k8s_issue_client_certificate From 137384d499e7b57bc44d5870a1fc3e87f06f85cc Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:25:40 +0530 Subject: [PATCH 28/82] Update main.tf --- 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 1d2e549134..5e40f7089f 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-server"] + target_tags = ["http-server2"] source_ranges = ["0.0.0.0/0"] } From 32b2f8f711004fe9f8b132eebe8517109fb0fd17 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:26:42 +0530 Subject: [PATCH 29/82] Update main.tf --- modules/vpc/main.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index c4ea7a4a87..da4de3c0c7 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -23,8 +23,7 @@ resource "google_container_cluster" "primary" { initial_node_count = var.k8s_initial_node_count master_auth { - username = {} - password = {} + client_certificate_config { issue_client_certificate = var.k8s_issue_client_certificate From 455876649b1ea8f91d8d6f7983ddd8f209aa18e0 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:54:15 +0530 Subject: [PATCH 30/82] Delete modules/firewall directory --- modules/firewall/main.tf | 32 -------------------------------- modules/firewall/outputs.tf | 18 ------------------ modules/firewall/variables.tf | 17 ----------------- modules/firewall/versions.tf | 18 ------------------ 4 files changed, 85 deletions(-) delete mode 100644 modules/firewall/main.tf delete mode 100644 modules/firewall/outputs.tf delete mode 100644 modules/firewall/variables.tf delete mode 100644 modules/firewall/versions.tf diff --git a/modules/firewall/main.tf b/modules/firewall/main.tf deleted file mode 100644 index 5e40f7089f..0000000000 --- a/modules/firewall/main.tf +++ /dev/null @@ -1,32 +0,0 @@ -# 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_compute_firewall" "allow-http" { - name = "${local.network}-allow-http" - network = "${local.network}" - project = "${var.project}" - - allow { - protocol = "tcp" - ports = ["80"] - } - - target_tags = ["http-server2"] - source_ranges = ["0.0.0.0/0"] -} diff --git a/modules/firewall/outputs.tf b/modules/firewall/outputs.tf deleted file mode 100644 index 6eee8e9bcf..0000000000 --- a/modules/firewall/outputs.tf +++ /dev/null @@ -1,18 +0,0 @@ -# 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. - - -output "firewall_rule" { - value = "${google_compute_firewall.allow-http.name}" -} diff --git a/modules/firewall/variables.tf b/modules/firewall/variables.tf deleted file mode 100644 index 2301355111..0000000000 --- a/modules/firewall/variables.tf +++ /dev/null @@ -1,17 +0,0 @@ -# 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/firewall/versions.tf b/modules/firewall/versions.tf deleted file mode 100644 index 4cc81b29fa..0000000000 --- a/modules/firewall/versions.tf +++ /dev/null @@ -1,18 +0,0 @@ -# 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 beafb09dc431bce01ecea3096230232a73eaa996 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:58:11 +0530 Subject: [PATCH 31/82] Delete modules/http_server directory --- modules/http_server/main.tf | 44 -------------------------------- modules/http_server/outputs.tf | 22 ---------------- modules/http_server/variables.tf | 17 ------------ modules/http_server/versions.tf | 18 ------------- 4 files changed, 101 deletions(-) delete mode 100644 modules/http_server/main.tf delete mode 100644 modules/http_server/outputs.tf delete mode 100644 modules/http_server/variables.tf delete mode 100644 modules/http_server/versions.tf diff --git a/modules/http_server/main.tf b/modules/http_server/main.tf deleted file mode 100644 index 6f05187f34..0000000000 --- a/modules/http_server/main.tf +++ /dev/null @@ -1,44 +0,0 @@ -# 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_compute_instance" "http_server" { - project = "${var.project}" - zone = "us-west1-a" - name = "${local.network}-apache2-instance" - machine_type = "f1-micro" - - metadata_startup_script = "sudo apt-get update && sudo apt-get install apache2 -y && echo '

Environment: ${local.network}

' | sudo tee /var/www/html/index.html" - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - network_interface { - subnetwork = "${var.subnet}" - - access_config { - # Include this section to give the VM an external ip address - } - } - - # Apply the firewall rule to allow external IPs to access this instance - tags = ["http-server"] -} diff --git a/modules/http_server/outputs.tf b/modules/http_server/outputs.tf deleted file mode 100644 index c503157063..0000000000 --- a/modules/http_server/outputs.tf +++ /dev/null @@ -1,22 +0,0 @@ -# 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. - - -output "instance_name" { - value = "${google_compute_instance.http_server.name}" -} - -output "external_ip" { - value = "${google_compute_instance.http_server.network_interface.0.access_config.0.nat_ip}" -} diff --git a/modules/http_server/variables.tf b/modules/http_server/variables.tf deleted file mode 100644 index 2301355111..0000000000 --- a/modules/http_server/variables.tf +++ /dev/null @@ -1,17 +0,0 @@ -# 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/http_server/versions.tf b/modules/http_server/versions.tf deleted file mode 100644 index 4cc81b29fa..0000000000 --- a/modules/http_server/versions.tf +++ /dev/null @@ -1,18 +0,0 @@ -# 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 2ba7859f203143c92c88e771c12ea52f148d10b0 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 16:21:15 +0530 Subject: [PATCH 32/82] Update main.tf --- modules/vpc/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index da4de3c0c7..2edb84e7c2 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,6 +11,7 @@ # 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 "google_container_cluster" "primary" { From 1f926bac1b26c42f8a019924aa01fdd6a4d5d036 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 16:35:57 +0530 Subject: [PATCH 33/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 2edb84e7c2..cc690255b3 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 47eb45e21356c2482846369121b80fcbd8fcdda0 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:17:40 +0530 Subject: [PATCH 34/82] Update main.tf --- environments/prod/main.tf | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/environments/prod/main.tf b/environments/prod/main.tf index 0c7726235e..a3b8bfe852 100644 --- a/environments/prod/main.tf +++ b/environments/prod/main.tf @@ -14,27 +14,33 @@ locals { - env = "prod" + env = "dev" } provider "google" { project = "${var.project}" } -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 "kubernetes_engine" { + source = "../../modules/vpc" + count = var.kubernetes_engine-create ? var.kubernetes_engine-count : 0 + k8s_cluster_name = var.k8s_cluster_name + k8s_cluster_location = var.k8s_cluster_location + k8s_remove_default_node_pool = var.k8s_remove_default_node_pool + k8s_initial_node_count = var.k8s_initial_node_count + #k8s_username = var.k8s_username + #k8s_password = var.k8s_password + k8s_issue_client_certificate = var.k8s_issue_client_certificate + k8s_pool_name = var.k8s_pool_name + k8s_pool_location = var.k8s_pool_location + k8s_pool_node_count = var.k8s_pool_node_count + k8s_pool_preemptible = var.k8s_pool_preemptible + k8s_pool_machine_type = var.k8s_pool_machine_type + k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints + k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes + project = "${var.project}" + env = "${local.env}" } + From 7ec6f3494fa6e1b2353174d45af2a452c26f957d Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:18:20 +0530 Subject: [PATCH 35/82] Update outputs.tf --- environments/prod/outputs.tf | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/environments/prod/outputs.tf b/environments/prod/outputs.tf index 0ae139e4f7..6f350a511d 100644 --- a/environments/prod/outputs.tf +++ b/environments/prod/outputs.tf @@ -13,22 +13,18 @@ # limitations under the License. -output "network" { - value = "${module.vpc.network}" +output "cluster_id" { + value = module.kubernetes_engine[*].cluster_id } -output "subnet" { - value = "${module.vpc.subnet}" +output "cluster_endpoint" { + value = module.kubernetes_engine[*].cluster_endpoint } -output "firewall_rule" { - value = "${module.firewall.firewall_rule}" +output "pool_id" { + value = module.kubernetes_engine[*].pool_id } -output "instance_name" { - value = "${module.http_server.instance_name}" -} - -output "external_ip" { - value = "${module.http_server.external_ip}" +output "pool_instance_group_urls" { + value = module.kubernetes_engine[*].pool_instance_group_urls } From e99ade27b3a5301e0625d6d8c3d87180cee9dce3 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:19:38 +0530 Subject: [PATCH 36/82] Update terraform.tfvars --- environments/prod/terraform.tfvars | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/environments/prod/terraform.tfvars b/environments/prod/terraform.tfvars index ab2a0e269c..237517c662 100644 --- a/environments/prod/terraform.tfvars +++ b/environments/prod/terraform.tfvars @@ -1 +1,36 @@ -project="yash-innovation" \ No newline at end of file +project="yash-innovation" +kubernetes_engine-create=true + + +kubernetes_engine-count=1 + + +k8s_cluster_name="tf-gke-cluster1" + +k8s_cluster_location="us-central1-a" + + +k8s_remove_default_node_pool=true + +k8s_initial_node_count=1 + +k8s_issue_client_certificate=false + +k8s_pool_name="tf-node-pool" + + +k8s_pool_location="us-central1-a" + + +k8s_pool_node_count=1 + +k8s_pool_preemptible=true + +k8s_pool_machine_type="e2-micro" + + +k8s_pool_disable-legacy-endpoints=true +k8s_pool_oauth_scopes= [ + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring" + ] From 7450e030b77806d841395ed348651ca8913f4008 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:20:53 +0530 Subject: [PATCH 37/82] Update variables.tf --- environments/prod/variables.tf | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/environments/prod/variables.tf b/environments/prod/variables.tf index 2b0a363f94..fcae41b22c 100644 --- a/environments/prod/variables.tf +++ b/environments/prod/variables.tf @@ -14,3 +14,76 @@ variable "project" {} +variable "kubernetes_engine-create" { + type = bool + default = true +} + +variable "kubernetes_engine-count" { + type = number + default = 1 +} + +variable "k8s_cluster_name" { + type = string + default = "tf-gke-cluster1" +} + +variable "k8s_cluster_location" { + type = string + default = "us-central1-a" +} + +variable "k8s_remove_default_node_pool" { + type = bool + default = true +} + +variable "k8s_initial_node_count" { + type = number + default = 1 +} + + +variable "k8s_issue_client_certificate" { + type = bool + default = false +} + +variable "k8s_pool_name" { + type = string + default = "tf-node-pool" +} + +variable "k8s_pool_location" { + type = string + default = "us-central1-a" +} + +variable "k8s_pool_node_count" { + type = number + default = 1 +} + +variable "k8s_pool_preemptible" { + type = bool + default = true +} + +variable "k8s_pool_machine_type" { + type = string + default = "e2-micro" +} + +variable "k8s_pool_disable-legacy-endpoints" { + type = bool + default = true +} + +variable "k8s_pool_oauth_scopes" { + type = list(string) + default = [ + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring", + ] +} From cab6e409d6740c419a9022f8c0953435daadb3c4 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:34:28 +0530 Subject: [PATCH 38/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index cc690255b3..4e618aea87 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From aef8b0d3c715032ce75ae0dcccfe43a955aa08fa Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:18:28 +0530 Subject: [PATCH 39/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 4e618aea87..f487f5a606 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 3aa1efd9beb0e6a8223e8879407d7e15be0fc39f Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 11:36:25 +0530 Subject: [PATCH 40/82] Update main.tf --- environments/dev/main.tf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index a3b8bfe852..4796f80c5f 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -40,6 +40,9 @@ module "kubernetes_engine" { k8s_pool_machine_type = var.k8s_pool_machine_type k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes + cluster_autoscaling = var.cluster_autoscaling + min_cpu_cores= var.min_cpu_cores + max_cpu_core = var.max_cpu_core project = "${var.project}" env = "${local.env}" } From ce9dc118eb08afdfc9f5c7a1988b479b53e74ac6 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 11:50:50 +0530 Subject: [PATCH 41/82] Update main.tf --- modules/vpc/main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index f487f5a606..cb5f5bbd9d 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -37,6 +37,10 @@ resource "google_container_node_pool" "primary_preemptible_nodes" { location = var.k8s_pool_location cluster = google_container_cluster.primary.name node_count = var.k8s_pool_node_count + autoscaling { + min_node_count = var.k8s_min_node_count + max_node_count = var.k8s_max_node_count + } node_config { preemptible = var.k8s_pool_preemptible machine_type = var.k8s_pool_machine_type From 6c13b279fb460c4d4acc18d79b787f089d5e21c8 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 11:53:50 +0530 Subject: [PATCH 42/82] Update variables.tf --- modules/vpc/variables.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/vpc/variables.tf b/modules/vpc/variables.tf index f91f697ef6..571c6ee099 100644 --- a/modules/vpc/variables.tf +++ b/modules/vpc/variables.tf @@ -56,10 +56,18 @@ variable "k8s_pool_machine_type" { type = string } + variable "k8s_pool_disable-legacy-endpoints" { type = bool } +variable "k8s_min_node_count" { + type = number +} +variable "k8s_max_node_count" { + type = number +} + variable "k8s_pool_oauth_scopes" { type = list(string) } From ce75fa43d9f598ca9db28422f7f1b9d24096e784 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 11:55:51 +0530 Subject: [PATCH 43/82] Update main.tf --- environments/dev/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 4796f80c5f..336f987f4b 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -41,8 +41,8 @@ module "kubernetes_engine" { k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes cluster_autoscaling = var.cluster_autoscaling - min_cpu_cores= var.min_cpu_cores - max_cpu_core = var.max_cpu_core + k8s_min_node_count = var.k8s_min_node_count + k8s_max_node_count = var.k8s_max_node_count project = "${var.project}" env = "${local.env}" } From d50b4fb4d76191c914b9110cd64069fdeb52d6b0 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:00:36 +0530 Subject: [PATCH 44/82] Update variables.tf --- environments/dev/variables.tf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index fcae41b22c..602c65edf8 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -62,7 +62,7 @@ variable "k8s_pool_location" { variable "k8s_pool_node_count" { type = number - default = 1 + default = 2 } variable "k8s_pool_preemptible" { @@ -79,6 +79,15 @@ variable "k8s_pool_disable-legacy-endpoints" { type = bool default = true } +variable "k8s_min_node_count" { + type = number + default = 1 +} + +variable "k8s_max_node_count" { + type = number + default = 3 +} variable "k8s_pool_oauth_scopes" { type = list(string) From 6b8c0133d636b00a65c44da777ddd01b41634301 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:02:39 +0530 Subject: [PATCH 45/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index 237517c662..9f6822f11c 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -22,12 +22,14 @@ k8s_pool_name="tf-node-pool" k8s_pool_location="us-central1-a" -k8s_pool_node_count=1 +k8s_pool_node_count=2 k8s_pool_preemptible=true k8s_pool_machine_type="e2-micro" +k8s_min_node_count=1 +k8s_max_node_count=3 k8s_pool_disable-legacy-endpoints=true k8s_pool_oauth_scopes= [ From fd29ca917fef03230ca410433001058cf061ddc4 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:03:30 +0530 Subject: [PATCH 46/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index cb5f5bbd9d..bf3d46e456 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From e24e15b028c6cdf1f689e4e7695b665394e412d1 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:05:27 +0530 Subject: [PATCH 47/82] Update main.tf --- environments/dev/main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 336f987f4b..bec3d95395 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -40,7 +40,6 @@ module "kubernetes_engine" { k8s_pool_machine_type = var.k8s_pool_machine_type k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes - cluster_autoscaling = var.cluster_autoscaling k8s_min_node_count = var.k8s_min_node_count k8s_max_node_count = var.k8s_max_node_count project = "${var.project}" From c1f60b1c55a3c5a9df47e2bd8ac81bd9c6b842e6 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:56:48 +0530 Subject: [PATCH 48/82] Update variables.tf --- environments/dev/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 602c65edf8..13d2288607 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -72,7 +72,7 @@ variable "k8s_pool_preemptible" { variable "k8s_pool_machine_type" { type = string - default = "e2-micro" + default = "e2-medium" } variable "k8s_pool_disable-legacy-endpoints" { From b08a8b04710dc7436773896d2a6088cb176232e4 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:57:28 +0530 Subject: [PATCH 49/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index 9f6822f11c..7178904fed 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -26,7 +26,7 @@ k8s_pool_node_count=2 k8s_pool_preemptible=true -k8s_pool_machine_type="e2-micro" +k8s_pool_machine_type="e2-medium" k8s_min_node_count=1 k8s_max_node_count=3 From 9d7ff7a944f2246a1da28bba17db9ddb0e2d8c53 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 13:05:55 +0530 Subject: [PATCH 50/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index bf3d46e456..bfc9e4dd44 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 2dff1e7ff53409b7cdaa8c14a97a9cf1e2d1aa83 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 13:09:22 +0530 Subject: [PATCH 51/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index bfc9e4dd44..0ba39c00e2 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From a5ab5202d4121fc124a296a9b6d16b0f6783abad Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 14:20:02 +0530 Subject: [PATCH 52/82] Update variables.tf --- environments/dev/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 13d2288607..4834687a6f 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -72,7 +72,7 @@ variable "k8s_pool_preemptible" { variable "k8s_pool_machine_type" { type = string - default = "e2-medium" + default = "e2-small" } variable "k8s_pool_disable-legacy-endpoints" { From c3cbd93052299c6e92b6341cfb1659cc6141784c Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 14:20:32 +0530 Subject: [PATCH 53/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index 7178904fed..1ca5b5bcbe 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -26,7 +26,7 @@ k8s_pool_node_count=2 k8s_pool_preemptible=true -k8s_pool_machine_type="e2-medium" +k8s_pool_machine_type="e2-small" k8s_min_node_count=1 k8s_max_node_count=3 From c7fb8b72e1f0febc210fce06f93389adf10a949a Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 14:44:21 +0530 Subject: [PATCH 54/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 0ba39c00e2..fef877f7c0 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From a320cbb0da89e89ae84a8a123874de0341ced756 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 14:45:11 +0530 Subject: [PATCH 55/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index fef877f7c0..2054dd2f15 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 07318f28f9cfded1c9ec555ec31193b6426387a2 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 14:53:55 +0530 Subject: [PATCH 56/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 2054dd2f15..a7d51aea88 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From a77699b30ce3d03a89bed4970de6bc50c09a4322 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:11:18 +0530 Subject: [PATCH 57/82] Update cloudbuild.yaml --- cloudbuild.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index a2e241289d..6041ee7a6e 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -89,4 +89,5 @@ steps: echo "Branch '$BRANCH_NAME' does not represent an oficial environment." echo "*******************************************************************************" fi + timeout: 900s # [END tf-apply] From 7081946c228fbd9cf5a480b724977d0eeecf05be Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:13:09 +0530 Subject: [PATCH 58/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index a7d51aea88..90bcf28885 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 53b801f6766c33149b93e22303d97a374eeb3487 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:44:18 +0530 Subject: [PATCH 59/82] Update variables.tf --- environments/dev/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 4834687a6f..602c65edf8 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -72,7 +72,7 @@ variable "k8s_pool_preemptible" { variable "k8s_pool_machine_type" { type = string - default = "e2-small" + default = "e2-micro" } variable "k8s_pool_disable-legacy-endpoints" { From 9ef6a6c381a57f7cc44801f9dc4e0c7df6c8cc99 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:45:05 +0530 Subject: [PATCH 60/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index 1ca5b5bcbe..9f6822f11c 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -26,7 +26,7 @@ k8s_pool_node_count=2 k8s_pool_preemptible=true -k8s_pool_machine_type="e2-small" +k8s_pool_machine_type="e2-micro" k8s_min_node_count=1 k8s_max_node_count=3 From c7220042abc7a3a851de7776a4c74756d34847bc Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:45:47 +0530 Subject: [PATCH 61/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 90bcf28885..54541d05eb 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From dcd85f3532f95edb27f7a25c4c087e917e75e021 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:46:54 +0530 Subject: [PATCH 62/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 54541d05eb..1de7499e9a 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From a10c4cbcce4d9665a3704fe6cd180f637c1b6c60 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 20 Sep 2021 08:39:39 +0530 Subject: [PATCH 63/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 1de7499e9a..8bf0d8efbc 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From d20b71c0becdc8516dcec9a3011b66f478b1f417 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 20 Sep 2021 08:44:03 +0530 Subject: [PATCH 64/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 8bf0d8efbc..4808a94dba 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 46ecf921d2d51bdf55b376db99265f7cfb0822bb Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 21 Sep 2021 11:23:53 +0530 Subject: [PATCH 65/82] Update variables.tf --- environments/dev/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/variables.tf b/environments/dev/variables.tf index 602c65edf8..4834687a6f 100644 --- a/environments/dev/variables.tf +++ b/environments/dev/variables.tf @@ -72,7 +72,7 @@ variable "k8s_pool_preemptible" { variable "k8s_pool_machine_type" { type = string - default = "e2-micro" + default = "e2-small" } variable "k8s_pool_disable-legacy-endpoints" { From f8c03d7eb4860cc874774f11f2af27c56d52d38e Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 21 Sep 2021 11:24:21 +0530 Subject: [PATCH 66/82] Update terraform.tfvars --- environments/dev/terraform.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index 9f6822f11c..1ca5b5bcbe 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -26,7 +26,7 @@ k8s_pool_node_count=2 k8s_pool_preemptible=true -k8s_pool_machine_type="e2-micro" +k8s_pool_machine_type="e2-small" k8s_min_node_count=1 k8s_max_node_count=3 From e4e1d2bb727eba4fad0a307d31afb44708b36b57 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Tue, 21 Sep 2021 11:26:35 +0530 Subject: [PATCH 67/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 4808a94dba..55f4b96429 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From c8ef726af4e3dacb4eb29f8809d5ecd5f7898db7 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 14:34:21 +0530 Subject: [PATCH 68/82] Update main.tf --- environments/prod/main.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environments/prod/main.tf b/environments/prod/main.tf index a3b8bfe852..bec3d95395 100644 --- a/environments/prod/main.tf +++ b/environments/prod/main.tf @@ -40,6 +40,8 @@ module "kubernetes_engine" { k8s_pool_machine_type = var.k8s_pool_machine_type k8s_pool_disable-legacy-endpoints = var.k8s_pool_disable-legacy-endpoints k8s_pool_oauth_scopes = var.k8s_pool_oauth_scopes + k8s_min_node_count = var.k8s_min_node_count + k8s_max_node_count = var.k8s_max_node_count project = "${var.project}" env = "${local.env}" } From b6a5e2d301dff2270b442361958c014057e93b25 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 14:35:33 +0530 Subject: [PATCH 69/82] Update terraform.tfvars --- environments/prod/terraform.tfvars | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/environments/prod/terraform.tfvars b/environments/prod/terraform.tfvars index 237517c662..1ca5b5bcbe 100644 --- a/environments/prod/terraform.tfvars +++ b/environments/prod/terraform.tfvars @@ -22,12 +22,14 @@ k8s_pool_name="tf-node-pool" k8s_pool_location="us-central1-a" -k8s_pool_node_count=1 +k8s_pool_node_count=2 k8s_pool_preemptible=true -k8s_pool_machine_type="e2-micro" +k8s_pool_machine_type="e2-small" +k8s_min_node_count=1 +k8s_max_node_count=3 k8s_pool_disable-legacy-endpoints=true k8s_pool_oauth_scopes= [ From 25f56f03a7fe134c3d215315adfc0288c8da9807 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 14:36:26 +0530 Subject: [PATCH 70/82] Update variables.tf --- environments/prod/variables.tf | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/environments/prod/variables.tf b/environments/prod/variables.tf index fcae41b22c..4834687a6f 100644 --- a/environments/prod/variables.tf +++ b/environments/prod/variables.tf @@ -62,7 +62,7 @@ variable "k8s_pool_location" { variable "k8s_pool_node_count" { type = number - default = 1 + default = 2 } variable "k8s_pool_preemptible" { @@ -72,13 +72,22 @@ variable "k8s_pool_preemptible" { variable "k8s_pool_machine_type" { type = string - default = "e2-micro" + default = "e2-small" } variable "k8s_pool_disable-legacy-endpoints" { type = bool default = true } +variable "k8s_min_node_count" { + type = number + default = 1 +} + +variable "k8s_max_node_count" { + type = number + default = 3 +} variable "k8s_pool_oauth_scopes" { type = list(string) From d1a069e8859e70380dc0aeb67733dd79d29e66bb Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 14:57:56 +0530 Subject: [PATCH 71/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 55f4b96429..6da3f600ea 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 45ef31588fd2eef4e02d5b831a924c5e14b85a4e Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 15:24:45 +0530 Subject: [PATCH 72/82] Update cloudbuild.yaml --- cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 6041ee7a6e..a62d51faa0 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -89,5 +89,5 @@ steps: echo "Branch '$BRANCH_NAME' does not represent an oficial environment." echo "*******************************************************************************" fi - timeout: 900s + timeout: 1800s # [END tf-apply] From 4feea153dedf7025901fd704f2b856a1df4b5487 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 15:27:44 +0530 Subject: [PATCH 73/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 6da3f600ea..c006d55cab 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 956131268c14c56d8427e8a8873c26bebe12bac3 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 15:38:14 +0530 Subject: [PATCH 74/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index c006d55cab..55f4b96429 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 76e7cc1f8090aef00394c5b8a591a4264705c256 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:02:47 +0530 Subject: [PATCH 75/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 55f4b96429..724b152cbe 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From fd4b9c3c6641d00134ada79662387eb480d43d3f Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:04:25 +0530 Subject: [PATCH 76/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 724b152cbe..1408999d0a 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 66b4ae3946e2ad36cbdd6d2c1410e79a637961c7 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:08:00 +0530 Subject: [PATCH 77/82] Update main.tf --- modules/vpc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 1408999d0a..2df4be77d7 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -11,7 +11,7 @@ # 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 "google_container_cluster" "primary" { From 1b4038432677f9d7b68f7fd06ce33e9f6f8f9694 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:30:07 +0530 Subject: [PATCH 78/82] Create infracost_test.tf --- infracost_test.tf | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 infracost_test.tf diff --git a/infracost_test.tf b/infracost_test.tf new file mode 100644 index 0000000000..cddc02d074 --- /dev/null +++ b/infracost_test.tf @@ -0,0 +1,45 @@ +provider "google" { + region = "us-central1" + project = "test" +} + +resource "google_compute_instance" "my_instance" { + zone = "us-central1-a" + name = "test" + + machine_type = "n1-standard-16" # <<<<<<<<<< Try changing this to n1-standard-32 to compare the costs + network_interface { + network = "default" + access_config {} + } + + boot_disk { + initialize_params { + image = "debian-cloud/debian-9" + } + } + + scheduling { + preemptible = true + } + + guest_accelerator { + type = "nvidia-tesla-t4" # <<<<<<<<<< Try changing this to nvidia-tesla-p4 to compare the costs + count = 4 + } + + labels = { + environment = "production" + service = "web-app" + } +} + +resource "google_cloudfunctions_function" "my_function" { + runtime = "nodejs20" + name = "test" + available_memory_mb = 512 + + labels = { + environment = "Prod" + } +} From 0bb714fa9fdbfe6a041fab41091cfba660bc5792 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 11 Jun 2025 18:00:18 +0530 Subject: [PATCH 79/82] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d44cdb1cc6..fa87cdad55 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is the repo for the [Managing infrastructure as code with Terraform, Cloud Build, and GitOps](https://cloud.google.com/solutions/managing-infrastructure-as-code) tutorial. This tutorial explains how to manage infrastructure as code with Terraform and Cloud Build using the popular GitOps methodology. -## Configuring your **dev** environment +## Configuring your **dev** environment. Just for demostration, this step will: 1. Configure an apache2 http server on network '**dev**' and subnet '**dev**-subnet-01' From db53cda78bd814536b4d1e7e3afb8af29f3a019c Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Wed, 11 Jun 2025 18:02:35 +0530 Subject: [PATCH 80/82] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa87cdad55..8122435072 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is the repo for the [Managing infrastructure as code with Terraform, Cloud Build, and GitOps](https://cloud.google.com/solutions/managing-infrastructure-as-code) tutorial. This tutorial explains how to manage infrastructure as code with Terraform and Cloud Build using the popular GitOps methodology. -## Configuring your **dev** environment. +## Configuring your **dev** environment.. Just for demostration, this step will: 1. Configure an apache2 http server on network '**dev**' and subnet '**dev**-subnet-01' From fc18ac7fde74715c9c3f0033d38c965313923528 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:00:43 +0530 Subject: [PATCH 81/82] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8122435072..5c2d17fe06 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is the repo for the [Managing infrastructure as code with Terraform, Cloud Build, and GitOps](https://cloud.google.com/solutions/managing-infrastructure-as-code) tutorial. This tutorial explains how to manage infrastructure as code with Terraform and Cloud Build using the popular GitOps methodology. -## Configuring your **dev** environment.. +## Configuring your **dev** environment...... Just for demostration, this step will: 1. Configure an apache2 http server on network '**dev**' and subnet '**dev**-subnet-01' From 44565b7fc695264a866d89fb73c9943b3ada1556 Mon Sep 17 00:00:00 2001 From: monika16p <49428322+monika16p@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:22:57 +0530 Subject: [PATCH 82/82] Update infracost_test.tf updated infracost_test.tf AB#108 --- infracost_test.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infracost_test.tf b/infracost_test.tf index cddc02d074..4666df533c 100644 --- a/infracost_test.tf +++ b/infracost_test.tf @@ -7,7 +7,7 @@ resource "google_compute_instance" "my_instance" { zone = "us-central1-a" name = "test" - machine_type = "n1-standard-16" # <<<<<<<<<< Try changing this to n1-standard-32 to compare the costs + machine_type = "n1-standard-16" # <<<<<<<<<< Try changing this to n1-standard-32 to compare the costs. network_interface { network = "default" access_config {}