确保请求中的项目、区域、命名空间名称和服务名称均正确无误,并且与您注册端点的位置一致。所有 Service Directory 服务都位于区域命名空间中,因此在一个区域注册的服务与另一个区域中的数据不匹配。
我向某人授予了某项服务的访问权限,但对方仍会收到 permission denied。
这可能有几个原因。首先,请检查地区是否正确。
如果您对某个命名空间或服务设置了政策,该政策仅适用于该特定区域。如果用户尝试在其他区域注册或查找同一服务,除非您还向他们授予对该区域性服务的 IAM 访问权限,否则他们将无权访问。如需调试访问问题,请尝试针对服务和命名空间使用 TestIamPermissions 方法。
我添加了一些端点,然后移除了服务后端。为什么端点仍然存在?
Service Directory 不会执行自动健康检查或心跳,也不会移除端点,除非您明确移除端点。请务必向服务后端/编排器添加代码,以便在端点不再存在时从 Service Directory 中移除该端点。我们建议您在端点上使用有效期注解字段,以记录端点的上次注册或更新时间。
我可以查找端点,但每次尝试连接到这些端点时都会失败。
Service Directory 无法确保从客户端可达服务。服务会直接向 Service Directory 注册其端点。不过,向 Service Directory 注册的地址可能无法路由(尤其是当客户端和服务器位于不同的专用网络中时)。如果端点可从客户端路由,则可能是端点运行状况不佳。请参阅以下问题。
已存在一个手动创建或使用其他集成创建的 Service Directory 命名空间,其名称与您尝试同步的 GKE 命名空间相同。您必须重命名或删除现有的 Service Directory 命名空间,以免发生冲突。
我们移除了您的 Service Directory 服务账号的权限。
确保 service-{PROJECT_NUMBER}@gcp-sa-servicedirectory.iam.gserviceaccount.com 具有 Service Directory Service Agent IAM 权限。如需详细了解 IAM,请参阅 IAM 文档。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Troubleshooting\n\nWhy do I get a `not found` error when adding an endpoint?\n---------------------------------------------------------\n\nIf you are getting 404 errors when adding services or endpoints,\nensure that you have created both the namespace and the service (in that order)\nbefore adding an endpoint. The service must exist before you can add additional\nendpoints.\n\nWhen I look up a service, why don't I get any of my endpoints?\n--------------------------------------------------------------\n\nEnsure that the project, region, namespace name, and service name are all correct\nin your request and match where you registered the endpoints. All\nService Directory services live in a regional namespace, so services\nregistered with one region do not match data in a separate region.\n\nI granted someone access to a service but they continue to get `permission denied`.\n-----------------------------------------------------------------------------------\n\nThis could be for a couple of reasons. First, check that the region is correct.\nIf you set a policy on a namespace or service, the policy only applies to that\nparticular region. If the user is trying to register or lookup the same service\nin another region, they won't have access unless you grant them\nIAM access to that regional service as well. To debug access\nissues, try the\n[`TestIamPermissions`](/resource-manager/reference/rest/v1/projects/testIamPermissions)\nmethod for services and namespaces.\n\nI added some endpoints and then removed the service backend. Why are the endpoints still there?\n-----------------------------------------------------------------------------------------------\n\nService Directory does not do automatic health-checking or heartbeating, and\ndoes not remove endpoints unless you explicitly remove them. Ensure that you\nadd code to your service backends/orchestrators that remove the endpoint from\nService Directory once it no longer exists. We recommend the use of time-to-live\nannotation fields on endpoints to record the last time an endpoint was registered\nor updated.\n\nI am able to look up endpoints but every time I try to connect to them, it fails.\n---------------------------------------------------------------------------------\n\nService Directory does not ensure the reachability from the client. Services\nregister their endpoints directly with Service Directory. However, the address\nregistered with Service Directory may not be routable (especially if both the\nclient and the server are on separate private networks). If the endpoint is\nroutable from the client, then it could be due to an unhealthy endpoint.\nSee the following question.\n\nHow can I add health data for endpoints so that my clients know which one to connect to?\n----------------------------------------------------------------------------------------\n\nWhen using client-side load balancing, we recommend that service backends\noccasionally update an annotation field on the endpoint that clients can use to\nmake decisions on which backend to connect to. Service Directory does not\ninspect or evaluate this data.\n\nI've created a namespace. Why can't I assign a Cloud DNS private zone to it?\n----------------------------------------------------------------------------\n\nEnsure that you have the `servicedirectory.namespaces.associatePrivateZone`\nIAM permission for the namespace as this permission lets you\ncreate the associated private zone. By default, the Project Editor, Project\nOwner, Service Directory Admin, and Service Directory Editor roles have this\npermission.\n\nWhen I do a DNS lookup of a service, why don't I get any of my endpoints?\n-------------------------------------------------------------------------\n\nThere could be several reasons, such as the following:\n\n1. The associated namespace has been deleted. You can check this by running the [`get`](/dns/docs/reference/v1/managedZones/get) command on the private zone. If the `serviceDirectoryConfig.deletionTime` is set, then the associated namespace and all of its endpoints have been deleted.\n2. Confirm that you are issuing the request from a network that is allowed to query the private zone. You can find the network list by running the [`get`](/dns/docs/reference/v1/managedZones/get) command on the private zone.\n3. There are no (valid) endpoints for the service. Run the [`resolve`](/service-directory/docs/reference/rest/v1beta1/projects.locations.namespaces.services/resolve) command on the service through the Service Directory API to ensure that the service is not empty and has at least one valid endpoint IP. DNS support is only available for endpoints with valid IPv4 or IPv6 IP addresses.\n4. Make sure that you're querying the correct zone. For example, suppose that you create a Service Directory zone called **example.com** , and you have another (standard) private zone named **billing.example.com** . Then any DNS query to **billing.example.com** returns resource records that belong to the **billing.example.com** zone, and not the **billing** service in the Service Directory namespace that is associated with **example.com.** For more information, see [Name resolution\n order](/dns/docs/vpc-name-res-order).\n\nWhy are my GKE services not syncing to Service Directory?\n---------------------------------------------------------\n\nThere could be several reasons, such as the following:\n\n1. Confirm that you have a `ServiceDirectoryRegistrationPolicy` deployed in your GKE cluster for the namespace that you are trying to sync. Also, confirm that the services you are trying to sync match the label selector in your policy.\n2. There is already an existing Service Directory namespace that was created manually or by using some other integration with the same name as the GKE namespace you are trying to sync. You must rename or delete your existing Service Directory namespace so that there are no conflicts.\n3. Permissions from your Service Directory Service Account were removed. Make sure that `service-{PROJECT_NUMBER}@gcp-sa-servicedirectory.iam.gserviceaccount.com` has the `Service Directory Service Agent` IAM permission. For details about IAM, see the [IAM\n documentation](/iam/docs).\n\nWhat's next\n-----------\n\n- To learn more about features, see [Service Directory\n overview](/service-directory/docs/overview).\n- To get additional help, see [Get\n support](/service-directory/docs/getting-support)."]]