Skip to content

Commit ccfc65b

Browse files
committed
[zh] resync page mysql-wordpress-persistent-volume
1 parent 263bf7f commit ccfc65b

File tree

1 file changed

+73
-39
lines changed

1 file changed

+73
-39
lines changed

content/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md

Lines changed: 73 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,28 @@ reviewers:
1313
- ahmetb
1414
content_type: tutorial
1515
weight: 20
16-
card:
16+
card:
1717
name: tutorials
1818
weight: 40
1919
title: "Stateful Example: Wordpress with Persistent Volumes"
2020
-->
2121
<!-- overview -->
2222

2323
<!--
24-
This tutorial shows you how to deploy a WordPress site and a MySQL database using Minikube. Both applications use PersistentVolumes and PersistentVolumeClaims to store data.
24+
This tutorial shows you how to deploy a WordPress site and a MySQL database using
25+
Minikube. Both applications use PersistentVolumes and PersistentVolumeClaims to store data.
2526
-->
2627
本示例描述了如何通过 Minikube 在 Kubernetes 上安装 WordPress 和 MySQL。
2728
这两个应用都使用 PersistentVolumes 和 PersistentVolumeClaims 保存数据。
2829

2930
<!--
30-
A [PersistentVolume](/docs/concepts/storage/persistent-volumes/)(PV)is a piece of storage in the cluster that has been manually provisioned by an administrator, or dynamically provisioned by Kubernetes using a [StorageClass](/docs/concepts/storage/storage-classes). A [PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)(PVC)is a request for storage by a user that can be fulfilled by a PV. PersistentVolumes and PersistentVolumeClaims are independent from Pod lifecycles and preserve data through restarting, rescheduling, and even deleting Pods.
31+
A [PersistentVolume](/docs/concepts/storage/persistent-volumes/) (PV) is a piece
32+
of storage in the cluster that has been manually provisioned by an administrator,
33+
or dynamically provisioned by Kubernetes using a [StorageClass](/docs/concepts/storage/storage-classes).
34+
A [PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) (PVC)
35+
is a request for storage by a user that can be fulfilled by a PV. PersistentVolumes and
36+
PersistentVolumeClaims are independent from Pod lifecycles and preserve data through
37+
restarting, rescheduling, and even deleting Pods.
3138
-->
3239
[PersistentVolume](/zh-cn/docs/concepts/storage/persistent-volumes/)(PV)是在集群里由管理员手动制备或
3340
Kubernetes 通过 [StorageClass](/zh-cn/docs/concepts/storage/storage-classes) 动态制备的一块存储。
@@ -38,7 +45,10 @@ PersistentVolumes 和 PersistentVolumeClaims 独立于 Pod 生命周期而存在
3845

