Skip to content

Commit effd79d

Browse files
authored
Merge pull request #40504 from windsonsea/mysqly
Tweak line wrapings and fix indentations in mysql-wordpress-pv
2 parents f411d0c + 61a9163 commit effd79d

File tree

1 file changed

+125
-106
lines changed

1 file changed

+125
-106
lines changed

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

Lines changed: 125 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,31 @@ card:
1111
---
1212

1313
<!-- overview -->
14-
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.
14+
This tutorial shows you how to deploy a WordPress site and a MySQL database using
15+
Minikube. Both applications use PersistentVolumes and PersistentVolumeClaims to store data.
1516

16-
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.
17+
A [PersistentVolume](/docs/concepts/storage/persistent-volumes/) (PV) is a piece
18+
of storage in the cluster that has been manually provisioned by an administrator,
19+
or dynamically provisioned by Kubernetes using a [StorageClass](/docs/concepts/storage/storage-classes).
20+
A [PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) (PVC)
21+
is a request for storage by a user that can be fulfilled by a PV. PersistentVolumes and
22+
PersistentVolumeClaims are independent from Pod lifecycles and preserve data through
23+
restarting, rescheduling, and even deleting Pods.
1724

1825
{{< warning >}}
19-
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.
26+
This deployment is not suitable for production use cases, as it uses single instance
27+
WordPress and MySQL Pods. Consider using
28+
[WordPress Helm Chart](https://github.com/bitnami/charts/tree/master/bitnami/wordpress)
29+
to deploy WordPress in production.
2030
{{< /warning >}}
2131

2232
{{< note >}}
23-
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.
33+
The files provided in this tutorial are using GA Deployment APIs and are specific
34+
to kubernetes version 1.9 and later. If you wish to use this tutorial with an earlier
35+
version of Kubernetes, please update the API version appropriately, or reference
36+
earlier versions of this tutorial.
2437
{{< /note >}}
2538

26-
27-
2839
## {{% heading "objectives" %}}
2940

3041
* Create PersistentVolumeClaims and PersistentVolumes
@@ -35,12 +46,10 @@ The files provided in this tutorial are using GA Deployment APIs and are specifi
3546
* Apply the kustomization directory by `kubectl apply -k ./`
3647
* Clean up
3748

38-
39-
4049
## {{% heading "prerequisites" %}}
4150

42-
4351
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
52+
4453
The example shown on this page works with `kubectl` 1.14 and above.
4554

4655
Download the following configuration files:
@@ -49,36 +58,49 @@ Download the following configuration files:
4958

5059
1. [wordpress-deployment.yaml](/examples/application/wordpress/wordpress-deployment.yaml)
5160

52-
53-
54-
<!-- lessoncontent -->
61+
<!-- lessoncontent -->
5562

5663
## Create PersistentVolumeClaims and PersistentVolumes
5764

58-
MySQL and Wordpress each require a PersistentVolume to store data. Their PersistentVolumeClaims will be created at the deployment step.
65+
MySQL and Wordpress each require a PersistentVolume to store data.
66+
Their PersistentVolumeClaims will be created at the deployment step.
5967

60-
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.
68+
Many cluster environments have a default StorageClass installed.
69+
When a StorageClass is not specified in the PersistentVolumeClaim,
70+
the cluster's default StorageClass is used instead.
6171

62-
When a PersistentVolumeClaim is created, a PersistentVolume is dynamically provisioned based on the StorageClass configuration.
72+
When a PersistentVolumeClaim is created, a PersistentVolume is dynamically
73+
provisioned based on the StorageClass configuration.
6374

6475
{{< warning >}}
65-
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.
76+
In local clusters, the default StorageClass uses the `hostPath` provisioner.
77+
`hostPath` volumes are only suitable for development and testing. With `hostPath`
78+
volumes, your data lives in `/tmp` on the node the Pod is scheduled onto and does
79+
not move between nodes. If a Pod dies and gets scheduled to another node in the
80+
cluster, or the node is rebooted, the data is lost.
6681
{{< /warning >}}
6782

6883
{{< note >}}
69-
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.
84+
If you are bringing up a cluster that needs to use the `hostPath` provisioner,
85+
the `--enable-hostpath-provisioner` flag must be set in the `controller-manager` component.
7086
{{< /note >}}
7187

7288
{{< note >}}
73-
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).
89+
If you have a Kubernetes cluster running on Google Kubernetes Engine, please
90+
follow [this guide](https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk).
7491
{{< /note >}}
7592

