Skip to content
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

Support serverless neg in google_compute_region_backend_service #12299

Closed
bahag-klickst opened this issue Aug 11, 2022 · 11 comments
Closed

Support serverless neg in google_compute_region_backend_service #12299

bahag-klickst opened this issue Aug 11, 2022 · 11 comments

Comments

@bahag-klickst
Copy link

bahag-klickst commented Aug 11, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

We are using the public preview feature of Internal Load Balancer supporting Cloud Run backends (https://cloud.google.com/load-balancing/docs/l7-internal/setting-up-l7-internal-serverless) and created a bash script for invoking the gcloud commands. We now wanted to build the setup via terraform, but unfortunately it fails due to google_compute_region_backend_service not supporting serverless negs.
We are receiving the following error:

╷
│ Error: Error creating RegionBackendService: googleapi: Error 400: Invalid value for field 'resource.backends[0].balancingMode': 'CONNECTION'. Balancing mode is not supported for Serverless network endpoint groups., invalid
│ 
│   with google_compute_region_backend_service.ilb_cr_backend_service,
│   on ilb.tf line 54, in resource "google_compute_region_backend_service" "ilb_cr_backend_service":
│   54: resource "google_compute_region_backend_service" "ilb_cr_backend_service" {
│ 
╵

New or Affected Resource(s)

google_compute_region_backend_service

Potential Terraform Configuration

resource "google_cloud_run_service" "ilb_cr_service" {
  provider = google-beta
  project  = var.project
  location = var.region
  name     = "ilb-cr"
  template {
    spec {
      containers {
        image = "gcr.io/cloudrun/hello"
      }
    }
    metadata {
      annotations = {
        # Limit scale up to prevent any cost blow outs!
        "autoscaling.knative.dev/maxScale" = "5"
        # Use the VPC Connector
        "run.googleapis.com/vpc-access-connector" = "serverless-vpc-connector"
        # all egress from the service should go through the VPC Connector
        "run.googleapis.com/vpc-access-egress" = "all-traffic"
      }
    }
  }
  traffic {
    percent         = 100
    latest_revision = true
  }
  metadata {
    annotations = {
      # Internal traffic only
      "run.googleapis.com/ingress" = "internal"
    }
  }
}

resource "google_compute_region_network_endpoint_group" "ilb_cr_neg" {
  project               = var.project
  region                = var.region
  name                  = "ilb-cr-neg"
  network_endpoint_type = "SERVERLESS"
  cloud_run {
    service = google_cloud_run_service.ilb_cr_service.name
  }
}

resource "google_compute_region_backend_service" "ilb_cr_backend_service" {
  project               = var.project
  region                = var.region
  name                  = "ilb-cr-backend-service"
  protocol              = "HTTPS"
  load_balancing_scheme = "INTERNAL_MANAGED"
  backend {
    group = google_compute_region_network_endpoint_group.ilb_cr_neg.id
  }
}

References

In the docs it states, that when using the gcloud commands, one should use the following commands to setup the backend service and attach the neg:

gcloud compute backend-services create BACKEND_SERVICE_NAME \
        --load-balancing-scheme=INTERNAL_MANAGED \
        --protocol=HTTP \
        --region=REGION

gcloud compute backend-services add-backend BACKEND_SERVICE_NAME \
        --region=REGION \
        --network-endpoint-group=SERVERLESS_NEG_NAME \
        --network-endpoint-group-region=REGION

So I guess backend block has to be expanded to support neg.

b/314616920

@bahag-klickst
Copy link
Author

Okay, just found out, that I missed to check setting balancing_mode to "UTILIZATION".
Using "UTILIZATION" works and setup of ILB with CR based backend is possible.

@bahag-klickst
Copy link
Author

However, not sure if this is the right setting.

@googlerjk
Copy link

I reviewed the latest Magic Modules resource "google_cloud_run_service" in the regional neg and see not all required fields are supported and/or tested.

The cloud_run_service.traffic property is not supported in the terraform.yaml. Also, the full configuration expressed here is not represented or tested in its entirety. Once the missing fields and handwritten tests are added, the support for serverless neg should done.

@rileykarson rileykarson added this to the Near-Term Goals milestone Sep 6, 2022
@bahag-klickst
Copy link
Author

Any updates on this issue?

@sudermanjr
Copy link

Also would love to see this feature implemented

@pawelJas
Copy link

pawelJas commented May 27, 2024

Any updates on this issue?
@bahag-klickst you have found the correct workaround. Default Terraform value is different than deafult GCP value, setting it explicitly solves the problem.

Changing the default value is a breaking change, so it will need to wait for the next.

@melinath Could you mark this bug as breaking change, please?
Could you also close 17257 as duplicate?

@melinath
Copy link
Collaborator

@hao-nan-li could you look into making the changes requested in #12299 (comment) if appropriate?

@pawelJas
Copy link

@melinath @hao-nan-li I am planning to preapre a PR which clears the deafult values next week. Making 17257 duplicate could help, but we can just mark both as resolved after the PR.

@hao-nan-li
Copy link
Collaborator

Thanks @pawelJas, just marked duplicate on #17257

@pawelJas
Copy link

The default value for balancing_mode in google_compute_region_backend_service has been changed to UTILIZATION (default GCP value) in version 6.0.0. That should resolve the serverless NEG support.

@c2thorn c2thorn closed this as completed Jul 29, 2024
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants