부하 분산기를 만들 때 원하는 기존 서비스 디렉터리 네임스페이스 및 서비스에 엔드포인트로 등록할 수 있습니다. 그러면 클라이언트 애플리케이션은 HTTP 또는 gRPC를 사용하는 서비스 디렉터리를 사용하여 외부 패스 스루 네트워크 부하 분산기 서비스의 주소를 확인하고 여기에 직접 연결할 수 있습니다.
이 태스크에 필요한 권한
이 작업을 수행하려면 다음과 같은 권한 및 IAM 역할을 부여받아야 합니다.
권한
servicedirectory.endpoints.create
servicedirectory.endpoints.delete
역할
roles/compute.networkAdmin
roles/compute.securityAdmin
roles/compute.instanceAdmin
제한사항
외부 패스 스루 네트워크 부하 분산기와의 서비스 디렉터리 통합에는 다음과 같은 제한사항이 있습니다.
자동 등록은 외부 레이어 4 부하 분산기만 지원합니다. GKE 통합을 사용하여 Google Kubernetes Engine 부하 분산 서비스를 등록할 수 있습니다. 서비스 디렉터리 API를 호출하여 다른 외부 부하 분산기, 전역 부하 분산기, Google Kubernetes Engine 인그레스 및 게이트를 등록할 수 있습니다.
자동 등록은 전달 규칙을 만들 때만 사용할 수 있습니다. 이미 존재하는 전달 규칙에 Google Cloud CLI 업데이트를 사용한 자동 등록은 사용할 수 없습니다.
서비스 디렉터리는 연결을 제공하지 않습니다. 즉, 서비스 디렉터리에 외부 패스 스루 네트워크 부하 분산기의 가상 IP 주소가 저장되어 있더라도 서비스 디렉터리에서 외부 패스 스루 네트워크 부하 분산기를 조회한다고 해서 가상 IP 주소에 연결할 수 있는 것은 아닙니다.
시작하기 전에
이 안내를 따르려면 다음이 필요합니다.
이미 서비스 디렉터리 네임스페이스와 서비스가 있어야 합니다.
네임스페이스가 없는 경우 서비스 디렉터리 구성의 절차에 따라 네임스페이스와 서비스를 만듭니다.
서비스 디렉터리 네임스페이스와 서비스는 만들려는 외부 패스 스루 네트워크 부하 분산기 전달 규칙과 동일한 프로젝트 및 리전에 있어야 합니다.
외부 패스 스루 네트워크 부하 분산기 전달 규칙을 만들기 위해 필요한 리소스를 이미 설정했어야 합니다.
SD_SERVICE_NAME: 엔드포인트를 등록할 서비스 디렉터리 서비스의 정규화된 이름. 이 서비스는 생성되는 전달 규칙과 동일한 프로젝트 및 리전에 있어야 합니다.
예:
projects/PROJECT/locations/REGION/namespaces/NAMESPACE_NAME/services/SERVICE_NAME
엔드포인트 확인
외부 패스 스루 네트워크 부하 분산기를 등록할 때 생성되는 서비스 디렉터리 엔드포인트의 특징은 다음과 같습니다.
엔드포인트의 이름은 지정된 포트 번호 (<forwarding rule name>-<port>)가 있는 전달 규칙의 이름과 동일합니다. 예를 들어 --port=8080로 전달 규칙 RULE를 만들면 RULE-8080라는 엔드포인트가 생성됩니다. 동일한 규칙에서 포트 --port=8080, 8081를 두 개 지정하면 엔드포인트 RULE-8080 및 RULE-8081가 두 개 생성됩니다. --port=ALL를 지정하면 서비스 디렉터리 엔드포인트가 포트 0에 등록됩니다. 외부 패스 스루 네트워크 부하 분산기의 소유자인 경우 API 호출자가 연결할 포트를 알고 있어야 합니다.
공개 서비스 디렉터리 API를 사용하여 엔드포인트를 수정하거나 삭제할 수 없습니다. 전달 규칙을 삭제할 때만 엔드포인트가 자동으로 삭제됩니다. 즉, 전달 규칙이 존재하는 동안 엔드포인트가 있는 서비스와 네임스페이스를 삭제할 수 없습니다.
엔드포인트 자체에는 요금이 청구되지 않지만 엔드포인트에 대한 모든 API 호출에는 일반 가격 세부정보가 적용됩니다.
엔드포인트가 생성되었는지 확인하려면 서비스 디렉터리에서 서비스를 확인합니다.
지정된 포트 번호와 함께 전달 규칙의 이름과 동일한 이름의 엔드포인트가 표시됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Register an external passthrough Network Load Balancer\n\nThis page provides information about how to configure an\n[external passthrough Network Load Balancer](/load-balancing/docs/network) so that it is automatically\nregistered in Service Directory.\n\nWhen you create your load balancer, you can register it as an endpoint in an\nexisting Service Directory namespace and service of your choice. Client\napplications can then use Service Directory (using HTTP or gRPC) to resolve\nthe address of the external passthrough Network Load Balancer service and connect to it\ndirectly.\n\n#### Permissions required for this task\n\nTo perform this task, you must have been granted the following permissions\n*and* IAM roles.\n\n**Permissions**\n\n- `servicedirectory.endpoints.create`\n- `servicedirectory.endpoints.delete`\n\n**Roles**\n\n- `roles/compute.networkAdmin`\n- `roles/compute.securityAdmin`\n- `roles/compute.instanceAdmin`\n\nLimitations\n-----------\n\nService Directory integration with external passthrough Network Load Balancers has the following\nlimitations:\n\n- Automatic registration only supports external Layer 4 load balancers. You can register Google Kubernetes Engine load balancing services using the [GKE\n integration](/service-directory/docs/configuring-sd-for-gke). You can register other external load balancers, global load balancers, and Google Kubernetes Engine ingresses and gateways by calling the [Service Directory\n API](/service-directory/docs/apis).\n- You can use automatic registration only at the time of forwarding rule creation. Automatic registration using Google Cloud CLI update for an already existing forwarding rule is not available.\n- Service Directory does not provide connectivity, which means that although Service Directory stores the virtual IP address of the external passthrough Network Load Balancer, looking up the external passthrough Network Load Balancer in Service Directory does not guarantee that you can connect to the virtual IP address.\n\nBefore you begin\n----------------\n\nThese instructions require the following:\n\n- You must already have a Service Directory namespace and service in place.\n If you do not, create a namespace and service using\n the procedure in [Configure Service Directory](/service-directory/docs/configuring-service-directory).\n\n The Service Directory namespace and service must be in the\n same project and region as the external passthrough Network Load Balancer forwarding rule that\n you are creating.\n- You must already have set up the necessary\n resources to create an external passthrough Network Load Balancer forwarding rule.\n\n For information about how to create an external passthrough Network Load Balancer, see [Setting up a\n external passthrough Network Load Balancer](/load-balancing/docs/network/setting-up-network-backend-service).\n\nSet up forwarding rules to register an external passthrough Network Load Balancer in Service Directory\n------------------------------------------------------------------------------------------------------\n\nYou must set up a forwarding rule to register the external passthrough Network Load Balancer in\nService Directory. To register an external passthrough Network Load Balancer, see the following section.\n\n### Register an external passthrough Network Load Balancer\n\nTo register an external passthrough Network Load Balancer, run the [`gcloud compute forwarding-rules\ncreate` command](/sdk/gcloud/reference/compute/forwarding-rules/create) and\nset the `service-directory-registration` flag: \n\n```\ngcloud beta compute forwarding-rules create FORWARDING_RULE_NAME \\\n --region=REGION \\\n --load-balancing-scheme=EXTERNAL \\\n --address=RESERVED_IP_ADDRESS \\\n --ip-protocol=PROTOCOL_TYPE \\\n --ports=PORT_NUMBER \\\n --backend-service=BACKEND_SERVICE_NAME \\\n --backend-service-region=REGION \\\n --service-directory-registration=SD_SERVICE_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFORWARDING_RULE_NAME\u003c/var\u003e: a name for the forwarding rule that you want to create\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region to create the forwarding rule in\n- \u003cvar translate=\"no\"\u003eRESERVED_IP_ADDRESS\u003c/var\u003e: the IP address that the forwarding rule serves\n- \u003cvar translate=\"no\"\u003ePROTOCOL_TYPE\u003c/var\u003e: the IP protocol that the rule is to serve\n- \u003cvar translate=\"no\"\u003ePORT_NUMBER\u003c/var\u003e: a list of comma-separated ports\n- \u003cvar translate=\"no\"\u003eBACKEND_SERVICE_NAME\u003c/var\u003e: the target backend service that receives the traffic\n- \u003cvar translate=\"no\"\u003eSD_SERVICE_NAME\u003c/var\u003e: the fully qualified name of the Service Directory service where you want to register the endpoint. This service must be in the same project and region as the forwarding rule being created. For example: projects/\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e/namespaces/\u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e/services/\u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e.\n\n### Verify the endpoint\n\nThe Service Directory endpoints that are created when you register\nan external passthrough Network Load Balancer have the following characteristics:\n\n- The endpoint has the same name as the name of the forwarding rule with the specified port number (`\u003cforwarding rule name\u003e-\u003cport\u003e`). For example, if you create a forwarding rule `RULE` with `--port=8080`, you get an endpoint called `RULE-8080`. For the same rule, if you specified two ports `--port=8080, 8081`, you get two endpoints, `RULE-8080` and `RULE-8081`. If you specify `--port=ALL`, the Service Directory endpoint is registered with port `0`. If you are the owner of the external passthrough Network Load Balancer, you must ensure that the API caller knows what port to connect on.\n- You cannot modify or delete the endpoint using the public Service Directory API. Only when you delete the forwarding rule does the endpoint get automatically deleted. This means that you cannot delete the service and namespace that the endpoint resides in while the forwarding rule exists.\n- The endpoint itself is not billed, although normal pricing details apply to any API calls to the endpoint.\n\nTo confirm that the endpoint is created, resolve the service in Service Directory.\nYou should see an endpoint with the same name as the name of the\nforwarding rule with the specified port number.\n\nTo resolve the service in Service Directory, run the [`gcloud service-directory\nservices resolve`](/sdk/gcloud/reference/service-directory/services/resolve)\ncommand: \n\n```\ngcloud service-directory services resolve SD_SERVICE_NAME \\\n --namespace=SD_NAMESPACE_NAME \\\n --location=REGION\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eSD_SERVICE_NAME\u003c/var\u003e: the name of the Service Directory service to resolve. It must live in the Service Directory namespace name.\n- \u003cvar translate=\"no\"\u003eSD_NAMESPACE_NAME\u003c/var\u003e: the name that you gave the namespace containing your service.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the Google Cloud region containing the namespace. This should be the same as the region that you created the forwarding rule in.\n\nCleanup\n-------\n\nTo delete the resources that you created, follow these steps.\n\n1. To delete the forwarding rule, run the [`gcloud compute forwarding-rules\n delete`](/sdk/gcloud/reference/compute/forwarding-rules/delete)\n command:\n\n ```\n gcloud compute forwarding-rules delete FORWARDING_RULE_NAME \\\n --region=REGION\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eFORWARDING_RULE_NAME\u003c/var\u003e: the name of the forwarding rule that you created\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region for the forwarding rule\n\n For further details, see [Deleting a forwarding\n rule](/load-balancing/docs/using-forwarding-rules#deleting-fr).\n\n To confirm that deleting the forwarding rule has automatically deleted the\n endpoint from Service Directory, run the [`gcloud service-directory\n services resolve`](/sdk/gcloud/reference/service-directory/services/resolve)\n command described in [Verify the endpoint](#verify-endpoint)\n section on your Service Directory service.\n2. To delete the Service Directory namespace and service, see [Delete\n resources](/service-directory/docs/configuring-service-directory#delete_resources).\n\nWhat's next\n-----------\n\n- To get an overview of Service Directory, see the [Service Directory overview](/service-directory/docs/overview).\n- To find solutions for common issues that you might encounter when using Service Directory, see [Troubleshooting](/service-directory/docs/troubleshooting)."]]