Skip to content

Commit 37f0e66

Browse files
committed
[zh] sync guestbook.md
1 parent 62dcee8 commit 37f0e66

File tree

1 file changed

+75
-47
lines changed
  • content/zh-cn/docs/tutorials/stateless-application

1 file changed

+75
-47
lines changed

content/zh-cn/docs/tutorials/stateless-application/guestbook.md

Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,34 @@ source: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
1414
title: "Example: Deploying PHP Guestbook application with Redis"
1515
reviewers:
1616
- ahmetb
17+
- jimangel
1718
content_type: tutorial
1819
weight: 20
1920
card:
2021
name: tutorials
2122
weight: 30
2223
title: "Stateless Example: PHP Guestbook with Redis"
2324
min-kubernetes-server-version: v1.14
25+
source: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
2426
-->
2527

2628
<!-- overview -->
2729

2830
<!--
29-
This tutorial shows you how to build and deploy a simple _(not production ready)_, multi-tier web application using Kubernetes and [Docker](https://www.docker.com/). This example consists of the following components:
31+
This tutorial shows you how to build and deploy a simple _(not production
32+
ready)_, multi-tier web application using Kubernetes and
33+
[Docker](https://www.docker.com/). This example consists of the following
34+
components:
3035
-->
3136
本教程向你展示如何使用 Kubernetes 和 [Docker](https://www.docker.com/)
32-
构建和部署一个简单的 **(非面向生产的)** 多层 web 应用程序。本例由以下组件组成:
37+
构建和部署一个简单的 **(非面向生产的)** 多层 Web 应用程序。本例由以下组件组成:
3338

3439
<!--
3540
* A single-instance [Redis](https://www.redis.io/) to store guestbook entries
3641
* Multiple web frontend instances
3742
-->
38-
3943
* 单实例 [Redis](https://www.redis.io/) 以保存留言板条目
40-
* 多个 web 前端实例
44+
* 多个 Web 前端实例
4145

4246
## {{% heading "objectives" %}}
4347

@@ -64,7 +68,7 @@ This tutorial shows you how to build and deploy a simple _(not production ready)
6468
<!--
6569
## Start up the Redis Database
6670
-->
67-
## 启动 Redis 数据库
71+
## 启动 Redis 数据库 {#start-up-the-redis-database}
6872

6973
<!--
7074
The guestbook application uses Redis to store its data.
@@ -74,7 +78,7 @@ The guestbook application uses Redis to store its data.
7478
<!--
7579
### Creating the Redis Deployment
7680
-->
77-
### 创建 Redis Deployment
81+
### 创建 Redis Deployment {#creating-the-redis-deployment}
7882

7983
<!--
8084
The manifest file, included below, specifies a Deployment controller that runs a single replica Redis Pod.
@@ -130,10 +134,13 @@ The manifest file, included below, specifies a Deployment controller that runs a
130134
<!--
131135
### Creating the Redis leader Service
132136
-->
133-
### 创建 Redis 领导者服务
137+
### 创建 Redis 领导者服务 {#creating-the-redis-leader-service}
134138

135139
<!--
136-
The guestbook application needs to communicate to the Redis to write its data. You need to apply a [Service](/docs/concepts/services-networking/service/) to proxy the traffic to the Redis Pod. A Service defines a policy to access the Pods.
140+
The guestbook application needs to communicate to the Redis to write its data.
141+
You need to apply a [Service](/docs/concepts/services-networking/service/) to
142+
proxy the traffic to the Redis Pod. A Service defines a policy to access the
143+
Pods.
137144
-->
138145
留言板应用程序需要往 Redis 中写数据。因此,需要创建
139146
[Service](/zh-cn/docs/concepts/services-networking/service/) 来转发 Redis Pod
@@ -169,34 +176,37 @@ The guestbook application needs to communicate to the Redis to write its data. Y
169176
-->
170177
响应应该与此类似:
171178

172-
```shell
179+
```
173180
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
174181
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 1m
175182
redis-leader ClusterIP 10.103.78.24 <none> 6379/TCP 16s
176183
```
177184

185+
{{< note >}}
178186
<!--
179-
This manifest file creates a Service named `redis-leader` with a set of labels that match the labels previously defined, so the Service routes network traffic to the Redis Pod.
187+
This manifest file creates a Service named `redis-leader` with a set of labels
188+
that match the labels previously defined, so the Service routes network
189+
traffic to the Redis Pod.
180190
-->
181-
{{< note >}}
182191
这个清单文件创建了一个名为 `redis-leader` 的 Service,其中包含一组
183192
与前面定义的标签匹配的标签,因此服务将网络流量路由到 Redis Pod 上。
184193
{{< /note >}}
185194

186195
<!--
187196
### Set up Redis followers
188197
189-
Although the Redis leader is a single Pod, you can make it highly available and meet traffic demands by adding a few Redis followers, or replicas.
198+
Although the Redis leader is a single Pod, you can make it highly available
199+
and meet traffic demands by adding a few Redis followers, or replicas.
190200
-->
191-
### 设置 Redis 跟随者
201+
### 设置 Redis 跟随者 {#set-up-redis-followers}
192202

193203
尽管 Redis 领导者只有一个 Pod,你可以通过添加若干 Redis 跟随者来将其配置为高可用状态,
194204
以满足流量需求。
195205

196206
{{< codenew file="application/guestbook/redis-follower-deployment.yaml" >}}
197207

198208
<!--
199-
1. Apply the Redis Service from the following `redis-follower-deployment.yaml` file:
209+
1. Apply the Redis Deployment from the following `redis-follower-deployment.yaml` file:
200210
-->
201211
1. 应用下面的 `redis-follower-deployment.yaml` 文件创建 Redis Deployment:
202212

@@ -233,9 +243,11 @@ Although the Redis leader is a single Pod, you can make it highly available and
233243
<!--
234244
### Creating the Redis follower service
235245
236-
The guestbook application needs to communicate with the Redis followers to read data. To make the Redis followers discoverable, you must set up another [Service](/docs/concepts/services-networking/service/).
246+
The guestbook application needs to communicate with the Redis followers to
247+
read data. To make the Redis followers discoverable, you must set up another
248+
[Service](/docs/concepts/services-networking/service/).
237249
-->
238-
### 创建 Redis 跟随者服务
250+
### 创建 Redis 跟随者服务 {#creating-the-redis-follower-service}
239251

240252
Guestbook 应用需要与 Redis 跟随者通信以读取数据。
241253
为了让 Redis 跟随者可被发现,你必须创建另一个
@@ -280,23 +292,30 @@ Guestbook 应用需要与 Redis 跟随者通信以读取数据。
280292

281293
{{< note >}}
282294
<!--
283-
This manifest file creates a Service named `redis-follower` with a set of labels that match the labels previously defined, so the Service routes network traffic to the Redis Pod.
295+
This manifest file creates a Service named `redis-follower` with a set of
296+
labels that match the labels previously defined, so the Service routes network
297+
traffic to the Redis Pod.
284298
-->
285299
清单文件创建了一个名为 `redis-follower` 的 Service,该 Service
286-
具有一些与之前所定义的标签相匹配的标签,因此该 Service 能够将网络流量
287-
路由到 Redis Pod 之上。
300+
具有一些与之前所定义的标签相匹配的标签,因此该 Service 能够将网络流量路由到
301+
Redis Pod 之上。
288302
{{< /note >}}
289303

290304

291305
<!--
292306
## Set up and Expose the Guestbook Frontend
293307
-->
294-
## 设置并公开留言板前端
308+
## 设置并公开留言板前端 {#set-up-and-expose-the-guestbook-frontend}
295309

296310
<!--
297-
Now that you have the Redis storage of your guestbook up and running, start the guestbook web servers. Like the Redis followers, the frontend is deployed using a Kubernetes Deployment.
311+
Now that you have the Redis storage of your guestbook up and running, start
312+
the guestbook web servers. Like the Redis followers, the frontend is deployed
313+
using a Kubernetes Deployment.
298314
299-
The guestbook app uses a PHP frontend. It is configured to communicate with either the Redis follower or leader Services, depending on whether the request is a read or a write. The frontend exposes a JSON interface, and serves a jQuery-Ajax-based UX.
315+
The guestbook app uses a PHP frontend. It is configured to communicate with
316+
either the Redis follower or leader Services, depending on whether the request
317+
is a read or a write. The frontend exposes a JSON interface, and serves a
318+
jQuery-Ajax-based UX.
300319
-->
301320
现在你有了一个为 Guestbook 应用配置的 Redis 存储处于运行状态,
302321
接下来可以启动 Guestbook 的 Web 服务器了。
@@ -309,7 +328,7 @@ Guestbook 应用使用 PHP 前端。该前端被配置成与后端的 Redis 跟
309328
<!--
310329
### Creating the Guestbook Frontend Deployment
311330
-->
312-
### 创建 Guestbook 前端 Deployment
331+
### 创建 Guestbook 前端 Deployment {#creating-the-guestbook-frontend-deployment}
313332

314333
{{< codenew file="application/guestbook/frontend-deployment.yaml" >}}
315334

@@ -351,31 +370,37 @@ Guestbook 应用使用 PHP 前端。该前端被配置成与后端的 Redis 跟
351370
<!--
352371
### Creating the Frontend Service
353372
-->
354-
### 创建前端服务
373+
### 创建前端服务 {#creating-the-frontend-service}
355374

356375
<!--
357-
The `Redis` Services you applied is only accessible within the Kubernetes cluster because the default type for a Service is [ClusterIP](/docs/concepts/services-networking/service/#publishing-services-service-types). `ClusterIP` provides a single IP address for the set of Pods the Service is pointing to. This IP address is accessible only within the cluster.
376+
The `Redis` Services you applied is only accessible within the Kubernetes
377+
cluster because the default type for a Service is
378+
[ClusterIP](/docs/concepts/services-networking/service/#publishing-services-service-types).
379+
`ClusterIP` provides a single IP address for the set of Pods the Service is
380+
pointing to. This IP address is accessible only within the cluster.
358381
-->
359382
应用的 `Redis` 服务只能在 Kubernetes 集群中访问,因为服务的默认类型是
360383
[ClusterIP](/zh-cn/docs/concepts/services-networking/service/#publishing-services-service-types)
361384
`ClusterIP` 为服务指向的 Pod 集提供一个 IP 地址。这个 IP 地址只能在集群中访问。
362385

363386
<!--
364-
If you want guests to be able to access your guestbook, you must configure the
365-
frontend Service to be externally visible, so a client can request the Service
387+
If you want guests to be able to access your guestbook, you must configure the
388+
frontend Service to be externally visible, so a client can request the Service
366389
from outside the Kubernetes cluster. However a Kubernetes user can use
367-
`kubectl port-forward` to access the service even though it uses a
390+
`kubectl port-forward` to access the service even though it uses a
368391
`ClusterIP`.
369392
-->
370393
如果你希望访客能够访问你的 Guestbook,你必须将前端服务配置为外部可见的,
371394
以便客户端可以从 Kubernetes 集群之外请求服务。
372395
然而即便使用了 `ClusterIP`,Kubernetes 用户仍可以通过
373396
`kubectl port-forward` 访问服务。
374397

398+
{{< note >}}
375399
<!--
376-
Some cloud providers, like Google Compute Engine or Google Kubernetes Engine, support external load balancers. If your cloud provider supports load balancers and you want to use it, uncomment `type: LoadBalancer`.
400+
Some cloud providers, like Google Compute Engine or Google Kubernetes Engine,
401+
support external load balancers. If your cloud provider supports load
402+
balancers and you want to use it, uncomment `type: LoadBalancer`.
377403
-->
378-
{{< note >}}
379404
一些云提供商,如 Google Compute Engine 或 Google Kubernetes Engine,
380405
支持外部负载均衡器。如果你的云提供商支持负载均衡器,并且你希望使用它,
381406
只需取消注释 `type: LoadBalancer`
@@ -422,7 +447,7 @@ Some cloud providers, like Google Compute Engine or Google Kubernetes Engine, su
422447
<!--
423448
### Viewing the Frontend Service via `kubectl port-forward`
424449
-->
425-
### 通过 `kubectl port-forward` 查看前端服务
450+
### 通过 `kubectl port-forward` 查看前端服务 {#viewing-the-frontend-service-via-kubectl-port-forward}
426451

427452
<!--
428453
1. Run the following command to forward port `8080` on your local machine to port `80` on the service.
@@ -446,19 +471,18 @@ Some cloud providers, like Google Compute Engine or Google Kubernetes Engine, su
446471
<!--
447472
1. load the page [http://localhost:8080](http://localhost:8080) in your browser to view your guestbook.
448473
-->
449-
2. 在浏览器中加载 [http://localhost:8080](http://localhost:8080)
450-
页面以查看 Guestbook。
474+
2. 在浏览器中加载 [http://localhost:8080](http://localhost:8080) 页面以查看 Guestbook。
451475

452476
<!--
453477
### Viewing the Frontend Service via `LoadBalancer`
454478
-->
455-
### 通过 `LoadBalancer` 查看前端服务
479+
### 通过 `LoadBalancer` 查看前端服务 {#viewing-the-frontend-service-via-loadbalancer}
456480

457481
<!--
458-
If you deployed the `frontend-service.yaml` manifest with type: `LoadBalancer` you need to find the IP address to view your Guestbook.
482+
If you deployed the `frontend-service.yaml` manifest with type: `LoadBalancer`
483+
you need to find the IP address to view your Guestbook.
459484
-->
460-
如果你部署了 `frontend-service.yaml`,需要找到用来查看 Guestbook 的
461-
IP 地址。
485+
如果你部署了 `frontend-service.yaml`,需要找到用来查看 Guestbook 的 IP 地址。
462486

463487
<!--
464488
1. Run the following command to get the IP address for the frontend Service.
@@ -486,20 +510,23 @@ IP 地址。
486510

487511
{{< note >}}
488512
<!--
489-
Try adding some guestbook entries by typing in a message, and clicking Submit. The message you typed appears in the frontend. This message indicates that data is successfully added to Redis through the Services you created earlier.
513+
Try adding some guestbook entries by typing in a message, and clicking Submit.
514+
The message you typed appears in the frontend. This message indicates that
515+
data is successfully added to Redis through the Services you created earlier.
490516
-->
491517
尝试通过输入消息并点击 Submit 来添加一些留言板条目。
492-
你所输入的消息会在前端显示。这一消息表明数据被通过你
493-
之前所创建的 Service 添加到 Redis 存储中。
518+
你所输入的消息会在前端显示。这一消息表明数据被通过你之前所创建的
519+
Service 添加到 Redis 存储中。
494520
{{< /note >}}
495521

496522
<!--
497523
## Scale the Web Frontend
498524
-->
499-
## 扩展 Web 前端
525+
## 扩展 Web 前端 {#scale-the-web-frontend}
500526

501527
<!--
502-
You can scale up or down as needed because your servers are defined as a Service that uses a Deployment controller.
528+
You can scale up or down as needed because your servers are defined as a
529+
Service that uses a Deployment controller.
503530
-->
504531
你可以根据需要执行伸缩操作,这是因为服务器本身被定义为使用一个
505532
Deployment 控制器的 Service。
@@ -574,15 +601,16 @@ Deployment 控制器的 Service。
574601
## {{% heading "cleanup" %}}
575602

576603
<!--
577-
Deleting the Deployments and Services also deletes any running Pods. Use labels to delete multiple resources with one command.
604+
Deleting the Deployments and Services also deletes any running Pods. Use
605+
labels to delete multiple resources with one command.
578606
-->
579607
删除 Deployments 和服务还会删除正在运行的 Pod。
580608
使用标签用一个命令删除多个资源。
581609

582610
<!--
583611
1. Run the following commands to delete all Pods, Deployments, and Services.
584612
-->
585-
1. 运行以下命令以删除所有 Pod,DeploymentsServices
613+
1. 运行以下命令以删除所有 Pod、DeploymentService
586614

587615
```shell
588616
kubectl delete deployment -l app=redis
@@ -602,6 +630,7 @@ Deleting the Deployments and Services also deletes any running Pods. Use labels
602630
deployment.apps "frontend" deleted
603631
service "frontend" deleted
604632
```
633+
605634
<!--
606635
1. Query the list of Pods to verify that no Pods are running:
607636
-->
@@ -617,7 +646,6 @@ Deleting the Deployments and Services also deletes any running Pods. Use labels
617646
响应应该是:
618647

619648
```
620-
621649
No resources found in default namespace.
622650
```
623651

@@ -626,11 +654,11 @@ Deleting the Deployments and Services also deletes any running Pods. Use labels
626654
<!--
627655
* Complete the [Kubernetes Basics](/docs/tutorials/kubernetes-basics/) Interactive Tutorials
628656
* Use Kubernetes to create a blog using [Persistent Volumes for MySQL and Wordpress](/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/#visit-your-new-wordpress-blog)
629-
* Read more about [connecting applications](/docs/concepts/services-networking/connect-applications-service/)
657+
* Read more about [connecting applications with services](/docs/tutorials/services/connect-applications-service/)
630658
* Read more about [Managing Resources](/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively)
631659
-->
632660
* 完成 [Kubernetes 基础](/zh-cn/docs/tutorials/kubernetes-basics/) 交互式教程
633661
* 使用 Kubernetes 创建一个博客,使用
634662
[MySQL 和 Wordpress 的持久卷](/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/#visit-your-new-wordpress-blog)
635-
* 进一步阅读[连接应用程序](/zh-cn/docs/concepts/services-networking/connect-applications-service/)
663+
* 进一步阅读[使用 Service 连接到应用](/zh-cn/docs/tutorials/services/connect-applications-service/)
636664
* 进一步阅读[管理资源](/zh-cn/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively)

0 commit comments

Comments
 (0)