You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
137
144
-->
138
145
留言板应用程序需要往 Redis 中写数据。因此,需要创建
139
146
[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
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.
180
190
-->
181
-
{{< note >}}
182
191
这个清单文件创建了一个名为 `redis-leader` 的 Service,其中包含一组
183
192
与前面定义的标签匹配的标签,因此服务将网络流量路由到 Redis Pod 上。
184
193
{{< /note >}}
185
194
186
195
<!--
187
196
### Set up Redis followers
188
197
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.
@@ -233,9 +243,11 @@ Although the Redis leader is a single Pod, you can make it highly available and
233
243
<!--
234
244
### Creating the Redis follower service
235
245
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
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
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.
298
314
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
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
`ClusterIP` 为服务指向的 Pod 集提供一个 IP 地址。这个 IP 地址只能在集群中访问。
362
385
363
386
<!--
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
366
389
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
368
391
`ClusterIP`.
369
392
-->
370
393
如果你希望访客能够访问你的 Guestbook,你必须将前端服务配置为外部可见的,
371
394
以便客户端可以从 Kubernetes 集群之外请求服务。
372
395
然而即便使用了 `ClusterIP`,Kubernetes 用户仍可以通过
373
396
`kubectl port-forward` 访问服务。
374
397
398
+
{{< note >}}
375
399
<!--
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`.
377
403
-->
378
-
{{< note >}}
379
404
一些云提供商,如 Google Compute Engine 或 Google Kubernetes Engine,
380
405
支持外部负载均衡器。如果你的云提供商支持负载均衡器,并且你希望使用它,
381
406
只需取消注释 `type: LoadBalancer`。
@@ -422,7 +447,7 @@ Some cloud providers, like Google Compute Engine or Google Kubernetes Engine, su
422
447
<!--
423
448
### Viewing the Frontend Service via `kubectl port-forward`
如果你部署了 `frontend-service.yaml`,需要找到用来查看 Guestbook 的 IP 地址。
462
486
463
487
<!--
464
488
1. Run the following command to get the IP address for the frontend Service.
@@ -486,20 +510,23 @@ IP 地址。
486
510
487
511
{{< note >}}
488
512
<!--
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.
490
516
-->
491
517
尝试通过输入消息并点击 Submit 来添加一些留言板条目。
492
-
你所输入的消息会在前端显示。这一消息表明数据被通过你
493
-
之前所创建的 Service 添加到 Redis 存储中。
518
+
你所输入的消息会在前端显示。这一消息表明数据被通过你之前所创建的
519
+
Service 添加到 Redis 存储中。
494
520
{{< /note >}}
495
521
496
522
<!--
497
523
## Scale the Web Frontend
498
524
-->
499
-
## 扩展 Web 前端
525
+
## 扩展 Web 前端 {#scale-the-web-frontend}
500
526
501
527
<!--
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.
503
530
-->
504
531
你可以根据需要执行伸缩操作,这是因为服务器本身被定义为使用一个
505
532
Deployment 控制器的 Service。
@@ -574,15 +601,16 @@ Deployment 控制器的 Service。
574
601
## {{% heading "cleanup" %}}
575
602
576
603
<!--
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.
578
606
-->
579
607
删除 Deployments 和服务还会删除正在运行的 Pod。
580
608
使用标签用一个命令删除多个资源。
581
609
582
610
<!--
583
611
1. Run the following commands to delete all Pods, Deployments, and Services.
584
612
-->
585
-
1. 运行以下命令以删除所有 Pod,Deployments 和 Services。
613
+
1. 运行以下命令以删除所有 Pod、Deployment 和 Service。
586
614
587
615
```shell
588
616
kubectl delete deployment -l app=redis
@@ -602,6 +630,7 @@ Deleting the Deployments and Services also deletes any running Pods. Use labels
602
630
deployment.apps "frontend" deleted
603
631
service "frontend" deleted
604
632
```
633
+
605
634
<!--
606
635
1. Query the list of Pods to verify that no Pods are running:
607
636
-->
@@ -617,7 +646,6 @@ Deleting the Deployments and Services also deletes any running Pods. Use labels
617
646
响应应该是:
618
647
619
648
```
620
-
621
649
No resources found in default namespace.
622
650
```
623
651
@@ -626,11 +654,11 @@ Deleting the Deployments and Services also deletes any running Pods. Use labels
626
654
<!--
627
655
* Complete the [Kubernetes Basics](/docs/tutorials/kubernetes-basics/) Interactive Tutorials
628
656
* 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/)
630
658
* Read more about [Managing Resources](/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively)
0 commit comments