Cloud Service Mesh dan Traffic Director kini bergabung menjadi Cloud Service Mesh. Untuk mengetahui informasi selengkapnya, lihat ringkasan Cloud Service Mesh.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Men-deploy contoh Bookinfo
Halaman ini menjelaskan cara men-deploy aplikasi contoh untuk mendemonstrasikan
Cloud Service Mesh. Jika Anda belum melakukan aktivasi ke Cloud Service Mesh, lihat
Panduan aktivasi.
Beberapa contoh aplikasi disertakan dengan penginstalan Cloud Service Mesh. Panduan
ini akan memandu Anda men-deploy
contoh
BookInfo. Ini adalah aplikasi toko buku tiruan sederhana yang terdiri dari empat layanan
yang menyediakan halaman produk web, detail buku, ulasan (dengan beberapa versi
layanan ulasan), dan rating—semuanya dikelola menggunakan Cloud Service Mesh. Anda dapat menemukan kode sumber dan semua file lain yang digunakan dalam contoh ini di direktori penginstalan Cloud Service Mesh di samples/bookinfo.
Jika Anda adalah pengguna lama dengan platform kontrol Istiod Terkelola:
Sebaiknya gunakan injeksi default, tetapi injeksi berbasis revisi
didukung. Gunakan petunjuk berikut:
Jalankan perintah berikut untuk menemukan saluran rilis yang tersedia:
kubectl-nistio-systemgetcontrolplanerevision
Outputnya mirip dengan hal berikut ini:
NAME AGE
asm-managed-rapid 6d7h
CATATAN: Jika dua revisi bidang kontrol muncul dalam daftar di atas, hapus salah satunya. Memiliki beberapa saluran bidang kontrol di cluster tidak didukung.
Dalam output, nilai di kolom NAME adalah label revisi yang sesuai dengan saluran rilis yang tersedia untuk versi Cloud Service Mesh.
Setelah injeksi otomatis diaktifkan di namespace default, saat Anda men-deploy
layanan aplikasi BookInfo, proxy sidecar akan dimasukkan bersama setiap
layanan.
Di command line pada komputer tempat Anda menginstal Cloud Service Mesh, buka
root direktori penginstalan Cloud Service Mesh. Jika perlu,
download file penginstalan Dalam cluster,
yang menyertakan aplikasi contoh bookinfo, lalu ekstrak.
Deploy aplikasi Anda ke namespace default menggunakan kubectl:
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created
Memvalidasi deployment aplikasi
Untuk melihat apakah aplikasi BookInfo berfungsi, Anda perlu mengirim traffic ke gateway masuk.
Jika Anda menginstal Cloud Service Mesh di Google Distributed Cloud (khusus software) untuk VMware, dapatkan alamat IP eksternal untuk gateway masuk yang Anda konfigurasi setelah menginstal Cloud Service Mesh
Jika Anda menginstal Cloud Service Mesh di GKE, dapatkan alamat IP eksternal gateway masuk sebagai berikut:
kubectl get service istio-ingressgateway -n istio-system
Output:
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
Dalam contoh ini, alamat IP layanan ingress adalah 35.239.7.64.
Mencoba aplikasi
Pastikan aplikasi BookInfo berjalan dengan curl:
curl -I http://EXTERNAL_IP/productpage
Jika respons menampilkan 200, artinya aplikasi berfungsi dengan benar
dengan Cloud Service Mesh.
Untuk melihat halaman web BookInfo, masukkan alamat berikut di browser Anda:
http://EXTERNAL_IP/productpage
Jika memuat ulang halaman beberapa kali, Anda akan melihat versi ulasan
yang berbeda yang ditampilkan di halaman produk, yang disajikan dalam gaya bergilir
(bintang merah, bintang hitam, tanpa bintang).
Setelah memiliki aplikasi yang menghasilkan traffic, Anda dapat
menjelajahi halaman Cloud Service Mesh
di Google Cloud konsol untuk melihat metrik dan fitur observabilitas
lainnya.
Pembersihan
Setelah selesai bereksperimen dengan contoh Bookinfo, hapus dari cluster Anda.
Uninstal Bookinfo menggunakan skrip berikut:
samples/bookinfo/platform/kube/cleanup.sh
Konfirmasi penonaktifan:
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
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 UTC."],[],[],null,["# Deploying the Bookinfo sample\n=============================\n\nThis page explains how to deploy a sample application to demonstrate\nCloud Service Mesh. If you haven't onboarded to Cloud Service Mesh, see the\n[Onboarding guide](/service-mesh/docs/onboarding/provision-control-plane).\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-------------------------------\n\n1. Enable the namespace for injection. The steps depend on your [control plane implementation](/service-mesh/docs/check-control-plane-implementation).\n\n ### Managed (TD)\n\n 1. Apply the default injection label to the namespace:\n\n kubectl label namespace default \\\n istio.io/rev- istio-injection=enabled --overwrite\n\n ### Managed (Istiod)\n\n **Recommended:** Run the following command to apply the default injection label to the namespace: \n\n kubectl label namespace default \\\n istio.io/rev- istio-injection=enabled --overwrite\n\n **If you are an existing user with the Managed Istiod control plane:**\n We recommend that you use default injection, but revision-based injection is\n supported. Use the following instructions:\n 1. Run the following command to locate the available release channels:\n\n kubectl -n istio-system get controlplanerevision\n\n The output is similar to the following: \n\n NAME AGE\n asm-managed-rapid 6d7h\n\n NOTE: If two control plane revisions appear in the list above, remove one. Having multiple control plane channels in the cluster is not supported.\n\n In the output, the value under the `NAME` column is the revision label that corresponds to the available [release channel](/service-mesh/docs/managed/select-a-release-channel#anthos_service_mesh_versions_per_channel) for the Cloud Service Mesh version.\n 2. Apply the revision label to the namespace:\n\n kubectl label namespace default \\\n istio-injection- istio.io/rev=\u003cvar translate=\"no\"\u003eREVISION_LABEL\u003c/var\u003e --overwrite\n\n ### In-cluster\n\n **Recommended:** Run the following command to apply the default injection label to the namespace: \n\n kubectl label namespace default \\\n istio.io/rev- istio-injection=enabled --overwrite\n\n **We recommend that you use default injection, but revision-based injection is supported:**\n Use the following instructions:\n 1. Use the following command to locate the revision label on `istiod`:\n\n kubectl get deploy -n istio-system -l app=istiod -o \\\n jsonpath={.items[*].metadata.labels.'istio\\.io\\/rev'}'{\"\\n\"}'\n\n 2. Apply the revision label to the namespace. In the following command,\n \u003cvar translate=\"no\"\u003eREVISION_LABEL\u003c/var\u003e is the value of the `istiod` revision\n label that you noted in the previous step.\n\n kubectl label namespace default \\\n istio-injection- istio.io/rev=\u003cvar translate=\"no\"\u003eREVISION_LABEL\u003c/var\u003e --overwrite\n\nDeploying the application\n-------------------------\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 In-cluster installation file](/service-mesh/docs/downloading-istioctl#in-cluster-control-plane),\n which includes the bookinfo sample application, and extract it.\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-------------------------------------\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 (software only) for VMware, get the external\n IP address for the ingress gateway that you\n [configured](/service-mesh/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\n### Trying 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/docs/observability-overview)\nin the Google Cloud console to see metrics and the other observability\nfeatures.\n\nCleaning up\n-----------\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\n[Learn more about the Bookinfo sample](https://archive.istio.io/v1.26/docs/examples/bookinfo/)."]]