7693
## Create a kustomization.yaml
7794

7895
### Add a Secret generator
79-
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`.
8096

81-
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.
97+
A [Secret](/docs/concepts/configuration/secret/) is an object that stores a piece
98+
of sensitive data like a password or key. Since 1.14, `kubectl` supports the
99+
management of Kubernetes objects using a kustomization file. You can create a Secret
100+
by generators in `kustomization.yaml`.
101+
102+
Add a Secret generator in `kustomization.yaml` from the following command.
103+
You will need to replace `YOUR_PASSWORD` with the password you want to use.
82104

83105
```shell
84106
cat <<EOF >./kustomization.yaml
@@ -91,42 +113,46 @@ EOF
91113

92114
## Add resource configs for MySQL and WordPress
93115

94-
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.
116+
The following manifest describes a single-instance MySQL Deployment. The MySQL
117+
container mounts the PersistentVolume at /var/lib/mysql. The `MYSQL_ROOT_PASSWORD`
118+
environment variable sets the database password from the Secret.
95119

96120
{{< codenew file="application/wordpress/mysql-deployment.yaml" >}}
97121

98122
The following manifest describes a single-instance WordPress Deployment. The WordPress container mounts the
99123
PersistentVolume at `/var/www/html` for website data files. The `WORDPRESS_DB_HOST` environment variable sets
100124
the name of the MySQL Service defined above, and WordPress will access the database by Service. The
101-
`WORDPRESS_DB_PASSWORD` environment variable sets the database password from the Secret kustomize generated.
125+
`WORDPRESS_DB_PASSWORD` environment variable sets the database password from the Secret kustomize generated.
102126

103127
{{< codenew file="application/wordpress/wordpress-deployment.yaml" >}}
104128

105129
1. Download the MySQL deployment configuration file.
106130

107-
```shell
108-
curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml
109-
```
110-
131+
```shell
132+
curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml
133+
```
134+
111135
2. Download the WordPress configuration file.
112136

113-
```shell
114-
curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml
115-
```
116-
137+
```shell
138+
curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml
139+
```
140+
117141
3. Add them to `kustomization.yaml` file.
118142

