-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for INTERNAL_SELF_MANAGED backend service #1833
Merged
modular-magician
merged 6 commits into
GoogleCloudPlatform:master
from
slevenick:internal-self-managed-backend
May 31, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba53b02
Add support for INTERNAL_SELF_MANAGED backend service and global forw…
slevenick 92e26ad
Add test for global INTERNAL_SELF_MANAGED backend service. Documentat…
slevenick 5fc7008
Add manual testing
slevenick 5cd75dd
Add min_version to network for glb
slevenick b3d39dd
Remove unnecessary test step
slevenick 8914332
Add comment to test
slevenick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
100 changes: 100 additions & 0 deletions
100
templates/terraform/examples/global_forwarding_rule_internal.tf.erb
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,100 @@ | ||
resource "google_compute_global_forwarding_rule" "default" { | ||
provider = "google-beta" | ||
name = "<%= ctx[:vars]['forwarding_rule_name'] %>" | ||
target = "${google_compute_target_http_proxy.default.self_link}" | ||
port_range = "80" | ||
load_balancing_scheme = "INTERNAL_SELF_MANAGED" | ||
ip_address = "0.0.0.0" | ||
} | ||
|
||
resource "google_compute_target_http_proxy" "default" { | ||
provider = "google-beta" | ||
name = "<%= ctx[:vars]['http_proxy_name'] %>" | ||
description = "a description" | ||
url_map = "${google_compute_url_map.default.self_link}" | ||
} | ||
|
||
resource "google_compute_url_map" "default" { | ||
provider = "google-beta" | ||
name = "url-map-<%= ctx[:vars]['http_proxy_name'] %>" | ||
description = "a description" | ||
default_service = "${google_compute_backend_service.default.self_link}" | ||
|
||
host_rule { | ||
hosts = ["mysite.com"] | ||
path_matcher = "allpaths" | ||
} | ||
|
||
path_matcher { | ||
name = "allpaths" | ||
default_service = "${google_compute_backend_service.default.self_link}" | ||
|
||
path_rule { | ||
paths = ["/*"] | ||
service = "${google_compute_backend_service.default.self_link}" | ||
} | ||
} | ||
} | ||
|
||
resource "google_compute_backend_service" "default" { | ||
provider = "google-beta" | ||
name = "<%= ctx[:vars]['backend_service_name'] %>" | ||
port_name = "http" | ||
protocol = "HTTP" | ||
timeout_sec = 10 | ||
load_balancing_scheme = "INTERNAL_SELF_MANAGED" | ||
|
||
backend { | ||
group = "${google_compute_instance_group_manager.foobar.instance_group}" | ||
balancing_mode = "RATE" | ||
capacity_scaler = 0.4 | ||
max_rate_per_instance = 50 | ||
} | ||
|
||
health_checks = ["${google_compute_health_check.default.self_link}"] | ||
} | ||
|
||
data "google_compute_image" "debian_image" { | ||
provider = "google-beta" | ||
family = "debian-9" | ||
project = "debian-cloud" | ||
} | ||
|
||
resource "google_compute_instance_group_manager" "foobar" { | ||
provider = "google-beta" | ||
name = "igm-internal" | ||
version { | ||
instance_template = "${google_compute_instance_template.foobar.self_link}" | ||
name = "primary" | ||
} | ||
base_instance_name = "foobar" | ||
zone = "us-central1-f" | ||
target_size = 1 | ||
} | ||
|
||
resource "google_compute_instance_template" "foobar" { | ||
provider = "google-beta" | ||
name = "instance-template-internal" | ||
machine_type = "n1-standard-1" | ||
|
||
network_interface { | ||
network = "default" | ||
} | ||
|
||
disk { | ||
source_image = "${data.google_compute_image.debian_image.self_link}" | ||
auto_delete = true | ||
boot = true | ||
} | ||
} | ||
|
||
resource "google_compute_health_check" "default" { | ||
provider = "google-beta" | ||
name = "check-<%= ctx[:vars]['backend_service_name'] %>" | ||
check_interval_sec = 1 | ||
timeout_sec = 1 | ||
|
||
tcp_health_check { | ||
port = "80" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -637,6 +637,34 @@ func TestAccComputeBackendService_withCustomHeaders(t *testing.T) { | |
} | ||
<% end -%> | ||
|
||
<% unless version == 'ga' -%> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hand-written test is only necessary in order to do the import part, right? If so, can you add a comment to remove it once the feature goes GA (since then we'd get import for the example test)? |
||
func TestAccComputeBackendService_internalLoadBalancing(t *testing.T) { | ||
t.Parallel() | ||
|
||
fr := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10)) | ||
proxy := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10)) | ||
backend := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10)) | ||
hc := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10)) | ||
urlmap := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10)) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckComputeBackendServiceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeBackendService_internalLoadBalancing(fr, proxy, backend, hc, urlmap), | ||
}, | ||
{ | ||
ResourceName: "google_compute_backend_service.backend_service", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
<% end -%> | ||
|
||
func testAccComputeBackendService_basic(serviceName, checkName string) string { | ||
return fmt.Sprintf(` | ||
resource "google_compute_backend_service" "foobar" { | ||
|
@@ -1078,3 +1106,102 @@ resource "google_compute_http_health_check" "zero" { | |
`, serviceName, checkName) | ||
} | ||
<% end -%> | ||
|
||
<% unless version == 'ga' -%> | ||
<%# This test is for import functionality. It can be removed and added to examples when this goes GA %> | ||
func testAccComputeBackendService_internalLoadBalancing(fr, proxy, backend, hc, urlmap string) string { | ||
return fmt.Sprintf(` | ||
resource "google_compute_global_forwarding_rule" "forwarding_rule" { | ||
name = "%s" | ||
target = "${google_compute_target_http_proxy.default.self_link}" | ||
port_range = "80" | ||
load_balancing_scheme = "INTERNAL_SELF_MANAGED" | ||
ip_address = "0.0.0.0" | ||
} | ||
|
||
resource "google_compute_target_http_proxy" "default" { | ||
name = "%s" | ||
description = "a description" | ||
url_map = "${google_compute_url_map.default.self_link}" | ||
} | ||
|
||
resource "google_compute_backend_service" "backend_service" { | ||
name = "%s" | ||
port_name = "http" | ||
protocol = "HTTP" | ||
timeout_sec = 10 | ||
load_balancing_scheme = "INTERNAL_SELF_MANAGED" | ||
|
||
backend { | ||
group = "${google_compute_instance_group_manager.foobar.instance_group}" | ||
balancing_mode = "RATE" | ||
capacity_scaler = 0.4 | ||
max_rate_per_instance = 50 | ||
} | ||
|
||
health_checks = ["${google_compute_health_check.default.self_link}"] | ||
} | ||
|
||
resource "google_compute_health_check" "default" { | ||
name = "%s" | ||
check_interval_sec = 1 | ||
timeout_sec = 1 | ||
|
||
tcp_health_check { | ||
port = "80" | ||
} | ||
} | ||
|
||
resource "google_compute_url_map" "default" { | ||
name = "%s" | ||
description = "a description" | ||
default_service = "${google_compute_backend_service.backend_service.self_link}" | ||
|
||
host_rule { | ||
hosts = ["mysite.com"] | ||
path_matcher = "allpaths" | ||
} | ||
|
||
path_matcher { | ||
name = "allpaths" | ||
default_service = "${google_compute_backend_service.backend_service.self_link}" | ||
|
||
path_rule { | ||
paths = ["/*"] | ||
service = "${google_compute_backend_service.backend_service.self_link}" | ||
} | ||
} | ||
} | ||
|
||
data "google_compute_image" "debian_image" { | ||
family = "debian-9" | ||
project = "debian-cloud" | ||
} | ||
|
||
resource "google_compute_instance_group_manager" "foobar" { | ||
name = "igm-internal" | ||
version { | ||
instance_template = "${google_compute_instance_template.foobar.self_link}" | ||
name = "primary" | ||
} | ||
base_instance_name = "foobar" | ||
zone = "us-central1-f" | ||
target_size = 1 | ||
} | ||
|
||
resource "google_compute_instance_template" "foobar" { | ||
name = "instance-template-internal" | ||
machine_type = "n1-standard-1" | ||
|
||
network_interface { | ||
network = "default" | ||
} | ||
|
||
disk { | ||
source_image = "${data.google_compute_image.debian_image.self_link}" | ||
auto_delete = true | ||
boot = true | ||
} | ||
}`, fr, proxy, backend, hc, urlmap) | ||
} | ||
<% end -%> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above