mirror of
https://github.com/ghndrx/GSP662.git
synced 2026-02-10 15:04:57 +00:00
set to use default service-account
This commit is contained in:
@@ -1,117 +0,0 @@
|
|||||||
resource "google_compute_target_pool" "fancy_target_pool_fe" {
|
|
||||||
name = "fancy-target-pool"
|
|
||||||
|
|
||||||
instances = [
|
|
||||||
google_compute_instance.fancy_fe_instance1.self_link,
|
|
||||||
google_compute_instance.fancy_fe_instance2.self_link,
|
|
||||||
]
|
|
||||||
|
|
||||||
health_checks = [
|
|
||||||
google_compute_http_health_check.fancy_fe_hc.self_link,
|
|
||||||
]
|
|
||||||
|
|
||||||
session_affinity = "CLIENT_IP"
|
|
||||||
}
|
|
||||||
resource "google_compute_target_pool" "fancy_target_pool_be" {
|
|
||||||
name = "fancy-target-pool"
|
|
||||||
|
|
||||||
instances = [
|
|
||||||
google_compute_instance.fancy_be_instance1.self_link,
|
|
||||||
google_compute_instance.fancy_be_instance2.self_link,
|
|
||||||
]
|
|
||||||
|
|
||||||
health_checks = [
|
|
||||||
google_compute_http_health_check.fancy_be_hc.self_link,
|
|
||||||
]
|
|
||||||
|
|
||||||
session_affinity = "CLIENT_IP"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
resource "google_compute_instance_group_manager" "fancy_fe_mig" {
|
|
||||||
name = "fancy-fe-mig"
|
|
||||||
base_instance_name = "fancy-fe"
|
|
||||||
instance_template = google_compute_instance_template.fancy_fe_template.self_link
|
|
||||||
target_size = 2
|
|
||||||
|
|
||||||
target_pools = [
|
|
||||||
google_compute_target_pool.fancy_target_pool_fe.self_link
|
|
||||||
]
|
|
||||||
|
|
||||||
zone = "us-central1-f"
|
|
||||||
|
|
||||||
update_policy {
|
|
||||||
type = "PROACTIVE"
|
|
||||||
min_instance_restart_time_sec = 300
|
|
||||||
}
|
|
||||||
|
|
||||||
named_port {
|
|
||||||
name = "frontend"
|
|
||||||
port = "8080"
|
|
||||||
}
|
|
||||||
|
|
||||||
depends_on = [
|
|
||||||
google_compute_http_health_check.fancy_fe_hc,
|
|
||||||
google_compute_backend_service.fancy_backend_service,
|
|
||||||
google_compute_target_pool.fancy_target_pool_fe,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_compute_instance_group_manager" "fancy_be_mig" {
|
|
||||||
name = "fancy-be-mig"
|
|
||||||
base_instance_name = "fancy-be"
|
|
||||||
instance_template = google_compute_instance_template.fancy_be_template.self_link
|
|
||||||
target_size = 2
|
|
||||||
|
|
||||||
target_pools = [
|
|
||||||
google_compute_target_pool.fancy_target_pool_be.self_link
|
|
||||||
]
|
|
||||||
|
|
||||||
zone = "us-central1-f"
|
|
||||||
|
|
||||||
update_policy {
|
|
||||||
type = "PROACTIVE"
|
|
||||||
min_instance_restart_time_sec = 300
|
|
||||||
}
|
|
||||||
|
|
||||||
named_port {
|
|
||||||
name = "orders"
|
|
||||||
port = "8081"
|
|
||||||
}
|
|
||||||
|
|
||||||
named_port {
|
|
||||||
name = "products"
|
|
||||||
port = "8082"
|
|
||||||
}
|
|
||||||
|
|
||||||
depends_on = [
|
|
||||||
google_compute_http_health_check.fancy_be_hc,
|
|
||||||
google_compute_backend_service.fancy_backend_service,
|
|
||||||
google_compute_target_pool.fancy_target_pool_be,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resource "google_compute_region_autoscaler" "fancy_fe_autoscaler" {
|
|
||||||
name = "fancy-fe-autoscaler"
|
|
||||||
target = google_compute_instance_group_manager.fancy_fe_mig.self_link
|
|
||||||
cooldown_period_sec = 60
|
|
||||||
load_balancing_utilization_target = 0.6
|
|
||||||
max_replicas = 2
|
|
||||||
|
|
||||||
depends_on = [
|
|
||||||
module.google_compute_instance_group_manager.fancy_fe_mig
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_compute_region_autoscaler" "fancy_be_autoscaler" {
|
|
||||||
name = "fancy-be-autoscaler"
|
|
||||||
target = google_compute_instance_group_manager.fancy_be_mig.self_link
|
|
||||||
cooldown_period_sec = 60
|
|
||||||
load_balancing_utilization_target = 0.6
|
|
||||||
max_replicas = 2
|
|
||||||
depends_on = [
|
|
||||||
google_compute_instance_group_manager.fancy_be_mig
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,11 @@ resource "google_compute_instance" "backend" {
|
|||||||
image = "debian-cloud/debian-10"
|
image = "debian-cloud/debian-10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
service_account {
|
||||||
|
// Use the default service account
|
||||||
|
email = "default"
|
||||||
|
scopes = ["cloud-platform"]
|
||||||
|
}
|
||||||
network_interface {
|
network_interface {
|
||||||
network = "default"
|
network = "default"
|
||||||
access_config {
|
access_config {
|
||||||
@@ -39,7 +43,11 @@ resource "google_compute_instance" "frontend" {
|
|||||||
image = "debian-cloud/debian-10"
|
image = "debian-cloud/debian-10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
service_account {
|
||||||
|
// Use the default service account
|
||||||
|
email = "default"
|
||||||
|
scopes = ["cloud-platform"]
|
||||||
|
}
|
||||||
network_interface {
|
network_interface {
|
||||||
network = "default"
|
network = "default"
|
||||||
access_config {
|
access_config {
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
# Change machine type of frontend instance
|
|
||||||
resource "google_compute_instance" "frontend" {
|
|
||||||
name = "frontend"
|
|
||||||
zone = "us-central1-f"
|
|
||||||
machine_type = "custom-4-3840"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a new instance template for the frontend instances
|
|
||||||
resource "google_compute_instance_template" "fancy_fe_new" {
|
|
||||||
name = "fancy-fe-new"
|
|
||||||
source_instance = google_compute_instance.frontend.self_link
|
|
||||||
source_instance_zone = google_compute_instance.frontend.zone
|
|
||||||
|
|
||||||
disk {
|
|
||||||
source = google_compute_instance.frontend.boot_disk[0].source
|
|
||||||
auto_delete = true
|
|
||||||
}
|
|
||||||
|
|
||||||
network_interface {
|
|
||||||
network = "default"
|
|
||||||
access_config {
|
|
||||||
nat_ip = google_compute_address.fancy_lb_ip.address
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update the instance group with the new instance template
|
|
||||||
resource "google_compute_region_instance_group_manager_rolling_update" "fancy_fe_mig_update" {
|
|
||||||
name = "fancy-fe-mig-update"
|
|
||||||
region = "us-central1"
|
|
||||||
|
|
||||||
managed_instance_group = google_compute_instance_group_manager.fancy_fe_mig.self_link
|
|
||||||
|
|
||||||
version {
|
|
||||||
name = "fancy-fe-new"
|
|
||||||
instance_template = google_compute_instance_template.fancy_fe_new.self_link
|
|
||||||
}
|
|
||||||
|
|
||||||
# Optional flags
|
|
||||||
max_surge = 1
|
|
||||||
max_unavailable = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# ENABLE CDN
|
|
||||||
resource "google_compute_backend_service" "fancy_fe_frontend" {
|
|
||||||
name = "fancy-fe-frontend"
|
|
||||||
port_name = "frontend"
|
|
||||||
protocol = "HTTP"
|
|
||||||
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
|
|
||||||
|
|
||||||
backend {
|
|
||||||
group = google_compute_instance_group_manager.fancy_fe_mig.self_link
|
|
||||||
}
|
|
||||||
|
|
||||||
health_checks = [
|
|
||||||
google_compute_http_health_check.fancy_fe_frontend_hc.self_link
|
|
||||||
]
|
|
||||||
|
|
||||||
enable_cdn = true
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user