119-
```shell
120-
cat <<EOF >>./kustomization.yaml
121-
resources:
122-
- mysql-deployment.yaml
123-
- wordpress-deployment.yaml
124-
EOF
125-
```
143+
```shell
144+
cat <<EOF >>./kustomization.yaml
145+
resources:
146+
- mysql-deployment.yaml
147+
- wordpress-deployment.yaml
148+
EOF
149+
```
126150
127151
## Apply and Verify
128-
The `kustomization.yaml` contains all the resources for deploying a WordPress site and a
152+
153+
The `kustomization.yaml` contains all the resources for deploying a WordPress site and a
129154
MySQL database. You can apply the directory by
155+
130156
```shell
131157
kubectl apply -k ./
132158
```
@@ -135,111 +161,104 @@ Now you can verify that all objects exist.
135161
136162
1. Verify that the Secret exists by running the following command:
137163
138-
```shell
139-
kubectl get secrets
140-
```
164+
```shell
165+
kubectl get secrets
166+
```
141167
142-
The response should be like this:
168+
The response should be like this:
143169
144-
```shell
145-
NAME TYPE DATA AGE
146-
mysql-pass-c57bb4t7mf Opaque 1 9s
147-
```
170+
```
171+
NAME TYPE DATA AGE
172+
mysql-pass-c57bb4t7mf Opaque 1 9s
173+
```
148174
149175
2. Verify that a PersistentVolume got dynamically provisioned.
150-
151-
```shell
152-
kubectl get pvc
153-
```
154-
155-
{{< note >}}
156-
It can take up to a few minutes for the PVs to be provisioned and bound.
157-
{{< /note >}}
158-
159-
The response should be like this:
160-
161-
```shell
162-
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
163-
mysql-pv-claim Bound pvc-8cbd7b2e-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s
164-
wp-pv-claim Bound pvc-8cd0df54-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s
165-
```
176+
177+
```shell
178+
kubectl get pvc
179+
```
180+
181+
{{< note >}}
182+
It can take up to a few minutes for the PVs to be provisioned and bound.
183+
{{< /note >}}
184+
185+
The response should be like this:
186+
187+
```
188+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
189+
mysql-pv-claim Bound pvc-8cbd7b2e-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s
190+
wp-pv-claim Bound pvc-8cd0df54-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s
191+
```
166192
167193
3. Verify that the Pod is running by running the following command:
168194
169-
```shell
170-
kubectl get pods
171-
```
195+
```shell
196+
kubectl get pods
197+
```
172198
173-
{{< note >}}
174-
It can take up to a few minutes for the Pod's Status to be `RUNNING`.
175-
{{< /note >}}
199+
{{< note >}}
200+
It can take up to a few minutes for the Pod's Status to be `RUNNING`.
201+
{{< /note >}}
176202
177-
The response should be like this:
203+
The response should be like this:
178204
179-
```
180-
NAME READY STATUS RESTARTS AGE
181-
wordpress-mysql-1894417608-x5dzt 1/1 Running 0 40s
182-
```
205+
```
206+
NAME READY STATUS RESTARTS AGE
207+
wordpress-mysql-1894417608-x5dzt 1/1 Running 0 40s
208+
```
183209
184210
4. Verify that the Service is running by running the following command:
185211
186-
```shell
187-
kubectl get services wordpress
188-
```
212+
```shell
213+
kubectl get services wordpress
214+
```
189215
190-
The response should be like this:
216+
The response should be like this:
191217
192-
```
193-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
194-
wordpress LoadBalancer 10.0.0.89 <pending> 80:32406/TCP 4m
195-
```
218+
```
219+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
220+
wordpress LoadBalancer 10.0.0.89 <pending> 80:32406/TCP 4m
221+
```
196222
197-
{{< note >}}
198-
Minikube can only expose Services through `NodePort`. The EXTERNAL-IP is always pending.
199-
{{< /note >}}
223+
{{< note >}}
224+
Minikube can only expose Services through `NodePort`. The EXTERNAL-IP is always pending.
225+
{{< /note >}}
200226
201227
5. Run the following command to get the IP Address for the WordPress Service:
202228
203-
```shell
204-
minikube service wordpress --url
205-
```
229+
```shell
230+
minikube service wordpress --url
231+
```
206232
207-
The response should be like this:
233+
The response should be like this:
208234
209-
```
210-
http://1.2.3.4:32406
211-
```
235+
```
236+
http://1.2.3.4:32406
237+
```
212238
213239
6. Copy the IP address, and load the page in your browser to view your site.
214240
215241
You should see the WordPress set up page similar to the following screenshot.
216242
217243
![wordpress-init](https://raw.githubusercontent.com/kubernetes/examples/master/mysql-wordpress-pd/WordPress.png)
218244
219-
{{< warning >}}
220-
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.
221-
{{< /warning >}}
222-
223-
245+
{{< warning >}}
246+
Do not leave your WordPress installation on this page. If another user finds it,
247+
they can set up a website on your instance and use it to serve malicious content.<br/><br/>
248+
Either install WordPress by creating a username and password or delete your instance.
249+
{{< /warning >}}
224250
225251
## {{% heading "cleanup" %}}
226252
227-
228253
1. Run the following command to delete your Secret, Deployments, Services and PersistentVolumeClaims:
229254
230-
```shell
231-
kubectl delete -k ./
232-
```
233-
234-
255+
```shell
256+
kubectl delete -k ./
257+
```
235258
236259
## {{% heading "whatsnext" %}}
237260
238-
239261
* Learn more about [Introspection and Debugging](/docs/tasks/debug/debug-application/debug-running-pod/)
240262
* Learn more about [Jobs](/docs/concepts/workloads/controllers/job/)
241263
* Learn more about [Port Forwarding](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)
242264
* Learn how to [Get a Shell to a Container](/docs/tasks/debug/debug-application/get-shell-running-container/)
243-
244-
245-

0 commit comments

Comments
 (0)