Register an internal load balancer (original) (raw)

This page provides information about how to configure aninternal passthrough Network Load Balancer or aninternal Application Load Balancer(Preview) so that it is automatically registered in Service Directory.

When you create your load balancer, you can register it as an endpoint in an existing Service Directory namespace and service of your choice. Client applications can then use Service Directory (using HTTP or gRPC) and/or DNS (if you have created aService Directory DNS zone) to resolve the address of the internal load balancer service and connect to it directly.

Permissions required for this task

To perform this task, you must have been granted the following permissions_and_ IAM roles.

Permissions

Roles

Limitations

Service Directory integration with internal load balancing has the following limitations:

Before you begin

These instructions require the following:

Set up forwarding rules to register an internal load balancer in Service Directory

You must set up a forwarding rule to register the internal load balancer in Service Directory. To register either an internal passthrough Network Load Balancer or an internal Application Load Balancer, see the following sections.

Register an internal passthrough Network Load Balancer

To register an internal passthrough Network Load Balancer, run the gcloud compute forwarding-rules create command and set the service-directory-registration flag:

gcloud compute forwarding-rules create FORWARDING_RULE_NAME
--region=REGION
--load-balancing-scheme=INTERNAL
--network=NETWORK_NAME
--subnet=SUBNET_NAME
--address=RESERVED_IP_ADDRESS
--ip-protocol=PROTOCOL_TYPE
--ports=PORT_NUMBER
--backend-service=BACKEND_SERVICE_NAME
--backend-service-region=REGION
--service-directory-registration=SD_SERVICE_NAME

Replace the following:

Register an internal Application Load Balancer

To register a regional internal Application Load Balancer, run the gcloud compute forwarding-rules create command and set the service-directory-registration flag:

gcloud beta compute forwarding-rules create FORWARDING_RULE_NAME
--region=REGION
--load-balancing-scheme=INTERNAL_MANAGED
--network=NETWORK_NAME
--address=RESERVED_IP_ADDRESS
--target-https-proxy=PROXY_NAME
--target-https-proxy-region=PROXY_REGION
--ports=PORT_NUMBER
--service-directory-registration=SD_SERVICE_NAME

Replace the following:

Verify the endpoint

One or more Service Directory endpoints that are created when you register an internal load balancer have the following characteristics:

To confirm that the endpoint is created, resolve the service in Service Directory. You should see an endpoint with the same name as the name of the forwarding rule with the specified port number.

To resolve the service in Service Directory, do the following:

gcloud

Run the gcloud service-directory services resolvecommand:

gcloud service-directory services resolve SD_SERVICE_NAME
--namespace=SD_NAMESPACE_NAME
--location=REGION

Replace the following:

Optional: Create a Service Directory zone using Cloud DNS

You can resolve Service Directory endpoints that are registered through this integration using DNS like any other Service Directory endpoint. To create a Service Directory zone using Cloud DNS, see Configuring a Service Directory zone.

To check that your zone is set up correctly, you can run a DNS query of your Service Directory zone. For instructions about how to query using DNS, seeQuerying using DNS. If your zone is configured correctly, you should see the IP address of your internal load balancer in the command output.

Cleanup

To delete the resources that you created, do the following:

gcloud

  1. To delete the forwarding rule, run the gcloud compute forwarding-rules deletecommand:
    gcloud compute forwarding-rules delete FORWARDING_RULE_NAME \
    --region=REGION \
    Replace the following:
  2. To delete the zone, if you created one, follow the instructions inDelete a managed zone.
  3. To delete the Service Directory namespace and service, see Deleting resources.

What's next