Nachdem Sie die .proto-Datei und die gRPC API-Konfigurationsdatei eingerichtet haben, stellen Sie diese so bereit, dass Cloud Endpoints über die Informationen verfügt, die zum Verwalten der API erforderlich sind. Die Endpoints-Konfiguration wird mit dem Befehl gcloud
endpoints services deploy bereitgestellt. Dieser Befehl verwendet Service Infrastructure, die grundlegende Dienstplattform von Google. Sie wird von Endpoints und anderen Diensten verwendet, um APIs und Dienste zu erstellen und zu verwalten. Auf dieser Seite wird beschrieben, wie Sie Konfigurationsdateien in Endpoints bereitstellen.
Vorbereitung
Sie sollten Folgendes bereits haben:
Sie haben ein Google Cloud-Projekt erstellt, in dem Sie die Rolle Bearbeiter oder Inhaber haben. Nach der ersten Bereitstellung können Sie die restriktivere Rolle des Dienstkonfigurationsbearbeiters erteilen. Weitere Informationen finden Sie unter Zugriff auf die API gewähren und widerrufen.
Falls Sie einen benutzerdefinierten Domainnamen verwenden (z. B. example.com), müssen Sie den Domainnamen prüfen, damit Sie die gRPC-Konfigurationsdateien bereitstellen können.
Google Cloud CLI für die Bereitstellung vorbereiten
Verwenden Sie das gcloud-Befehlszeilentool, um die Konfiguration bereitzustellen. Weitere Informationen zu den Befehlen finden Sie in der gcloud-Referenz.
So bereiten Sie die Bereitstellung vor:
Installieren und initialisieren Sie die gcloud CLI.
Aktualisieren Sie die gcloud CLI:
gcloud components update
Achten Sie darauf, dass die gcloud CLI zum Zugriff auf Ihre Daten und Dienste berechtigt ist:
gcloud auth login
Ein neuer Browsertab wird geöffnet und Sie werden aufgefordert, ein Konto auszuwählen.
Legen Sie das Standardprojekt fest. Ersetzen Sie [YOUR-PROJECT-ID] durch Ihre GCP-Projekt-ID:
gcloud config set project [YOUR-PROJECT-ID]
Wenn Sie das API-Back-End in Kubernetes oder Kubernetes Engine bereitstellen, führen Sie den folgenden Befehl aus, um neue Nutzeranmeldedaten zur Verwendung als Standardanmeldedaten für Anwendungen abzurufen. Die Nutzeranmeldedaten sind für die Autorisierung von kubectl erforderlich.
gcloudauthapplication-defaultlogin
Ein neuer Browsertab wird geöffnet und Sie werden aufgefordert, ein Konto auszuwählen.
Konfigurationsdateien bereitstellen
Sie müssen sich in dem Verzeichnis befinden, in dem die Dateien api_descriptor.pb und api_config.yaml liegen.
Vergewissern Sie sich, dass das aktuell vom gcloud-Befehlszeilentool verwendete Standardprojekt das Google Cloud -Projekt ist, für das Sie die Endpoints-Konfiguration bereitstellen möchten. Überprüfen Sie anhand der vom folgenden Befehl zurückgegebenen Projekt-ID, ob der Dienst im richtigen Projekt erstellt wird.
gcloud config list project
Wenn Sie das Standardprojekt ändern müssen, führen Sie den folgenden Befehl aus:
gcloud config set project YOUR_PROJECT_ID
Stellen Sie die Datei proto descriptor und die Konfigurationsdatei mithilfe der Google Cloud CLI bereit:
Beim Erstellen und Konfigurieren des Dienstes gibt Service Management Informationen an das Terminal aus. Nach Abschluss der Bereitstellung erhalten Sie eine Meldung, die in etwa so aussieht:
Service Configuration [CONFIG_ID] uploaded for service [bookstore.endpoints.example-project.cloud.goog]
CONFIG_ID ist die eindeutige Endpoints-Dienstkonfigurations-ID, die von der Bereitstellung erstellt wird. Beispiel:
Service Configuration [2017-02-13r0] uploaded for service [bookstore.endpoints.example-project.cloud.goog]
Im obigen Beispiel ist 2017-02-13r0 die Dienstkonfigurations-ID und bookstore.endpoints.example-project.cloud.goog der Dienstname. Die Dienstkonfigurations-ID besteht aus einem Datumsstempel und einer Überarbeitungsnummer. Wenn Sie die Endpoints-Konfiguration am selben Tag noch einmal bereitstellen, erhöht sich die Überarbeitungsnummer in der Dienstkonfigurations-ID.
Wenn die Konfiguration Ihres Diensts auf mehrere YAML-Dateien verteilt ist, können Sie alle Dateien an den Befehl deploy übergeben. Die Hauptkonfiguration für Bookstore befindet sich beispielsweise in api_config.yaml. Sie können jedoch die HTTP-Transcodierung für den Dienst aktivieren, indem Sie zusätzlich api_config_http.yaml bereitstellen. Die Datei enthält zusätzliche Konfigurationen für dieses Feature:
Sollten Werte in den YAML-Dateien in Konflikt stehen, überschreiben die Werte in der letzten angegebenen Datei alle anderen Werte. Weitere Informationen dazu, wie in Cloud Endpoints mehrere YAML-Dateien zusammengeführt werden, finden Sie unter gRPC API-Dienst konfigurieren.
Wenn Sie Änderungen an .proto oder Ihrer YAML-Dienstkonfigurationsdatei vornehmen, müssen Sie die Dateien noch einmal bereitstellen, damit der Extensible Service Proxy (ESP) die neueste Version der API-Dienstkonfiguration hat. Wenn Sie bereits den ESP bereitgestellt und dabei die rollout-Option auf managed festgelegt haben, müssen Sie den ESP nicht noch einmal starten oder bereitstellen. Mit der Option rollout=managed legen Sie fest, dass der ESP die zuletzt bereitgestellte Dienstkonfiguration verwendet. Wenn Sie diese Option innerhalb von 5 Minuten nach der Bereitstellung einer neuen Dienstkonfiguration angeben, erkennt der ESP die Änderung und verwendet automatisch die neue Konfiguration. Wir empfehlen, diese Option anstelle einer konkreten Konfigurations-ID anzugeben, die vom ESP verwendet werden soll.
Nach der ersten Bereitstellung der Endpoints-Konfiguration können Sie einem Nutzer, einem Dienstkonto oder einer Gruppe eine Rolle zuweisen, die eine erneute Bereitstellung der Endpoints-Konfiguration zulässt. Weitere Informationen finden Sie unter Zugriff auf die API gewähren und widerrufen.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-03 (UTC)."],[[["\u003cp\u003eEndpoints requires deployment of \u003ccode\u003e.proto\u003c/code\u003e and gRPC API configuration files to manage your API, using the \u003ccode\u003egcloud endpoints services deploy\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eBefore deploying, you must set up a Google Cloud project with necessary roles, install gRPC and its tools, configure Endpoints, and verify any custom domain names.\u003c/p\u003e\n"],["\u003cp\u003eDeployment involves preparing the Google Cloud CLI, including logging in, setting the project ID, and updating components.\u003c/p\u003e\n"],["\u003cp\u003eThe deployment process utilizes \u003ccode\u003egcloud endpoints services deploy\u003c/code\u003e with the \u003ccode\u003eapi_descriptor.pb\u003c/code\u003e and \u003ccode\u003eapi_config.yaml\u003c/code\u003e files, resulting in a unique service configuration ID.\u003c/p\u003e\n"],["\u003cp\u003eRedeploying updated \u003ccode\u003e.proto\u003c/code\u003e or configuration files is necessary, with the \u003ccode\u003erollout=managed\u003c/code\u003e option for ESP enabling automatic updates within 5 minutes.\u003c/p\u003e\n"]]],[],null,["# Deploying the Endpoints configuration\n\n[OpenAPI](/endpoints/docs/openapi/deploy-endpoints-config \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nAfter you configure your `.proto` file and [gRPC API configuration\nfile](/endpoints/docs/grpc/configure-endpoints), you deploy them so that\nCloud Endpoints has the information that it needs to manage your API. To\ndeploy the Endpoints configuration, you use the [`gcloud\nendpoints services deploy`](/sdk/gcloud/reference/endpoints/services/deploy)\ncommand. This command uses\n[Service Infrastructure](/service-infrastructure/docs/overview), Google's\nfoundational services platform, used by Endpoints and other\nservices to create and manage APIs and services. This page describes how to\ndeploy your configuration files to Endpoints.\n\nPrerequisites\n-------------\n\nAs a starting point, this page assumes that you have:\n\n- [Created a Google Cloud\n project](/resource-manager/docs/creating-managing-projects) in which you have\n the **Editor** or **Owner** role. After the initial deployment, you can grant\n the more restrictive **Service Config Editor** role. See [Granting and\n revoking access to the API](/endpoints/docs/grpc/control-api-access) for more\n information.\n\n- [Installed gRPC and the gRPC tools](https://grpc.io/docs/quickstart/)\n\n- Configured Endpoints, which includes:\n\n - [Choosing the service name](/endpoints/docs/grpc/configure-endpoints#service_name).\n - [Configuring the protocol buffer](/endpoints/docs/grpc/configure-endpoints#configuring_the_protocol_buffer).\n - [Configuring the gRPC service configuration file](/endpoints/docs/grpc/configure-endpoints#configuring_the_grpc_service_configuration_file).\n- If you use a custom domain name (such as, `example.com`), you must [verify the\n domain name](/endpoints/docs/grpc/verify-domain-name) before you can deploy\n the gRPC configuration files.\n\nPreparing Google Cloud CLI for deployment\n-----------------------------------------\n\nYou use the `gcloud` command line tool to\ndeploy the configuration. See the [gcloud Reference](/sdk/gcloud/reference) for more information about the commands.\n\nTo prepare for the deployment:\n\n1. Install and initialize the [gcloud CLI](/sdk/docs/install).\n2. Update gcloud CLI: \n\n ```text\n gcloud components update\n ```\n3. Make sure that gcloud CLI is authorized to access your data and services: \n\n ```text\n gcloud auth login\n ```\n\n A new browser tab opens and you are prompted to choose an account.\n4. Set the default project. Replace `[YOUR-PROJECT-ID]` with your GCP project ID \n\n ```text\n gcloud config set project [YOUR-PROJECT-ID]\n ```\n5. If you will be deploying your API backend to either Kubernetes or Kubernetes Engine, run the following command to acquire new user credentials to use for Application Default Credentials. The user credentials are needed to authorize `kubectl`. \n\n ```bash\n gcloud auth application-default login\n ```\n A new browser tab opens and you are prompted to choose an account.\n\nDeploying the configuration files\n---------------------------------\n\n1. Make sure you are in the directory where the `api_descriptor.pb` and `api_config.yaml` files are located.\n2. Confirm that the default project that the `gcloud` command-line tool is currently using is the Google Cloud project that you want to deploy the Endpoints configuration to. Validate the project ID returned from the following command to make sure that the service doesn't get created in the wrong project. \n\n ```\n gcloud config list project\n ```\n\n If you need to change the default project, run the following command: \n\n ```\n gcloud config set project YOUR_PROJECT_ID\n ```\n3. Deploy the `proto descriptor` file and the configuration file by using the Google Cloud CLI: \n\n ```\n gcloud endpoints services deploy api_descriptor.pb api_config.yaml\n ```\n\n As it is creating and configuring the service, Service Management outputs\n information to the terminal. When the deployment completes, a message similar to\n the following is displayed: \n\n ```\n Service Configuration [CONFIG_ID] uploaded for service [bookstore.endpoints.example-project.cloud.goog]\n ```\n\n \u003cvar translate=\"no\"\u003eCONFIG_ID\u003c/var\u003e is the unique Endpoints service configuration\n ID created by the deployment. For example: \n\n ```\n Service Configuration [2017-02-13r0] uploaded for service [bookstore.endpoints.example-project.cloud.goog]\n ```\n\n In the previous example, `2017-02-13r0` is the service\n configuration ID and\n `bookstore.endpoints.example-project.cloud.goog` is the\n service name. The service configuration ID consists of a date stamp followed by\n a revision number. If you deploy the Endpoints configuration\n again on the same day, the revision number is incremented in the service\n configuration ID.\n\nIf your service's configuration is in multiple YAML files, you can pass them all\nto the `deploy` command. For example, the Bookstore has its basic configuration\nin `api_config.yaml`, but you can enable HTTP transcoding for the service by\nalso deploying `api_config_http.yaml`, which has additional configuration for\nthis feature: \n\n gcloud endpoints services deploy api_descriptor.pb api_config.yaml api_config_http.yaml\n\n| The above gcloud command only supports one proto descriptor file and it has to be the first file in the gcloud command arguments. If you have multiple gRPC services in different proto files, please use the \\`protoc\\` command-line tool to combine them into one descriptor file.\n\nNote that if there are conflicting values in your YAML files, the values in the\nlast specified file override the others. You can find out more about how\nEndpoints handles merging multiple YAML files in\n[Configuring a gRPC service](/endpoints/docs/grpc/grpc-service-config).\n\nIf you get an error message, see [Troubleshooting Endpoints\nconfiguration deployment](/endpoints/docs/grpc/troubleshoot-config-deployment) for\ninformation on troubleshooting the error.\n\nRedeploying\n-----------\n\nWhenever you change something in your `.proto` or service configuration YAML\nfile, deploy the files again so that the Extensible Service Proxy (ESP) has\nthe most recent version of your API's service configuration. If you previously\ndeployed ESP with the [`rollout` option set to\n`managed`](/endpoints/docs/grpc/deploy-api-backend#deploying_your_api_and_esp),\nyou don't need to restart or redeploy ESP. The `rollout=managed`\noption\nconfigures ESP to use the latest deployed service configuration. When you\nspecify this option, up to 5 minutes after you deploy a new service\nconfiguration, ESP detects the change and automatically begins using it. We\nrecommend that you specify this option instead of a specific configuration ID\nfor ESP to use.\n\nAfter the initial Endpoints configuration deployment, you can\ngrant a user, service account, or group a role that allows them to redeploy the\nEndpoints configuration. See [Granting and revoking access to the\nAPI](/endpoints/docs/grpc/control-api-access) for more information.\n\nWhat's next\n-----------\n\n- [Deploying the API backend](/endpoints/docs/grpc/deploy-api-backend)\n- [Running ESP Locally or on another platform](/endpoints/docs/grpc/running-esp-localdev)\n- [Getting the service name and configuration ID](/endpoints/docs/grpc/get-service-name-config-id)"]]