このページでは、ドメイン名として .endpoints.PROJECT_ID.cloud.goog を使用するように Cloud Endpoints API を構成する方法について説明します。このページの構成手順は、OpenAPI を使用し、Compute Engine、Kubernetes Engine、Kubernetes で実行されている API に適用できます。.endpoints.PROJECT_ID.cloud.goog ドメイン名は、App Engine で実行されている API ではサポートされていません。App Engine の API には、PROJECT_ID.appspot.com Endpoints サービス名として使用することをおすすめします。App Engine に API をデプロイすると、PROJECT_ID.appspot.com という形式の名前を持つ DNS エントリが自動的に作成されます。
.cloud.goog ドメインは Google が管理し、 Google Cloudのお客様と共有します。 Google Cloud プロジェクトには必ずグローバルに一意のプロジェクト ID が割り当てられるので、.endpoints.PROJECT_ID.cloud.goog 形式のドメイン名は一意になり、API のドメイン名として使用できます。.endpoints.PROJECT_ID.cloud.goog ドメイン名の構成はオプションです。必要に応じて、独自のドメイン名を登録できます。
前提条件
このページでは、Cloud Endpoints API をすでに作成して Compute Engine、Google Kubernetes Engine、Kubernetes にデプロイ済みであることを前提としています。テスト用の API が必要な場合は、サンプル API の構成およびデプロイ方法を示すチュートリアルのいずれかを使用してください。
DNS の構成
次の手順では、.endpoints.[PROJECT_ID].cloud.goog を Endpoints サービス名として使用する Cloud Endpoints API の DNS を構成する方法について説明します([PROJECT_ID] は実際の Google Cloudプロジェクト ID です)。便宜上、この手順では OpenAPI 構成ファイルを openapi.yaml とします。
[API_NAME] は API の名前(bookstore、my-cool-api など)で置き換えます。
[PROJECT_ID] は、実際の Google Cloud プロジェクト ID に置き換えます。
[IP_ADDRESS] を IPv4 アドレスに置き換えます。
たとえば、Endpoints API サービスを Compute Engine 仮想マシン インスタンスにデプロイする場合、その仮想マシンの外部 IP を使用できます。また、ロードバランサの背後にある仮想マシン インスタンス(または GKE ポッド)のグループでコードを実行する場合、ロードバランサの IP アドレスを使用できます。
前述の gcloud コマンドで openapi.yaml をデプロイすると、Service Management はターゲット IP アドレス 192.0.2.1 に解決される DNS A レコード my-cool-api.endpoints.my-project-
id.cloud.goog を作成します。新しい DNS 構成が反映されるまでに数分かかる場合があります。
[[["わかりやすい","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-04-09 UTC。"],[[["\u003cp\u003eCloud Endpoints APIs can use \u003ccode\u003e.endpoints.\u003c/code\u003e\u003cvar translate=no\u003ePROJECT_ID\u003c/var\u003e\u003ccode\u003e.cloud.goog\u003c/code\u003e as the domain name, which is managed by Google and ensures uniqueness due to the globally unique project ID.\u003c/p\u003e\n"],["\u003cp\u003eAlternatively, users can register their own custom domain names for their APIs, requiring them to manage their own DNS configuration.\u003c/p\u003e\n"],["\u003cp\u003eTo configure DNS with \u003ccode\u003e.endpoints.\u003c/code\u003e\u003cvar translate=no\u003ePROJECT_ID\u003c/var\u003e\u003ccode\u003e.cloud.goog\u003c/code\u003e, users must add the \u003ccode\u003ex-google-endpoints\u003c/code\u003e field in their \u003ccode\u003eopenapi.yaml\u003c/code\u003e file, specifying the API name and target IP address.\u003c/p\u003e\n"],["\u003cp\u003eWhen deploying the updated \u003ccode\u003eopenapi.yaml\u003c/code\u003e file, Service Management creates a DNS A-record that resolves the API's domain name to the specified IP address.\u003c/p\u003e\n"],["\u003cp\u003eThe use of \u003ccode\u003e.endpoints.\u003c/code\u003e\u003cvar translate=no\u003ePROJECT_ID\u003c/var\u003e\u003ccode\u003e.cloud.goog\u003c/code\u003e domain is not supported for APIs running on App Engine; instead, \u003cvar translate=no\u003ePROJECT_ID\u003c/var\u003e\u003ccode\u003e.appspot.com\u003c/code\u003e is recommended.\u003c/p\u003e\n"]]],[],null,["# Configuring DNS on the cloud.goog domain\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/cloud-goog-dns-configure \"View this page for the Cloud Endpoints gRPC docs\")\n\n\u003cbr /\u003e\n\nAfter your API is deployed, users of your API need to access it through a domain name\nrather than an IP address. You can either:\n\n- Configure `.endpoints.`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloud.goog` as the domain name (where \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is your Google Cloud project ID).\n- Or register your own domain name, such as `example.com`, which entails:\n - Configuring DNS name servers (or using [Cloud DNS](/dns/docs)).\n - Updating registry addresses.\n - Creating and maintaining DNS records.\n\n If you already have a DNS infrastructure, or you want to register your own\n domain name, see [Serving an API from your domain name](/endpoints/docs/grpc/serving-apis-from-domains) for more information.\n\nThis page describes how to configure Cloud Endpoints APIs to use\n`.endpoints.`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloud.goog` as the domain\nname. The configuration steps on this page are applicable for APIs using\nOpenAPI running on Compute Engine, Google Kubernetes Engine, or Kubernetes.\n\nThe `.endpoints.`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloud.goog` domain name isn't\nsupported for APIs running on App Engine. For APIs on App Engine, we\nrecommend that you use \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.appspot.com` as the\nEndpoints service name. When you deploy the API to App Engine, a DNS entry with a\nname in the format \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.appspot.com` is created automatically.\n\nThe `.cloud.goog` domain is managed by Google and shared by Google Cloud\ncustomers. Because Google Cloud projects are guaranteed to have a globally unique project ID,\na domain name in the format `.endpoints.`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloud.goog` is unique and\ncan be used as the domain name for your API. Configuring the\n`.endpoints.`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloud.goog` domain name is optional. If you prefer, you\ncan register your own domain name.\n\nPrerequisites\n-------------\n\nAs a starting point, this page assumes that you have already created your\nCloud Endpoints API and deployed it to Compute Engine, Google Kubernetes Engine, or\nKubernetes. If you need an API for testing, you can use one of the\n[tutorials](/endpoints/docs/openapi/tutorials) that walk you through\nconfiguring and deploying a sample API.\n\nConfiguring DNS\n---------------\n\nThe following procedure describes how to configure DNS for Cloud Endpoints\nAPIs that use `.endpoints.[PROJECT_ID].cloud.goog` as the Endpoints\nservice name where `[PROJECT_ID]` represents your Google Cloud\nproject ID. For convenience, the procedure refers to your\nOpenAPI configuration file as `openapi.yaml`.\n\nTo configure DNS:\n\n1. Open `openapi.yaml`, and add the `x-google-endpoints` field to the file as shown in the following snippet: \n\n ```transact-sql\n swagger: \"2.0\"\n host: \"[API_NAME].endpoints.[PROJECT_ID].cloud.goog\"\n x-google-endpoints:\n - name: \"[API_NAME].endpoints.[PROJECT_ID].cloud.goog\"\n target: \"[IP_ADDRESS]\"\n ```\n\n Typically, you configure the `host` field and the\n `x-google-endpoints.name` field to be the same. When you deploy your\n OpenAPI specification, the text specified in the `host` field is used\n as the name of your Endpoints service.\n2. Replace `[API_NAME]` with the name of your API (for example, `bookstore` or `my-cool-api`).\n3. Replace `[PROJECT_ID]` with your Google Cloud project ID.\n4. Replace `[IP_ADDRESS]` with an IPv4 address.\n\n For example, if you deploy your Endpoints API service to a\n Compute Engine virtual machine instance, you can use the external IP of that\n virtual machine. Alternatively, if you run your code on a group of virtual\n machine instances (or GKE pods) behind a load balancer,\n you can use the IP address of the load balancer.\n5. Deploy your new OpenAPI specification to Service Management using the following command: \n\n ```text\n gcloud endpoints services deploy openapi.yaml\n ```\n\nFor example, if the following is specified in an `openapi.yaml` file: \n\n```text\n swagger: \"2.0\"\n host: \"my-cool-api.endpoints.my-project-id.cloud.goog\"\n x-google-endpoints:\n - name: \"my-cool-api.endpoints.my-project-id.cloud.goog\"\n target: \"192.0.2.1\"\n```\n\n\u003cbr /\u003e\n\nWhen you deploy the `openapi.yaml` using the previous `gcloud` command,\nService Management creates a DNS A-record, `my-cool-api.endpoints.my-project-id.cloud.goog`, which resolves to the target IP address, `192.0.2.1`. You might\nneed to wait a few minutes for the new DNS configuration to propagate.\n\nWhat's next\n-----------\n\n- [Enabling SSL for Endpoints](/endpoints/docs/openapi/enabling-ssl)\n- [Configuring IP addresses](/compute/docs/configure-ip-addresses)\n- [Naming your API service](/endpoints/docs/openapi/naming-your-api-service)\n- [Serving an API from your domain name](/endpoints/docs/openapi/serving-apis-from-domains)"]]