This repository has been archived by the owner on Nov 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: convert Terraform configuration from plain files to modules (#1054
) Replace 'loging' with 'login' in tutorial and README instructions and adds "create" command in markdown. (#1047) Fixes errors (#1045) and refactors use of kustomize path in CLI. Makes GKE+ASM provisioning a module. Makes Online Boutique provisioning a module. Creates a new 'main.tf' TF configuration to provision modules sequentially, because of the hard dependency there is no effective way to paralelize it. Refactors "online-boutique" to replace with "microservices-demo".
- Loading branch information
Showing
23 changed files
with
234 additions
and
105 deletions.
There are no files selected for viewing
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
# Required input variables | ||
variable "gcp_project_id" { | ||
type = string | ||
description = "The GCP project ID to apply this config to" | ||
} | ||
|
||
variable "gke_cluster_name" { | ||
type = string | ||
description = "Name given to the new GKE cluster" | ||
} | ||
|
||
variable "gke_cluster_location" { | ||
type = string | ||
description = "Region or zone of the new GKE cluster" | ||
} | ||
|
||
# Optional input variables | ||
variable "asm_channel" { | ||
type = string | ||
description = "Defines one of the following managed ASM channels/revisions: 'rapid', 'regular' or stable'" | ||
default = "stable" | ||
validation { | ||
condition = can(regex("^(rapid|regular|stable)$", var.asm_channel)) | ||
error_message = "ASM channel/revision can be only 'rapid', 'regular' or stable'" | ||
} | ||
} | ||
|
||
variable "enable_asm" { | ||
type = bool | ||
description = "If true, installs Anthos Service Mesh (managed version of Istio) on the GKE cluster" | ||
default = false | ||
} | ||
|
||
# Default values for node pool support connecting the cluster to ASM | ||
# https://cloud.google.com/service-mesh/docs/unified-install/anthos-service-mesh-prerequisites#cluster_requirements | ||
variable "gke_node_pool" { | ||
type = object({ | ||
initial_node_count = number | ||
labels = map(string) | ||
machine_type = string | ||
|
||
autoscaling = object({ | ||
max_node_count = number | ||
min_node_count = number | ||
}) | ||
}) | ||
description = "Initial settings and autoscale configuration of the GKE cluster's default node pool" | ||
default = { | ||
initial_node_count = 4 | ||
labels = {} | ||
machine_type = "e2-standard-4" | ||
autoscaling = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2023 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. | ||
|
||
|
||
# ------------------------------------------ | ||
# Infra | ||
module "k8s_cluster" { | ||
source = "./k8s_cluster" | ||
asm_channel = var.asm_channel | ||
enable_asm = var.enable_asm | ||
gcp_project_id = module.enable_google_apis.project_id | ||
gke_cluster_location = var.gke_cluster_location | ||
gke_cluster_name = var.gke_cluster_name | ||
gke_node_pool = var.gke_node_pool | ||
} | ||
|
||
# ------------------------------------------ | ||
# Demo application | ||
module "online_boutique" { | ||
source = "./microservice_demo" | ||
depends_on = [module.k8s_cluster] | ||
enable_asm = var.enable_asm | ||
filepath_manifest = var.filepath_manifest | ||
gcp_project_id = module.enable_google_apis.project_id | ||
} | ||
|
||
# ------------------------------------------ | ||
# Cloud Ops configuration | ||
module "cloud_ops" { | ||
source = "./cloud-ops" | ||
depends_on = [module.online_boutique] | ||
enable_asm = var.enable_asm | ||
frontend_external_ip = module.online_boutique.frontend_ip_address | ||
gcp_project_id = var.gcp_project_id | ||
gke_cluster_name = var.gke_cluster_name | ||
# re-use prefix to customize resources within the same project | ||
name_suffix = length(var.state_prefix) > 0 ? "-${var.state_prefix}" : "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 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 "frontend_ip_address" { | ||
value = data.kubernetes_service.frontend_external_service.status[0].load_balancer[0].ingress[0].ip | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
# Required input variables | ||
variable "gcp_project_id" { | ||
type = string | ||
description = "The GCP project ID to apply this config to" | ||
} | ||
|
||
variable "enable_asm" { | ||
type = bool | ||
description = "If true, installs Anthos Service Mesh (managed version of Istio) on the GKE cluster" | ||
} | ||
|
||
# Optional input variables | ||
variable "filepath_manifest" { | ||
type = string | ||
description = "Path to Kubernetes resources, written using Kustomize" | ||
default = "../kustomize/microservices-demo/" | ||
} |
Oops, something went wrong.