From a9d507b4616bef1f6b561eb92bad86a7c439449d Mon Sep 17 00:00:00 2001 From: Laiq Ahmed Date: Thu, 26 Sep 2024 17:01:42 -0400 Subject: [PATCH 1/2] Add fields to support stateful cookie-based affinity --- mmv1/products/compute/BackendService.yaml | 50 +++++++++++++++++++ .../compute/RegionBackendService.yaml | 50 +++++++++++++++++++ ..._service_stateful_session_affinity.tf.tmpl | 26 ++++++++++ ...vice_ilb_stateful_session_affinity.tf.tmpl | 27 ++++++++++ 4 files changed, 153 insertions(+) create mode 100644 mmv1/templates/terraform/examples/backend_service_stateful_session_affinity.tf.tmpl create mode 100644 mmv1/templates/terraform/examples/region_backend_service_ilb_stateful_session_affinity.tf.tmpl diff --git a/mmv1/products/compute/BackendService.yaml b/mmv1/products/compute/BackendService.yaml index 0b1597f1ffac..c4363d34d91f 100644 --- a/mmv1/products/compute/BackendService.yaml +++ b/mmv1/products/compute/BackendService.yaml @@ -106,6 +106,12 @@ examples: vars: backend_service_name: 'backend-service' health_check_name: 'health-check' + - name: 'backend_service_stateful_session_affinity' + primary_resource_id: 'default' + min_version: 'beta' + vars: + backend_service_name: 'backend-service' + health_check_name: 'health-check' - name: 'backend_service_network_endpoint' primary_resource_id: 'default' min_version: 'beta' @@ -1295,6 +1301,50 @@ properties: - 'GENERATED_COOKIE' - 'HEADER_FIELD' - 'HTTP_COOKIE' + - 'STRONG_COOKIE_AFFINITY' + - name: 'strongSessionAffinityCookie' + type: NestedObject + description: | + Describes the HTTP cookie used for stateful session affinity. This field is applicable and required if the sessionAffinity is set to STRONG_COOKIE_AFFINITY. + properties: + - name: 'ttl' + type: NestedObject + description: | + Lifetime of the cookie. + at_least_one_of: + - 'http_cookie.0.ttl' + - 'http_cookie.0.name' + - 'http_cookie.0.path' + properties: + - name: 'seconds' + type: Integer + description: | + Span of time at a resolution of a second. + Must be from 0 to 315,576,000,000 inclusive. + required: true + - name: 'nanos' + type: Integer + description: | + Span of time that's a fraction of a second at nanosecond + resolution. Durations less than one second are represented + with a 0 seconds field and a positive nanos field. Must + be from 0 to 999,999,999 inclusive. + - name: 'name' + type: String + description: | + Name of the cookie. + at_least_one_of: + - 'http_cookie.0.ttl' + - 'http_cookie.0.name' + - 'http_cookie.0.path' + - name: 'path' + type: String + description: | + Path to set for the cookie. + at_least_one_of: + - 'http_cookie.0.ttl' + - 'http_cookie.0.name' + - 'http_cookie.0.path' - name: 'timeoutSec' type: Integer description: | diff --git a/mmv1/products/compute/RegionBackendService.yaml b/mmv1/products/compute/RegionBackendService.yaml index 17ce2a0c80ba..eef9e1adf91f 100644 --- a/mmv1/products/compute/RegionBackendService.yaml +++ b/mmv1/products/compute/RegionBackendService.yaml @@ -96,6 +96,12 @@ examples: vars: region_backend_service_name: 'region-service' health_check_name: 'rbs-health-check' + - name: 'region_backend_service_ilb_stateful_session_affinity' + primary_resource_id: 'default' + min_version: 'beta' + vars: + region_backend_service_name: 'region-service' + health_check_name: 'rbs-health-check' - name: 'region_backend_service_balancing_mode' primary_resource_id: 'default' vars: @@ -1151,6 +1157,50 @@ properties: - 'HEADER_FIELD' - 'HTTP_COOKIE' - 'CLIENT_IP_NO_DESTINATION' + - 'STRONG_COOKIE_AFFINITY' + - name: 'strongSessionAffinityCookie' + type: NestedObject + description: | + Describes the HTTP cookie used for stateful session affinity. This field is applicable and required if the sessionAffinity is set to STRONG_COOKIE_AFFINITY. + properties: + - name: 'ttl' + type: NestedObject + description: | + Lifetime of the cookie. + at_least_one_of: + - 'http_cookie.0.ttl' + - 'http_cookie.0.name' + - 'http_cookie.0.path' + properties: + - name: 'seconds' + type: Integer + description: | + Span of time at a resolution of a second. + Must be from 0 to 315,576,000,000 inclusive. + required: true + - name: 'nanos' + type: Integer + description: | + Span of time that's a fraction of a second at nanosecond + resolution. Durations less than one second are represented + with a 0 seconds field and a positive nanos field. Must + be from 0 to 999,999,999 inclusive. + - name: 'name' + type: String + description: | + Name of the cookie. + at_least_one_of: + - 'http_cookie.0.ttl' + - 'http_cookie.0.name' + - 'http_cookie.0.path' + - name: 'path' + type: String + description: | + Path to set for the cookie. + at_least_one_of: + - 'http_cookie.0.ttl' + - 'http_cookie.0.name' + - 'http_cookie.0.path' - name: 'connectionTrackingPolicy' type: NestedObject description: | diff --git a/mmv1/templates/terraform/examples/backend_service_stateful_session_affinity.tf.tmpl b/mmv1/templates/terraform/examples/backend_service_stateful_session_affinity.tf.tmpl new file mode 100644 index 000000000000..18d4856148d5 --- /dev/null +++ b/mmv1/templates/terraform/examples/backend_service_stateful_session_affinity.tf.tmpl @@ -0,0 +1,26 @@ +resource "google_compute_backend_service" "{{$.PrimaryResourceId}}" { + provider = google-beta + + name = "{{index $.Vars "backend_service_name"}}" + health_checks = [google_compute_health_check.health_check.id] + load_balancing_scheme = "EXTERNAL_MANAGED" + locality_lb_policy = "RING_HASH" + session_affinity = "STRONG_COOKIE_AFFINITY" + + strong_session_affinity_cookie { + ttl { + seconds = 11 + nanos = 1111 + } + name = "mycookie" + } +} + +resource "google_compute_health_check" "health_check" { + provider = google-beta + + name = "{{index $.Vars "health_check_name"}}" + http_health_check { + port = 80 + } +} diff --git a/mmv1/templates/terraform/examples/region_backend_service_ilb_stateful_session_affinity.tf.tmpl b/mmv1/templates/terraform/examples/region_backend_service_ilb_stateful_session_affinity.tf.tmpl new file mode 100644 index 000000000000..a3c93ddf65f5 --- /dev/null +++ b/mmv1/templates/terraform/examples/region_backend_service_ilb_stateful_session_affinity.tf.tmpl @@ -0,0 +1,27 @@ +resource "google_compute_region_backend_service" "{{$.PrimaryResourceId}}" { + provider = google-beta + + region = "us-central1" + name = "{{index $.Vars "region_backend_service_name"}}" + health_checks = [google_compute_health_check.health_check.id] + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "RING_HASH" + session_affinity = "STRONG_COOKIE_AFFINITY" + protocol = "HTTP" + + strong_session_affinity_cookie { + ttl { + seconds = 11 + nanos = 1111 + } + name = "mycookie" + } +} + +resource "google_compute_health_check" "health_check" { + provider = google-beta + name = "{{index $.Vars "health_check_name"}}" + http_health_check { + port = 80 + } +} From 11f56f9225e18d10b078c69944d3e38fcb99652c Mon Sep 17 00:00:00 2001 From: Laiq Ahmed Date: Fri, 27 Sep 2024 06:41:34 -0400 Subject: [PATCH 2/2] Fixes the name of the at_least_one_of field for strongSessionAffinityCookie --- mmv1/products/compute/BackendService.yaml | 18 +++++++++--------- .../products/compute/RegionBackendService.yaml | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mmv1/products/compute/BackendService.yaml b/mmv1/products/compute/BackendService.yaml index c4363d34d91f..5bb6764e9975 100644 --- a/mmv1/products/compute/BackendService.yaml +++ b/mmv1/products/compute/BackendService.yaml @@ -1312,9 +1312,9 @@ properties: description: | Lifetime of the cookie. at_least_one_of: - - 'http_cookie.0.ttl' - - 'http_cookie.0.name' - - 'http_cookie.0.path' + - 'strong_session_affinity_cookie.0.ttl' + - 'strong_session_affinity_cookie.0.name' + - 'strong_session_affinity_cookie.0.path' properties: - name: 'seconds' type: Integer @@ -1334,17 +1334,17 @@ properties: description: | Name of the cookie. at_least_one_of: - - 'http_cookie.0.ttl' - - 'http_cookie.0.name' - - 'http_cookie.0.path' + - 'strong_session_affinity_cookie.0.ttl' + - 'strong_session_affinity_cookie.0.name' + - 'strong_session_affinity_cookie.0.path' - name: 'path' type: String description: | Path to set for the cookie. at_least_one_of: - - 'http_cookie.0.ttl' - - 'http_cookie.0.name' - - 'http_cookie.0.path' + - 'strong_session_affinity_cookie.0.ttl' + - 'strong_session_affinity_cookie.0.name' + - 'strong_session_affinity_cookie.0.path' - name: 'timeoutSec' type: Integer description: | diff --git a/mmv1/products/compute/RegionBackendService.yaml b/mmv1/products/compute/RegionBackendService.yaml index eef9e1adf91f..76f9dbf223be 100644 --- a/mmv1/products/compute/RegionBackendService.yaml +++ b/mmv1/products/compute/RegionBackendService.yaml @@ -1168,9 +1168,9 @@ properties: description: | Lifetime of the cookie. at_least_one_of: - - 'http_cookie.0.ttl' - - 'http_cookie.0.name' - - 'http_cookie.0.path' + - 'strong_session_affinity_cookie.0.ttl' + - 'strong_session_affinity_cookie.0.name' + - 'strong_session_affinity_cookie.0.path' properties: - name: 'seconds' type: Integer @@ -1190,17 +1190,17 @@ properties: description: | Name of the cookie. at_least_one_of: - - 'http_cookie.0.ttl' - - 'http_cookie.0.name' - - 'http_cookie.0.path' + - 'strong_session_affinity_cookie.0.ttl' + - 'strong_session_affinity_cookie.0.name' + - 'strong_session_affinity_cookie.0.path' - name: 'path' type: String description: | Path to set for the cookie. at_least_one_of: - - 'http_cookie.0.ttl' - - 'http_cookie.0.name' - - 'http_cookie.0.path' + - 'strong_session_affinity_cookie.0.ttl' + - 'strong_session_affinity_cookie.0.name' + - 'strong_session_affinity_cookie.0.path' - name: 'connectionTrackingPolicy' type: NestedObject description: |