Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Bookinfo-Beispiel bereitstellen
Auf dieser Seite wird erläutert, wie Sie eine Beispielanwendung in Cloud Service Mesh bereitstellen. Wenn Sie Cloud Service Mesh noch nicht installiert haben, lesen Sie die Installationsanleitung.
In der Cloud Service Mesh-Installation sind mehrere Beispielanwendungen enthalten. In dieser Anleitung wird beschrieben, wie Sie das Beispiel BookInfo bereitstellen. Hierbei handelt es sich um eine einfache Nachbildung einer Buchhandlung, die aus vier Diensten besteht, die eine Webproduktseite, Buchdetails, Rezensionen (mit mehreren Versionen des Rezensionsdienstes) sowie Bewertungen bieten. Alle werden mit Cloud Service Mesh verwaltet. Den Quellcode und alle anderen Dateien, die in diesem Beispiel genutzt werden, finden Sie im Verzeichnis samples/bookinfo Ihrer Cloud Service Mesh-Installation.
Automatische Sidecar-Injektion aktivieren
Wenn Sie die automatische Sidecar-Injektion aktivieren möchten, müssen Sie Ihre Namespaces so labeln, dass der Webhook für den Sidecar-Injektor die eingefügten Sidecars mit einer bestimmten Steuerungsebenen-Revision verknüpft. Wenn Sie das Standard-Tag einrichten, versehen Sie Ihre Namespaces mit den Standard-Injektionslabels.
Andernfalls kennzeichnen Sie Ihre Namespaces mit dem Überarbeitungslabel. Welches Label Sie hinzufügen, hängt davon ab, ob Sie verwaltetes Cloud Service Mesh oder die clusterinterne Steuerungsebene installiert haben.
Verwaltet
Sie können entweder das Standard-Injektionslabel oder das Überarbeitungslabel für Ihren Namespace verwenden.
Standard-Injektionslabels
Wenden Sie das Standard-Injektionslabel auf den Namespace an.
Entfernen Sie vor dem Bereitstellen von Anwendungen alle vorherigen istio-injection-Labels aus ihren Namespaces und legen Sie stattdessen das Label istio.io/rev=REVISION_LABEL fest.
Wenn Sie es in ein bestimmtes Überarbeitungslabel ändern möchten, klicken Sie auf REVISION_LABEL und ersetzen Sie es durch das entsprechende Label: asm-managed-rapid für den Rapid-Channel, asm-managed für den Regular-Channel oder asm-managed-stable für den Stable-Channel.
Verwenden Sie den folgenden Befehl, um das Überarbeitungslabel für istiod zu finden:
kubectl -n istio-system get pods -l app=istiod --show-labels
Die Ausgabe sieht dann ungefähr so aus:
NAME READY STATUS RESTARTS AGE LABELS
istiod-asm-173-3-5788d57586-bljj4 1/1 Running 0 23h app=istiod,istio.io/rev=asm-1264-1,istio=istiod,pod-template-hash=5788d57586
istiod-asm-173-3-5788d57586-vsklm 1/1 Running 1 23h app=istiod,istio.io/rev=asm-1264-1,istio=istiod,pod-template-hash=5788d57586
Notieren Sie sich den Wert des Überarbeitungslabels istiod aus der Ausgabe in der Spalte LABELS, das auf das Präfix istio.io/rev= folgt. In diesem Beispiel ist der Wert asm-1264-1.
Wenden Sie das Überarbeitungslabel auf den Standard-Namespace an. Im folgenden Befehl ist REVISION der Wert des Revisions-Labels istiod, den Sie im vorherigen Schritt notiert haben.
Sie können die Nachricht "istio-injection not found" in der Ausgabe ignorieren. Das bedeutet, dass der Namespace bisher nicht das Label istio-injection hatte, was bei Neuinstallationen von Cloud Service Mesh oder neuen Bereitstellungen zu erwarten wäre. Da das Verhalten der automatischen Injektion nicht definiert ist, wenn ein Namespace sowohl istio-injection als auch das Überarbeitungslabel enthält, wird bei allen kubectl label-Befehlen in der Cloud Service Mesh-Dokumentation ausdrücklich darauf geachtet, dass nur eines davon festgelegt ist.
Anwendung bereitstellen
Nachdem die automatische Injektion im Namespace default aktiviert wurde, werden beim Bereitstellen der Dienste der BookInfo-Anwendung Sidecar-Proxys zusammen mit jedem Dienst eingefügt.
Wechseln Sie in der Befehlszeile des Computers, auf dem Sie Cloud Service Mesh installiert haben, zum Stammverzeichnis des Cloud Service Mesh-Installationsverzeichnisses. Laden Sie bei Bedarfdie Installationsdatei herunter.
Stellen Sie die Anwendung mit kubectl im Standard-Namespace bereit:
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created
Anwendungsbereitstellung validieren
Zum Prüfen, ob die BookInfo-Anwendung funktioniert, müssen Sie Traffic an das Ingress-Gateway senden.
Wenn Sie Cloud Service Mesh in Google Distributed Cloud installiert haben, rufen Sie die externe IP-Adresse für das Ingress-Gateway ab, das Sie nach der Installation von Cloud Service Mesh konfiguriert haben.
Wenn Sie Cloud Service Mesh in GKE installiert haben, erhalten Sie die externe IP-Adresse des Ingress-Gateways:
kubectl get service istio-ingressgateway -n istio-system
Ausgabe:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.19.247.233 35.239.7.64 80:31380/TCP,443:31390/TCP,31400:31400/TCP 27m
In diesem Beispiel lautet die IP-Adresse des Ingress-Dienstes 35.239.7.64.
Anwendung testen
Prüfen Sie, ob die BookInfo-Anwendung mit curl ausgeführt wird:
curl -I http://EXTERNAL_IP/productpage
Wenn in der Antwort 200 angezeigt wird, bedeutet dies, dass die Anwendung fehlerfrei mit Cloud Service Mesh funktioniert.
Geben Sie die folgende Adresse in Ihren Browser ein, um die BookInfo-Webseite aufzurufen:
http://EXTERNAL_IP/productpage
Wenn Sie die Seite mehrmals aktualisieren, sollten auf der Produktseite verschiedene Versionen der Rezensionen in zufälliger Abfolge angezeigt werden (rote Sterne, schwarze Sterne, keine Sterne).
Da Ihre Anwendung Traffic generiert, können Sie sich die Cloud Service Mesh-Seiten in der Google Cloud Console ansehen, um Messwerte und andere Beobachtbarkeitsfunktionen aufzurufen.
Bereinigen
Wenn Sie mit dem Testen des Bookinfo-Beispiels fertig sind, entfernen Sie es aus Ihrem Cluster.
Deinstallieren Sie Bookinfo mit dem folgenden Skript:
samples/bookinfo/platform/kube/cleanup.sh
Bestätigen Sie das Herunterfahren:
kubectl get virtualservices #-- there should be no virtual services
kubectl get destinationrules #-- there should be no destination rules
kubectl get gateway #-- there should be no gateway
kubectl get pods #-- the Bookinfo pods should be deleted
[[["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-04 (UTC)."],[],[],null,["Deploying the Bookinfo sample\n\nThis page explains how to deploy a sample application to demonstrate\nCloud Service Mesh. If you haven't installed Cloud Service Mesh, see the\n[Installation guide](/service-mesh/v1.20/docs/unified-install/install-anthos-service-mesh).\n\nSeveral sample applications come with the Cloud Service Mesh installation. This\nguide walks you through deploying the\n[BookInfo](https://istio.io/v1.26/docs/examples/bookinfo/)\nsample. This is a simple mock bookstore application made up of four services\nthat provide a web product page, book details, reviews (with several versions of\nthe review service), and ratings---all managed using Cloud Service Mesh. You can\nfind the source code and all the other files used in this example in your\nCloud Service Mesh installation's directory in `samples/bookinfo`.\n\nEnabling sidecar auto-injection\n\nTo enable sidecar auto-injection, you must label your namespaces so that the\nsidecar injector webhook associate injected sidecars with a particular control\nplane revision. If you set up the default tag, then label your namespaces with\nthe\n[default injection labels](/service-mesh/docs/managed/select-a-release-channel#how-to-select-a-release-channel).\nOtherwise, label your namespaces with the\n[revision label](/service-mesh/v1.20/docs/revisions-overview). Additionally, the label that\nyou add also depends on whether you deployed\n[managed Cloud Service Mesh](/service-mesh/docs/managed/provision-managed-anthos-service-mesh)\nor installed the [in-cluster control plane](/service-mesh/v1.20/docs/unified-install/install-anthos-service-mesh). \n\nManaged\n\n1. You can either use the default injection label or the revision label for your namespace\n\n Default injection labels\n\n Apply the default injection label to the namespace. \n\n kubectl label namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e istio-injection=enabled istio.io/rev-\n\n Revision label\n\n Before you deploy applications, remove any previous `istio-injection` labels\n from their namespaces and set the `istio.io/rev=`\u003cvar label=\"revision\" scope=\"MCP_RELEASE_CHANNEL\" class=\"edit\" translate=\"no\"\u003eREVISION_LABEL\u003c/var\u003e label instead.\n\n\n To change it to a specific revision label, click `REVISION_LABEL`, and replace\n it with the applicable label: `asm-managed-rapid` for rapid channel, `asm-managed` for\n regular channel, or `asm-managed-stable` for stable channel.\n\n The revision label corresponds to a [release channel](/service-mesh/v1.20/docs/release-channels-managed-control-plane):\n\n | Revision label | Channel |\n |----------------------|---------|\n | `asm-managed` | Regular |\n | `asm-managed-rapid` | Rapid |\n | `asm-managed-stable` | Stable |\n\n kubectl label namespace \u003cvar label=\"namespace\" translate=\"no\"\u003eNAMESPACE\u003c/var\u003e istio-injection- istio.io/rev=\u003cvar label=\"revision\" scope=\"MCP_RELEASE_CHANNEL\" translate=\"no\"\u003eREVISION_LABEL\u003c/var\u003e --overwrite\n\n | **Note:** You can ignore any `label \"istio-injection\" not found` errors.\n2. If you also deployed the optional\n [managed data plane](/service-mesh/docs/managed/provision-managed-anthos-service-mesh#managed_data_plane),\n annotate the `NAMESPACE`namespace as follows:\n\n kubectl annotate --overwrite namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n mesh.cloud.google.com/proxy='{\"managed\":\"true\"}'\n\nIn-cluster\n\n1. Use the following command to locate the label on `istiod`:\n\n kubectl -n istio-system get pods -l app=istiod --show-labels\n\n The output looks similar to the following: \n\n NAME READY STATUS RESTARTS AGE LABELS\n istiod-asm-173-3-5788d57586-bljj4 1/1 Running 0 23h app=istiod,istio.io/rev=asm-1264-1,istio=istiod,pod-template-hash=5788d57586\n istiod-asm-173-3-5788d57586-vsklm 1/1 Running 1 23h app=istiod,istio.io/rev=asm-1264-1,istio=istiod,pod-template-hash=5788d57586\n\n In the output, under the `LABELS` column, note the value of the `istiod`\n revision label, which follows the prefix `istio.io/rev=`. In this\n example, the value is `asm-1264-1`.\n\n\n | **Note:** You can substitute `istio.io/rev` with the `istio-injection=enabled` label if the [default tag](https://istio.io/latest/docs/setup/upgrade/canary/#default-tag) is configured. Verify the default tag exists by running ` istioctl tag list` with the `istioctl` from \u003cvar translate=\"no\"\u003eOUTPUT_DIR\u003c/var\u003e.\n\n \u003cbr /\u003e\n\n2. Apply the revision label to the default namespace. In the following command,\n \u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e is the value of the `istiod` revision label\n that you noted in the previous step.\n\n kubectl label namespace default istio-injection- istio.io/rev=\u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e --overwrite\n\n\n You can ignore the message `\"istio-injection not found\"` in the\n output. That means that the namespace didn't previously have the\n `istio-injection` label, which you should expect in new\n installations of Cloud Service Mesh or new deployments. Because auto-injection\n behavior is undefined when a namespace has both the `istio-injection`\n and the revision label, all `kubectl label` commands in the\n Cloud Service Mesh documentation explicitly ensure that only one is set.\n\nDeploying the application\n\nNow that auto-injection is enabled on the `default` namespace, when you deploy\nthe BookInfo application's services, sidecar proxies are injected alongside each\nservice.\n\n1. On the command line on the computer where you installed Cloud Service Mesh, go to\n the root of the Cloud Service Mesh installation directory. If you need to,\n [download the installation file](/service-mesh/v1.20/docs/downloading-istioctl).\n\n2. Deploy your application to the default namespace using `kubectl`:\n\n kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml\n\n3. Confirm that the application has been deployed correctly by running the\n following commands:\n\n kubectl get services\n\n Output: \n\n ```\n NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE\n details 10.0.0.31 \u003cnone\u003e 9080/TCP 6m\n kubernetes 10.0.0.1 \u003cnone\u003e 443/TCP 7d\n productpage 10.0.0.120 \u003cnone\u003e 9080/TCP 6m\n ratings 10.0.0.15 \u003cnone\u003e 9080/TCP 6m\n reviews 10.0.0.170 \u003cnone\u003e 9080/TCP 6m\n ```\n\n and \n\n kubectl get pod\n\n Output: \n\n ```\n NAME READY STATUS RESTARTS AGE\n details-v1-1520924117-48z17 2/2 Running 0 6m\n productpage-v1-560495357-jk1lz 2/2 Running 0 6m\n ratings-v1-734492171-rnr5l 2/2 Running 0 6m\n reviews-v1-874083890-f0qf0 2/2 Running 0 6m\n reviews-v2-1343845940-b34q5 2/2 Running 0 6m\n reviews-v3-1813607990-8ch52 2/2 Running 0 6m\n ```\n4. Finally, define the ingress gateway routing for the application:\n\n kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml\n\n Output: \n\n ```\n gateway.networking.istio.io/bookinfo-gateway created\n virtualservice.networking.istio.io/bookinfo created\n ```\n\nValidating the application deployment\n\nTo see if the BookInfo application is working, you need to send traffic to\nthe ingress gateway.\n\n- If you installed Cloud Service Mesh on Google Distributed Cloud, get the external\n IP address for the ingress gateway that you\n [configured](/service-mesh/v1.20/docs/unified-install/external-ip-load-balance)\n after installing Cloud Service Mesh\n\n- If you installed Cloud Service Mesh on GKE, get the external IP\n address of the ingress gateway as follows:\n\n kubectl get service istio-ingressgateway -n istio-system\n\n Output: \n\n ```\n NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\n istio-ingressgateway LoadBalancer 10.19.247.233 35.239.7.64 80:31380/TCP,443:31390/TCP,31400:31400/TCP 27m\n ```\n\n In this example, the IP address of the ingress service is `35.239.7.64`.\n\nTrying the application\n\n1. Check that the BookInfo app is running with `curl`:\n\n curl -I http://\u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e/productpage\n\n If the response shows `200`, it means the application is working properly\n with Cloud Service Mesh.\n2. To view the BookInfo web page, enter the following address in your browser:\n\n http://\u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e/productpage\n\n If you refresh the page several times, you should see different versions of\n reviews shown in the product page, presented in a round robin style\n (red stars, black stars, no stars).\n\nNow that you have an application that is generating traffic, you can\n[explore the Cloud Service Mesh pages](/service-mesh/v1.20/docs/observability/explore-dashboard)\nin the Google Cloud console to see metrics and the other observability\nfeatures.\n\nCleaning up\n\nWhen you are finished experimenting with the Bookinfo sample, remove it from\nyour cluster.\n\n1. Uninstall Bookinfo using the following script:\n\n samples/bookinfo/platform/kube/cleanup.sh\n\n2. Confirm shutdown:\n\n kubectl get virtualservices #-- there should be no virtual services\n kubectl get destinationrules #-- there should be no destination rules\n kubectl get gateway #-- there should be no gateway\n kubectl get pods #-- the Bookinfo pods should be deleted\n\nWhat's next\n\n[Learn more about the Bookinfo sample](https://archive.istio.io/v1.26/docs/examples/bookinfo/)."]]