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
Copy file name to clipboardExpand all lines: content/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md
+73-39Lines changed: 73 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,21 +13,28 @@ reviewers:
13
13
- ahmetb
14
14
content_type: tutorial
15
15
weight: 20
16
-
card:
16
+
card:
17
17
name: tutorials
18
18
weight: 40
19
19
title: "Stateful Example: Wordpress with Persistent Volumes"
20
20
-->
21
21
<!-- overview -->
22
22
23
23
<!--
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.
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
@@ -38,7 +45,10 @@ PersistentVolumes 和 PersistentVolumeClaims 独立于 Pod 生命周期而存在
38
45
39
46
{{< warning >}}
40
47
<!--
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
@@ -47,7 +57,10 @@ This deployment is not suitable for production use cases, as it uses single inst
47
57
48
58
{{< note >}}
49
59
<!--
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.
51
64
-->
52
65
本教程中提供的文件使用 GA Deployment API,并且特定于 kubernetes 1.9 或更高版本。
53
66
如果你希望将本教程与 Kubernetes 的早期版本一起使用,请相应地更新 API 版本,或参考本教程的早期版本。
@@ -100,11 +113,16 @@ Download the following configuration files:
100
113
-->
101
114
## 创建 PersistentVolumeClaims 和 PersistentVolumes
102
115
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.
104
119
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.
106
123
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.
108
126
-->
109
127
MySQL 和 Wordpress 都需要一个 PersistentVolume 来存储数据。
110
128
它们的 PersistentVolumeClaims 将在部署步骤中创建。
@@ -116,7 +134,11 @@ MySQL 和 Wordpress 都需要一个 PersistentVolume 来存储数据。
116
134
117
135
{{< warning >}}
118
136
<!--
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.
使用 `hostPath` 卷时,你的数据位于 Pod 调度到的节点上的 `/tmp` 中,并且不会在节点之间移动。
@@ -125,15 +147,17 @@ In local clusters, the default StorageClass uses the `hostPath` provisioner. `h
125
147
126
148
{{< note >}}
127
149
<!--
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.
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
@@ -150,9 +174,13 @@ If you have a Kubernetes cluster running on Google Kubernetes Engine, please fol
150
174
### 创建 Secret 生成器
151
175
152
176
<!--
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`.
154
181
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.
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.
180
210
-->
181
211
以下清单文件描述的是一个单实例的 MySQL Deployment。MySQL 容器将 PersistentVolume 挂载在 `/var/lib/mysql`。
182
212
`MYSQL_ROOT_PASSWORD` 环境变量根据 Secret 设置数据库密码。
@@ -193,38 +223,39 @@ the name of the MySQL Service defined above, and WordPress will access the datab
193
223
挂载到 `/var/www/html`,用于保存网站数据文件。
194
224
`WORDPRESS_DB_HOST` 环境变量设置上面定义的 MySQL Service 的名称,WordPress 将通过 Service 访问数据库。
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.
0 commit comments