zh-translation:content/zh/docs/examples/virtual-machines/bookinfo/index.md (#6107)

This commit is contained in:
chentanjun 2019-12-17 16:12:50 +08:00 committed by Istio Automation
parent 300d1aaca0
commit 9b434b4eff
1 changed files with 29 additions and 35 deletions

View File

@ -1,7 +1,6 @@
---
title: Bookinfo with a Virtual Machine
description: Run the Bookinfo application with a MySQL service running on a virtual
machine within your mesh.
title: 在虚拟机上部署 Bookinfo 应用程序
description: 使用在网格内的虚拟机上运行的 MySQL 服务运行 Bookinfo 应用程序。
weight: 60
keywords:
- virtual-machine
@ -12,17 +11,15 @@ aliases:
- /zh/docs/examples/vm-bookinfo
---
This example deploys the Bookinfo application across Kubernetes with one
service running on a virtual machine (VM), and illustrates how to control
this infrastructure as a single mesh.
本示例通过在虚拟机VM上运行一项服务来跨 Kubernetes 部署 Bookinfo 应用程序,并说明了如何以单个网格的形式控制此基础架构。
{{< warning >}}
This example is still under development and only tested on Google Cloud Platform.
On IBM Cloud or other platforms where overlay network of Pods is isolated from VM network,
VMs cannot initiate any direct communication to Kubernetes Pods even when using Istio.
此示例仍在开发中,仅在 Google Cloud Platform 上进行了测试。
在 Pod 的覆盖网络与 VM 网络隔离的 IBM Cloud 或其他平台上,
即使使用 Istio虚拟机也无法与 Kubernetes Pod 进行任何直接通信活动。
{{< /warning >}}
## Overview
## 概述{#overview}
{{< image width="80%" link="./vm-bookinfo.svg" caption="Bookinfo running on VMs" >}}
@ -30,25 +27,24 @@ VMs cannot initiate any direct communication to Kubernetes Pods even when using
https://docs.google.com/drawings/d/1G1592HlOVgtbsIqxJnmMzvy6ejIdhajCosxF1LbvspI/edit
-->
## Before you begin
## 开始之前{#before-you-begin}
- Setup Istio by following the instructions in the
[Installation guide](/zh/docs/setup/getting-started/).
- 按照[安装指南](/zh/docs/setup/getting-started/) 中的说明安装 Istio。
- Deploy the [Bookinfo](/zh/docs/examples/bookinfo/) sample application (in the `bookinfo` namespace).
- 部署 [Bookinfo](/zh/docs/examples/bookinfo/) 示例应用程序(在 `bookinfo` 命名空间中)。
- Create a VM named 'vm-1' in the same project as the Istio cluster, and [join the mesh](/zh/docs/examples/virtual-machines/single-network/).
- 在与 Istio 集群相同的项目中创建一个名为 'vm-1' 的虚拟机,然后[加入网格](/zh/docs/examples/virtual-machines/single-network/)。
## Running MySQL on the VM
## 在 VM 上运行 MySQL{#running-MySQL-on-the-VM}
We will first install MySQL on the VM, and configure it as a backend for the ratings service.
我们将首先在虚拟机上安装 MySQL并将其配置为 ratings 服务的后端。
On the VM:
在虚拟机上:
{{< text bash >}}
$ sudo apt-get update && sudo apt-get install -y mariadb-server
$ sudo mysql
# Grant access to root
# 授予 root 的访问权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
quit;
{{< /text >}}
@ -57,16 +53,15 @@ quit;
$ sudo systemctl restart mysql
{{< /text >}}
You can find details of configuring MySQL at [Mysql](https://mariadb.com/kb/en/library/download/).
您可以在 [Mysql](https://mariadb.com/kb/en/library/download/) 中找到配置 MySQL 的详细信息。
On the VM add ratings database to mysql.
在虚拟机上,将 ratings 数据库添加到 mysql 中。
{{< text bash >}}
$ curl -q {{< github_file >}}/samples/bookinfo/src/mysql/mysqldb-init.sql | mysql -u root -ppassword
{{< /text >}}
To make it easy to visually inspect the difference in the output of the Bookinfo application, you can change the ratings that are generated by using the
following commands to inspect the ratings:
为了便于直观地检查 Bookinfo 应用程序输出中的差异,您可以使用以下命令来更改所生成的 ratings 数据库并且检查它:
{{< text bash >}}
$ mysql -u root -password test -e "select * from ratings;"
@ -78,7 +73,7 @@ $ mysql -u root -password test -e "select * from ratings;"
+----------+--------+
{{< /text >}}
and to change the ratings
更改 ratings 数据库:
{{< text bash >}}
$ mysql -u root -ppassword test -e "update ratings set rating=1 where reviewid=1;select * from ratings;"
@ -90,17 +85,17 @@ $ mysql -u root -ppassword test -e "update ratings set rating=1 where reviewid=
+----------+--------+
{{< /text >}}
## Find out the IP address of the VM that will be used to add it to the mesh
## 找出将用于添加到网格中的虚拟机的 IP 地址{#find-out-the-IP-address-of-the-VM-that-will-be-used-to-add-it-to-the-mesh}
On the VM:
在虚拟机上:
{{< text bash >}}
$ hostname -I
{{< /text >}}
## Registering the mysql service with the mesh
## 向网格中注册 mysql 服务{#registering-the-mysql-service-with-the-mesh}
On a host with access to [`istioctl`](/zh/docs/reference/commands/istioctl) commands, register the VM and mysql db service
在可以访问 [`istioctl`](/zh/docs/reference/commands/istioctl) 命令的主机上,注册虚拟机和 mysql 数据库服务。
{{< text bash >}}
$ istioctl register -n vm mysqldb <ip-address-of-vm> 3306
@ -112,23 +107,22 @@ I1108 20:17:54.886657 40419 register.go:180] No pre existing exact matching po
I1108 20:17:54.959744 40419 register.go:191] Successfully updated mysqldb, now with 1 endpoints
{{< /text >}}
Note that the 'mysqldb' virtual machine does not need and should not have special Kubernetes privileges.
请注意,'mysqldb' 虚拟机不需要也不应具有特殊的 Kubernetes 特权。
## Using the mysql service
## 使用 mysql 服务{#using-the-mysql-service}
The ratings service in Bookinfo will use the DB on the machine. To verify that it works, create version 2 of the ratings service that uses the mysql db on the VM. Then specify route rules that force the review service to use the ratings version 2.
Bookinfo 中的 ratings 服务将使用该虚拟机上的数据库。为了验证它是否正常工作,请在虚拟机上创建使用 mysql 数据库的 ratings 服务第二个版本。然后指定路由规则,用于强制 review 服务使用 ratings 服务的第二个版本。
{{< text bash >}}
$ istioctl kube-inject -n bookinfo -f @samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql-vm.yaml@ | kubectl apply -n bookinfo -f -
{{< /text >}}
Create route rules that will force Bookinfo to use the ratings back end:
创建将强制 Bookinfo 使用 ratings 后端的路由规则:
{{< text bash >}}
$ kubectl apply -n bookinfo -f @samples/bookinfo/networking/virtual-service-ratings-mysql-vm.yaml@
{{< /text >}}
You can verify the output of the Bookinfo application is showing 1 star from Reviewer1 and 4 stars from Reviewer2 or change the ratings on your VM and see the
results.
您可以验证 Bookinfo 应用程序的输出显示的是 Reviewer1 的 1 个星,还是 Reviewer2 的 4 个星,或者更改虚拟机的 ratings 服务并查看结果。
You can also find some troubleshooting and other information in the [RawVM MySQL]({{< github_blob >}}/samples/rawvm/README.md) document in the meantime.
同时,您还可以在 [RawVM MySQL]({{< github_blob >}}/samples/rawvm/README.md) 文档中找到一些疑难解答和其他信息。