3946
{{< warning >}}
4047
<!--
41-
This deployment is not suitable for production use cases, as it uses single instance WordPress and MySQL Pods. Consider using [WordPress Helm Chart](https://github.com/bitnami/charts/tree/master/bitnami/wordpress) to deploy WordPress in production.
48+
This deployment is not suitable for production use cases, as it uses single instance
49+
WordPress and MySQL Pods. Consider using
50+
[WordPress Helm Chart](https://github.com/bitnami/charts/tree/master/bitnami/wordpress)
51+
to deploy WordPress in production.
4252
-->
4353
这种部署并不适合生产场景,因为它使用的是单实例 WordPress 和 MySQL Pod。
4454
在生产场景中,请考虑使用 [WordPress Helm Chart](https://github.com/bitnami/charts/tree/master/bitnami/wordpress)
@@ -47,7 +57,10 @@ This deployment is not suitable for production use cases, as it uses single inst
4757

4858
{{< note >}}
4959
<!--
50-
The files provided in this tutorial are using GA Deployment APIs and are specific to kubernetes version 1.9 and later. If you wish to use this tutorial with an earlier version of Kubernetes, please update the API version appropriately, or reference earlier versions of this tutorial.
60+
The files provided in this tutorial are using GA Deployment APIs and are specific
61+
to kubernetes version 1.9 and later. If you wish to use this tutorial with an earlier
62+
version of Kubernetes, please update the API version appropriately, or reference
63+
earlier versions of this tutorial.
5164
-->
5265
本教程中提供的文件使用 GA Deployment API,并且特定于 kubernetes 1.9 或更高版本。
5366
如果你希望将本教程与 Kubernetes 的早期版本一起使用,请相应地更新 API 版本,或参考本教程的早期版本。
@@ -100,11 +113,16 @@ Download the following configuration files:
100113
-->
101114
## 创建 PersistentVolumeClaims 和 PersistentVolumes
102115

103-
<!-- MySQL and Wordpress each require a PersistentVolume to store data. Their PersistentVolumeClaims will be created at the deployment step.
116+
<!--
117+
MySQL and Wordpress each require a PersistentVolume to store data.
118+
Their PersistentVolumeClaims will be created at the deployment step.
104119
105-
Many cluster environments have a default StorageClass installed. When a StorageClass is not specified in the PersistentVolumeClaim, the cluster's default StorageClass is used instead.
120+
Many cluster environments have a default StorageClass installed.
121+
When a StorageClass is not specified in the PersistentVolumeClaim,
122+
the cluster's default StorageClass is used instead.
106123
107-
When a PersistentVolumeClaim is created, a PersistentVolume is dynamically provisioned based on the StorageClass configuration.
124+
When a PersistentVolumeClaim is created, a PersistentVolume is dynamically
125+
provisioned based on the StorageClass configuration.
108126
-->
109127
MySQL 和 Wordpress 都需要一个 PersistentVolume 来存储数据。
110128
它们的 PersistentVolumeClaims 将在部署步骤中创建。
@@ -116,7 +134,11 @@ MySQL 和 Wordpress 都需要一个 PersistentVolume 来存储数据。
116134

117135
{{< warning >}}
118136
<!--
119-
In local clusters, the default StorageClass uses the `hostPath` provisioner. `hostPath` volumes are only suitable for development and testing. With `hostPath` volumes, your data lives in `/tmp` on the node the Pod is scheduled onto and does not move between nodes. If a Pod dies and gets scheduled to another node in the cluster, or the node is rebooted, the data is lost.
137+
In local clusters, the default StorageClass uses the `hostPath` provisioner.
138+
`hostPath` volumes are only suitable for development and testing. With `hostPath`
139+
volumes, your data lives in `/tmp` on the node the Pod is scheduled onto and does
140+
not move between nodes. If a Pod dies and gets scheduled to another node in the
141+
cluster, or the node is rebooted, the data is lost.
120142
-->
121143
在本地集群中,默认的 StorageClass 使用 `hostPath` 制备程序。`hostPath` 卷仅适用于开发和测试。
122144
使用 `hostPath` 卷时,你的数据位于 Pod 调度到的节点上的 `/tmp` 中,并且不会在节点之间移动。
@@ -125,15 +147,17 @@ In local clusters, the default StorageClass uses the `hostPath` provisioner. `h
125147

126148
{{< note >}}
127149
<!--
128-
If you are bringing up a cluster that needs to use the `hostPath` provisioner, the `--enable-hostpath-provisioner` flag must be set in the `controller-manager` component.
150+
If you are bringing up a cluster that needs to use the `hostPath` provisioner,
151+
the `--enable-hostpath-provisioner` flag must be set in the `controller-manager` component.
129152
-->
130153
如果要建立需要使用 `hostPath` 制备程序的集群,
131154
则必须在 `controller-manager` 组件中设置 `--enable-hostpath-provisioner` 标志。
132155
{{< /note >}}
133156

134157
{{< note >}}
135158
<!--
136-
If you have a Kubernetes cluster running on Google Kubernetes Engine, please follow [this guide](https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk).
159+
If you have a Kubernetes cluster running on Google Kubernetes Engine, please
160+
follow [this guide](https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk).
137161
-->
138162
如果你已经有运行在 Google Kubernetes Engine 的集群,
139163
请参考[此指南](https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk)
@@ -150,9 +174,13 @@ If you have a Kubernetes cluster running on Google Kubernetes Engine, please fol
150174
### 创建 Secret 生成器
151175

152176
<!--
153-
A [Secret](/docs/concepts/configuration/secret/) is an object that stores a piece of sensitive data like a password or key. Since 1.14, `kubectl` supports the management of Kubernetes objects using a kustomization file. You can create a Secret by generators in `kustomization.yaml`.
177+
A [Secret](/docs/concepts/configuration/secret/) is an object that stores a piece
178+
of sensitive data like a password or key. Since 1.14, `kubectl` supports the
179+
management of Kubernetes objects using a kustomization file. You can create a Secret
180+
by generators in `kustomization.yaml`.
154181
155-
Add a Secret generator in `kustomization.yaml` from the following command. You will need to replace `YOUR_PASSWORD` with the password you want to use.
182+
Add a Secret generator in `kustomization.yaml` from the following command.
183+
You will need to replace `YOUR_PASSWORD` with the password you want to use.
156184
-->
157185
[Secret](/zh-cn/docs/concepts/configuration/secret/) 是存储诸如密码或密钥之类敏感数据的对象。
158186
从 1.14 开始,`kubectl` 支持使用一个 kustomization 文件来管理 Kubernetes 对象。
@@ -176,7 +204,9 @@ EOF
176204
## 补充 MySQL 和 WordPress 的资源配置
177205

178206
<!--
179-
The following manifest describes a single-instance MySQL Deployment. The MySQL container mounts the PersistentVolume at /var/lib/mysql. The `MYSQL_ROOT_PASSWORD` environment variable sets the database password from the Secret.
207+
The following manifest describes a single-instance MySQL Deployment. The MySQL
208+
container mounts the PersistentVolume at /var/lib/mysql. The `MYSQL_ROOT_PASSWORD`
209+
environment variable sets the database password from the Secret.
180210
-->
181211
以下清单文件描述的是一个单实例的 MySQL Deployment。MySQL 容器将 PersistentVolume 挂载在 `/var/lib/mysql`
182212
`MYSQL_ROOT_PASSWORD` 环境变量根据 Secret 设置数据库密码。
@@ -193,38 +223,39 @@ the name of the MySQL Service defined above, and WordPress will access the datab
193223
挂载到 `/var/www/html`,用于保存网站数据文件。
194224
`WORDPRESS_DB_HOST` 环境变量设置上面定义的 MySQL Service 的名称,WordPress 将通过 Service 访问数据库。
195225
`WORDPRESS_DB_PASSWORD` 环境变量根据使用 kustomize 生成的 Secret 设置数据库密码。
226+
196227
{{< codenew file="application/wordpress/wordpress-deployment.yaml" >}}
197228

198229
<!--
199230
1. Download the MySQL deployment configuration file.
200231
-->
201232
1. 下载 MySQL Deployment 配置文件。
202233

203-
```shell
204-
curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml
205-
```
234+
```shell
235+
curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml
236+
```
206237

207238
<!--
208239
2. Download the WordPress configuration file.
209240
-->
210241
2. 下载 WordPress 配置文件。
211242

212-
```shell
213-
curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml
214-
```
243+
```shell
244+
curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml
245+
```
215246

216247
<!--
217248
3. Add them to `kustomization.yaml` file.
218249
-->
219250
3. 将上述内容追加到 `kustomization.yaml` 文件。
220251

221-
```
222-
cat <<EOF >>./kustomization.yaml
223-
resources:
224-
- mysql-deployment.yaml
225-
- wordpress-deployment.yaml
226-
EOF
227-
```
252+
```shell
253+
cat <<EOF >>./kustomization.yaml
254+
resources:
255+
- mysql-deployment.yaml
256+
- wordpress-deployment.yaml
257+
EOF
258+
```
228259
229260
<!--
230261
## Apply and Verify
@@ -233,7 +264,7 @@ the name of the MySQL Service defined above, and WordPress will access the datab
233264
234265
<!--
235266
The `kustomization.yaml` contains all the resources for deploying a WordPress site and a
236-
MySQL database. You can apply the directory by:
267+
MySQL database. You can apply the directory by
237268
-->
238269
`kustomization.yaml` 包含用于部署 WordPress 网站以及 MySQL 数据库的所有资源。你可以通过以下方式应用目录:
239270
@@ -260,7 +291,7 @@ Now you can verify that all objects exist.
260291
261292
响应应如下所示:
262293
263-
```shell
294+
```
264295
NAME TYPE DATA AGE
265296
mysql-pass-c57bb4t7mf Opaque 1 9s
266297
```
@@ -285,10 +316,10 @@ Now you can verify that all objects exist.
285316
<!--
286317
The response should be like this:
287318
-->
288-
319+
289320
响应应如下所示:
290321
291-
```shell
322+
```
292323
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
293324
mysql-pv-claim Bound pvc-8cbd7b2e-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s
294325
wp-pv-claim Bound pvc-8cd0df54-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s
@@ -338,8 +369,8 @@ Now you can verify that all objects exist.
338369
响应应如下所示:
339370
340371
```
341-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
342-
wordpress ClusterIP 10.0.0.89 <pending> 80:32406/TCP 4m
372+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
373+
wordpress LoadBalancer 10.0.0.89 <pending> 80:32406/TCP 4m
343374
```
344375
345376
{{< note >}}
@@ -379,12 +410,15 @@ Now you can verify that all objects exist.
379410
380411
![wordpress-init](https://raw.githubusercontent.com/kubernetes/examples/master/mysql-wordpress-pd/WordPress.png)
381412
382-
{{< warning >}}
383-
<!--
384-
Do not leave your WordPress installation on this page. If another user finds it, they can set up a website on your instance and use it to serve malicious content. <br/><br/>Either install WordPress by creating a username and password or delete your instance.
385-
-->
386-
不要在此页面上保留 WordPress 安装。如果其他用户找到了它,他们可以在你的实例上建立一个网站并使用它来提供恶意内容。<br/><br/>通过创建用户名和密码来安装 WordPress 或删除你的实例。
387-
{{< /warning >}}
413+
{{< warning >}}
414+
<!--
415+
Do not leave your WordPress installation on this page. If another user finds it,
416+
they can set up a website on your instance and use it to serve malicious content.<br/><br/>
417+
Either install WordPress by creating a username and password or delete your instance.
418+
-->
419+
不要在此页面上保留 WordPress 安装。如果其他用户找到了它,他们可以在你的实例上建立一个网站并使用它来提供恶意内容。<br/><br/>
420+
通过创建用户名和密码来安装 WordPress 或删除你的实例。
421+
{{< /warning >}}
388422
389423
## {{% heading "cleanup" %}}
390424

0 commit comments

Comments
 (0)