Skip to content

Commit

Permalink
Add fields to support stateful cookie-based affinity (#11845)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-laiq authored Sep 27, 2024
1 parent 77b2876 commit c0fae5c
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
50 changes: 50 additions & 0 deletions mmv1/products/compute/BackendService.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
- 'strong_session_affinity_cookie.0.ttl'
- 'strong_session_affinity_cookie.0.name'
- 'strong_session_affinity_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:
- '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:
- 'strong_session_affinity_cookie.0.ttl'
- 'strong_session_affinity_cookie.0.name'
- 'strong_session_affinity_cookie.0.path'
- name: 'timeoutSec'
type: Integer
description: |
Expand Down
50 changes: 50 additions & 0 deletions mmv1/products/compute/RegionBackendService.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
- 'strong_session_affinity_cookie.0.ttl'
- 'strong_session_affinity_cookie.0.name'
- 'strong_session_affinity_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:
- '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:
- 'strong_session_affinity_cookie.0.ttl'
- 'strong_session_affinity_cookie.0.name'
- 'strong_session_affinity_cookie.0.path'
- name: 'connectionTrackingPolicy'
type: NestedObject
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit c0fae5c

Please sign in to comment.