From 23c4c9416582052c8b4df97ac61e6619e02188c7 Mon Sep 17 00:00:00 2001 From: upodroid Date: Wed, 5 Aug 2020 13:30:21 +0100 Subject: [PATCH 1/2] add grpc hc to both regional and global hc's --- products/compute/api.yaml | 150 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 813aca4836e8..f25f9a7508cf 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -4188,6 +4188,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'host' @@ -4311,6 +4312,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'host' @@ -4434,6 +4436,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'request' @@ -4538,6 +4541,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'request' @@ -4642,6 +4646,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'host' @@ -4757,6 +4762,76 @@ objects: - :USE_FIXED_PORT - :USE_NAMED_PORT - :USE_SERVING_PORT + - !ruby/object:Api::Type::NestedObject + name: 'grpcHealthCheck' + exactly_one_of: + - http_health_check + - https_health_check + - http2_health_check + - tcp_health_check + - ssl_health_check + - grpc_health_check + properties: + - !ruby/object:Api::Type::Integer + name: 'port' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + The port number for the health check request. + Must be specified if portName and portSpecification are not set + or if port_specification is USE_FIXED_PORT. Valid values are 1 through 65535. + - !ruby/object:Api::Type::String + name: 'portName' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + Port name as defined in InstanceGroup#NamedPort#name. If both port and + port_name are defined, port takes precedence. + - !ruby/object:Api::Type::Enum + name: 'portSpecification' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + Specifies how port is selected for health checking, can be one of the + following values: + + * `USE_FIXED_PORT`: The port number in `port` is used for health checking. + + * `USE_NAMED_PORT`: The `portName` is used for health checking. + + * `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each + network endpoint is used for health checking. For other backends, the + port or named port specified in the Backend Service is used for health + checking. + + If not specified, gRPC health check follows behavior specified in `port` and + `portName` fields. + values: + - :USE_FIXED_PORT + - :USE_NAMED_PORT + - :USE_SERVING_PORT + - !ruby/object:Api::Type::String + name: 'grpcServiceName' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + The gRPC service name for the health check. + The value of grpcServiceName has the following meanings by convention: + - Empty serviceName means the overall status of all services at the backend. + - Non-empty serviceName means the health of that gRPC service, as defined by the owner of the service. + The grpcServiceName can only be ASCII. - !ruby/object:Api::Type::NestedObject name: 'logConfig' description: | @@ -10561,6 +10636,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'host' @@ -10684,6 +10760,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'host' @@ -10807,6 +10884,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'request' @@ -10911,6 +10989,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'request' @@ -11015,6 +11094,7 @@ objects: - http2_health_check - tcp_health_check - ssl_health_check + - grpc_health_check properties: - !ruby/object:Api::Type::String name: 'host' @@ -11130,6 +11210,76 @@ objects: - :USE_FIXED_PORT - :USE_NAMED_PORT - :USE_SERVING_PORT + - !ruby/object:Api::Type::NestedObject + name: 'grpcHealthCheck' + exactly_one_of: + - http_health_check + - https_health_check + - http2_health_check + - tcp_health_check + - ssl_health_check + - grpc_health_check + properties: + - !ruby/object:Api::Type::Integer + name: 'port' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + The port number for the health check request. + Must be specified if portName and portSpecification are not set + or if port_specification is USE_FIXED_PORT. Valid values are 1 through 65535. + - !ruby/object:Api::Type::String + name: 'portName' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + Port name as defined in InstanceGroup#NamedPort#name. If both port and + port_name are defined, port takes precedence. + - !ruby/object:Api::Type::Enum + name: 'portSpecification' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + Specifies how port is selected for health checking, can be one of the + following values: + + * `USE_FIXED_PORT`: The port number in `port` is used for health checking. + + * `USE_NAMED_PORT`: The `portName` is used for health checking. + + * `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each + network endpoint is used for health checking. For other backends, the + port or named port specified in the Backend Service is used for health + checking. + + If not specified, gRPC health check follows behavior specified in `port` and + `portName` fields. + values: + - :USE_FIXED_PORT + - :USE_NAMED_PORT + - :USE_SERVING_PORT + - !ruby/object:Api::Type::String + name: 'grpcServiceName' + at_least_one_of: + - grpc_health_check.0.port + - grpc_health_check.0.port_name + - grpc_health_check.0.port_specification + - grpc_health_check.0.grpc_service_name + description: | + The gRPC service name for the health check. + The value of grpcServiceName has the following meanings by convention: + - Empty serviceName means the overall status of all services at the backend. + - Non-empty serviceName means the health of that gRPC service, as defined by the owner of the service. + The grpcServiceName can only be ASCII. - !ruby/object:Api::Type::NestedObject name: 'logConfig' description: | From 81dd47bf9700af0b8b03af680790a121ea7faf7f Mon Sep 17 00:00:00 2001 From: upodroid Date: Wed, 5 Aug 2020 13:48:57 +0100 Subject: [PATCH 2/2] added examples --- products/compute/terraform.yaml | 24 +++++++++++++++++++ .../examples/health_check_grpc.tf.erb | 10 ++++++++ .../examples/health_check_grpc_full.tf.erb | 12 ++++++++++ .../examples/region_health_check_grpc.tf.erb | 10 ++++++++ .../region_health_check_grpc_full.tf.erb | 12 ++++++++++ 5 files changed, 68 insertions(+) create mode 100644 templates/terraform/examples/health_check_grpc.tf.erb create mode 100644 templates/terraform/examples/health_check_grpc_full.tf.erb create mode 100644 templates/terraform/examples/region_health_check_grpc.tf.erb create mode 100644 templates/terraform/examples/region_health_check_grpc_full.tf.erb diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index 7eb456a56138..b490eaf69716 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -882,6 +882,16 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_id: "http2-health-check" vars: health_check_name: "http2-health-check" + - !ruby/object:Provider::Terraform::Examples + name: "health_check_grpc" + primary_resource_id: "grpc-health-check" + vars: + health_check_name: "grpc-health-check" + - !ruby/object:Provider::Terraform::Examples + name: "health_check_grpc_full" + primary_resource_id: "grpc-health-check" + vars: + health_check_name: "grpc-health-check" - !ruby/object:Provider::Terraform::Examples name: "health_check_with_logging" primary_resource_id: "health-check-with-logging" @@ -908,6 +918,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides diff_suppress_func: 'portDiffSuppress' sslHealthCheck: !ruby/object:Overrides::Terraform::PropertyOverride diff_suppress_func: 'portDiffSuppress' + grpcHealthCheck: !ruby/object:Overrides::Terraform::PropertyOverride + diff_suppress_func: 'portDiffSuppress' Image: !ruby/object:Overrides::Terraform::ResourceOverride examples: - !ruby/object:Provider::Terraform::Examples @@ -1603,6 +1615,16 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_id: "http2-region-health-check" vars: health_check_name: "http2-region-health-check" + - !ruby/object:Provider::Terraform::Examples + name: "region_health_check_grpc" + primary_resource_id: "grpc-region-health-check" + vars: + health_check_name: "grpc-region-health-check" + - !ruby/object:Provider::Terraform::Examples + name: "region_health_check_grpc_full" + primary_resource_id: "grpc-region-health-check" + vars: + health_check_name: "grpc-region-health-check" custom_code: !ruby/object:Provider::Terraform::CustomCode encoder: templates/terraform/encoders/health_check_type.erb resource_definition: templates/terraform/resource_definition/health_check.erb @@ -1629,6 +1651,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides diff_suppress_func: 'portDiffSuppress' sslHealthCheck: !ruby/object:Overrides::Terraform::PropertyOverride diff_suppress_func: 'portDiffSuppress' + grpcHealthCheck: !ruby/object:Overrides::Terraform::PropertyOverride + diff_suppress_func: 'portDiffSuppress' RegionUrlMap: !ruby/object:Overrides::Terraform::ResourceOverride examples: - !ruby/object:Provider::Terraform::Examples diff --git a/templates/terraform/examples/health_check_grpc.tf.erb b/templates/terraform/examples/health_check_grpc.tf.erb new file mode 100644 index 000000000000..01c0b3c5f30c --- /dev/null +++ b/templates/terraform/examples/health_check_grpc.tf.erb @@ -0,0 +1,10 @@ +resource "google_compute_health_check" "grpc-health-check" { + name = "<%= ctx[:vars]['health_check_name'] %>" + + timeout_sec = 1 + check_interval_sec = 1 + + grpc_health_check { + port = "443" + } +} diff --git a/templates/terraform/examples/health_check_grpc_full.tf.erb b/templates/terraform/examples/health_check_grpc_full.tf.erb new file mode 100644 index 000000000000..c4f69c4f0f1f --- /dev/null +++ b/templates/terraform/examples/health_check_grpc_full.tf.erb @@ -0,0 +1,12 @@ +resource "google_compute_health_check" "grpc-health-check" { + name = "<%= ctx[:vars]['health_check_name'] %>" + + timeout_sec = 1 + check_interval_sec = 1 + + grpc_health_check { + port_name = "health-check-port" + port_specification = "USE_NAMED_PORT" + grpc_service_name = "testservice" + } +} diff --git a/templates/terraform/examples/region_health_check_grpc.tf.erb b/templates/terraform/examples/region_health_check_grpc.tf.erb new file mode 100644 index 000000000000..d766d5c1924b --- /dev/null +++ b/templates/terraform/examples/region_health_check_grpc.tf.erb @@ -0,0 +1,10 @@ +resource "google_compute_region_health_check" "grpc-health-check" { + name = "<%= ctx[:vars]['health_check_name'] %>" + + timeout_sec = 1 + check_interval_sec = 1 + + grpc_health_check { + port = "443" + } +} diff --git a/templates/terraform/examples/region_health_check_grpc_full.tf.erb b/templates/terraform/examples/region_health_check_grpc_full.tf.erb new file mode 100644 index 000000000000..32c70d7a164a --- /dev/null +++ b/templates/terraform/examples/region_health_check_grpc_full.tf.erb @@ -0,0 +1,12 @@ +resource "google_compute_region_health_check" "grpc-health-check" { + name = "<%= ctx[:vars]['health_check_name'] %>" + + timeout_sec = 1 + check_interval_sec = 1 + + grpc_health_check { + port_name = "health-check-port" + port_specification = "USE_NAMED_PORT" + grpc_service_name = "testservice" + } +}