Pan*_*ale 4 google-cloud-platform terraform
Terraform是否支持Google内部负载平衡器? https://cloud.google.com/compute/docs/load-balancing/internal/
截至2017年9月,确实可以!不幸的是,它的文档不是那么好。
这是一个非常粗糙的示例,可能不仅仅可以通过复制/粘贴来工作!
resource "google_compute_instance_group" "elasticsearch-cluster" {
name = "elasticsearch-cluster"
description = "Terraform test instance group"
instances = [
"${google_compute_instance.elasticsearch-compute-instance.*.self_link}"
]
named_port {
name = "elasticsearch-api"
port = "9200"
}
named_port {
name = "elasticsearch-transport"
port = "9300"
}
zone = "us-central1-a"
}
resource "google_compute_forwarding_rule" "elasticsearch-forwarding-rule" {
name = "elasticsearch-lb"
load_balancing_scheme = "INTERNAL"
backend_service = "${google_compute_region_backend_service.elasticsearch-lb.self_link}"
ports = [ "9200", "9300" ]
}
resource "google_compute_region_backend_service" "elasticsearch-lb" {
name = "elasticsearch-lb"
protocol = "TCP"
timeout_sec = 10
session_affinity = "NONE"
backend {
group = "${google_compute_instance_group.elasticsearch-cluster.self_link}"
}
health_checks = ["${google_compute_health_check.elasticsearch-healthcheck.self_link}"]
}
resource "google_compute_health_check" "elasticsearch-healthcheck" {
name = "elasticsearch-healthcheck"
check_interval_sec = 5
timeout_sec = 5
tcp_health_check {
port = "9200"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2387 次 |
| 最近记录: |