Skip to content

Commit

Permalink
Add metadataFilters to GlobalForwardingRule
Browse files Browse the repository at this point in the history
  • Loading branch information
Ty Larrabee committed Sep 18, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 48b0aeb commit cad1aed
Showing 3 changed files with 204 additions and 2 deletions.
62 changes: 62 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
@@ -2468,6 +2468,66 @@ objects:
values:
- :INTERNAL_SELF_MANAGED
- :EXTERNAL
- !ruby/object:Api::Type::Array
name: 'metadataFilters'
description: |
Opaque filter criteria used by Loadbalancer to restrict routing
configuration to a limited set xDS compliant clients. In their xDS
requests to Loadbalancer, xDS clients present node metadata. If a
match takes place, the relevant routing configuration is made available
to those proxies.
For each metadataFilter in this list, if its filterMatchCriteria is set
to MATCH_ANY, at least one of the filterLabels must match the
corresponding label provided in the metadata. If its filterMatchCriteria
is set to MATCH_ALL, then all of its filterLabels must match with
corresponding labels in the provided metadata.
metadataFilters specified here can be overridden by those specified in
the UrlMap that this ForwardingRule references.
metadataFilters only applies to Loadbalancers that have their
loadBalancingScheme set to INTERNAL_SELF_MANAGED.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::Enum
name: 'filterMatchCriteria'
description: |
Specifies how individual filterLabel matches within the list of
filterLabels contribute towards the overall metadataFilter match.
MATCH_ANY - At least one of the filterLabels must have a matching
label in the provided metadata.
MATCH_ALL - All filterLabels must have matching labels in the
provided metadata.
required: true
values:
- :MATCH_ANY
- :MATCH_ALL
- !ruby/object:Api::Type::Array
name: 'filterLabels'
description: |
The list of label value pairs that must match labels in the
provided metadata based on filterMatchCriteria
This list must not be empty and can have at the most 64 entries.
min_size: 1
max_size: 64
required: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
Name of the metadata label. The length must be between
1 and 1024 characters, inclusive.
required: true
- !ruby/object:Api::Type::String
name: 'value'
description: |
The value that the label must match. The value has a maximum
length of 1024 characters.
required: true
- !ruby/object:Api::Type::String
name: 'name'
description: |
@@ -2524,6 +2584,8 @@ objects:
description: |
The URL of the target resource to receive the matched traffic.
The forwarded traffic must be of a type appropriate to the target object.
For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets
are valid.
update_verb: :POST
update_url: 'projects/{{project}}/global/forwardingRules/{{name}}/setTarget'
- !ruby/object:Api::Resource
Original file line number Diff line number Diff line change
@@ -5,6 +5,13 @@ resource "google_compute_global_forwarding_rule" "default" {
port_range = "80"
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
ip_address = "0.0.0.0"
metadata_filters {
filter_match_criteria = "MATCH_ANY"
filter_labels {
name = "PLANET"
value = "MARS"
}
}
}

resource "google_compute_target_http_proxy" "default" {
@@ -97,4 +104,4 @@ resource "google_compute_health_check" "default" {
tcp_health_check {
port = "80"
}
}
}
Original file line number Diff line number Diff line change
@@ -144,6 +144,14 @@ func TestAccComputeGlobalForwardingRule_internalLoadBalancing(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeGlobalForwardingRule_internalLoadBalancingUpdate(fr, proxy, backend, hc, urlmap, igm, it),
},
{
ResourceName: "google_compute_global_forwarding_rule.forwarding_rule",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@@ -379,6 +387,13 @@ resource "google_compute_global_forwarding_rule" "forwarding_rule" {
port_range = "80"
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
ip_address = "0.0.0.0"
metadata_filters {
filter_match_criteria = "MATCH_ANY"
filter_labels {
name = "PLANET"
value = "NEPTUNE"
}
}
}

resource "google_compute_target_http_proxy" "default" {
@@ -466,4 +481,122 @@ resource "google_compute_instance_template" "instance_template" {
}
}`, fr, proxy, backend, hc, urlmap, igm, it)
}
<% end -%>

func testAccComputeGlobalForwardingRule_internalLoadBalancingUpdate(fr, proxy, backend, hc, urlmap, igm, it 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"
metadata_filters {
filter_match_criteria = "MATCH_ANY"
filter_labels {
name = "PLANET"
value = "NEPTUNE"
}
filter_labels {
name = "PLANET"
value = "JUPITER"
}
}
metadata_filters {
filter_match_criteria = "MATCH_ALL"
filter_labels {
name = "STAR"
value = "PROXIMA CENTAURI"
}
filter_labels {
name = "SPECIES"
value = "ALIEN"
}
}
}

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" "default" {
name = "%s"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "INTERNAL_SELF_MANAGED"

backend {
group = "${google_compute_instance_group_manager.igm.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.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}"
}
}
}

data "google_compute_image" "debian_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_instance_group_manager" "igm" {
name = "%s"
version {
instance_template = "${google_compute_instance_template.instance_template.self_link}"
name = "primary"
}
base_instance_name = "internal-igm"
zone = "us-central1-f"
target_size = 1
}

resource "google_compute_instance_template" "instance_template" {
name = "%s"
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, igm, it)
}
<% end -%>

0 comments on commit cad1aed

Please sign in to comment.