From ccfc65b6a6a5fae94b05b9dc3cb7221a1e4ab08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=AD=A3=E6=B5=A9=2CZhu=20Zhenghao?= Date: Wed, 5 Apr 2023 22:19:53 +0800 Subject: [PATCH] [zh] resync page mysql-wordpress-persistent-volume --- .../mysql-wordpress-persistent-volume.md | 112 ++++++++++++------ 1 file changed, 73 insertions(+), 39 deletions(-) diff --git a/content/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md b/content/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md index a38da5bbbd..a7979ec629 100644 --- a/content/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md +++ b/content/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md @@ -13,7 +13,7 @@ reviewers: - ahmetb content_type: tutorial weight: 20 -card: +card: name: tutorials weight: 40 title: "Stateful Example: Wordpress with Persistent Volumes" @@ -21,13 +21,20 @@ card: 本示例描述了如何通过 Minikube 在 Kubernetes 上安装 WordPress 和 MySQL。 这两个应用都使用 PersistentVolumes 和 PersistentVolumeClaims 保存数据。 [PersistentVolume](/zh-cn/docs/concepts/storage/persistent-volumes/)(PV)是在集群里由管理员手动制备或 Kubernetes 通过 [StorageClass](/zh-cn/docs/concepts/storage/storage-classes) 动态制备的一块存储。 @@ -38,7 +45,10 @@ PersistentVolumes 和 PersistentVolumeClaims 独立于 Pod 生命周期而存在 {{< warning >}} 这种部署并不适合生产场景,因为它使用的是单实例 WordPress 和 MySQL Pod。 在生产场景中,请考虑使用 [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 {{< note >}} 本教程中提供的文件使用 GA Deployment API,并且特定于 kubernetes 1.9 或更高版本。 如果你希望将本教程与 Kubernetes 的早期版本一起使用,请相应地更新 API 版本,或参考本教程的早期版本。 @@ -100,11 +113,16 @@ Download the following configuration files: --> ## 创建 PersistentVolumeClaims 和 PersistentVolumes - MySQL 和 Wordpress 都需要一个 PersistentVolume 来存储数据。 它们的 PersistentVolumeClaims 将在部署步骤中创建。 @@ -116,7 +134,11 @@ MySQL 和 Wordpress 都需要一个 PersistentVolume 来存储数据。 {{< warning >}} 在本地集群中,默认的 StorageClass 使用 `hostPath` 制备程序。`hostPath` 卷仅适用于开发和测试。 使用 `hostPath` 卷时,你的数据位于 Pod 调度到的节点上的 `/tmp` 中,并且不会在节点之间移动。 @@ -125,7 +147,8 @@ In local clusters, the default StorageClass uses the `hostPath` provisioner. `h {{< note >}} 如果要建立需要使用 `hostPath` 制备程序的集群, 则必须在 `controller-manager` 组件中设置 `--enable-hostpath-provisioner` 标志。 @@ -133,7 +156,8 @@ If you are bringing up a cluster that needs to use the `hostPath` provisioner, t {{< note >}} 如果你已经有运行在 Google Kubernetes Engine 的集群, 请参考[此指南](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 ### 创建 Secret 生成器 [Secret](/zh-cn/docs/concepts/configuration/secret/) 是存储诸如密码或密钥之类敏感数据的对象。 从 1.14 开始,`kubectl` 支持使用一个 kustomization 文件来管理 Kubernetes 对象。 @@ -176,7 +204,9 @@ EOF ## 补充 MySQL 和 WordPress 的资源配置 以下清单文件描述的是一个单实例的 MySQL Deployment。MySQL 容器将 PersistentVolume 挂载在 `/var/lib/mysql`。 `MYSQL_ROOT_PASSWORD` 环境变量根据 Secret 设置数据库密码。 @@ -193,6 +223,7 @@ the name of the MySQL Service defined above, and WordPress will access the datab 挂载到 `/var/www/html`,用于保存网站数据文件。 `WORDPRESS_DB_HOST` 环境变量设置上面定义的 MySQL Service 的名称,WordPress 将通过 Service 访问数据库。 `WORDPRESS_DB_PASSWORD` 环境变量根据使用 kustomize 生成的 Secret 设置数据库密码。 + {{< codenew file="application/wordpress/wordpress-deployment.yaml" >}} 1. 下载 MySQL Deployment 配置文件。 - ```shell - curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml - ``` + ```shell + curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml + ``` 2. 下载 WordPress 配置文件。 - ```shell - curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml - ``` + ```shell + curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml + ``` 3. 将上述内容追加到 `kustomization.yaml` 文件。 - ``` - cat <>./kustomization.yaml - resources: - - mysql-deployment.yaml - - wordpress-deployment.yaml - EOF - ``` + ```shell + cat <>./kustomization.yaml + resources: + - mysql-deployment.yaml + - wordpress-deployment.yaml + EOF + ``` `kustomization.yaml` 包含用于部署 WordPress 网站以及 MySQL 数据库的所有资源。你可以通过以下方式应用目录: @@ -260,7 +291,7 @@ Now you can verify that all objects exist. 响应应如下所示: - ```shell + ``` NAME TYPE DATA AGE mysql-pass-c57bb4t7mf Opaque 1 9s ``` @@ -285,10 +316,10 @@ Now you can verify that all objects exist. - + 响应应如下所示: - ```shell + ``` NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE mysql-pv-claim Bound pvc-8cbd7b2e-4044-11e9-b2bb-42010a800002 20Gi RWO standard 77s 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. 响应应如下所示: ``` - NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE - wordpress ClusterIP 10.0.0.89 80:32406/TCP 4m + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE + wordpress LoadBalancer 10.0.0.89 80:32406/TCP 4m ``` {{< note >}} @@ -379,12 +410,15 @@ Now you can verify that all objects exist. ![wordpress-init](https://raw.githubusercontent.com/kubernetes/examples/master/mysql-wordpress-pd/WordPress.png) -{{< warning >}} - -不要在此页面上保留 WordPress 安装。如果其他用户找到了它,他们可以在你的实例上建立一个网站并使用它来提供恶意内容。

通过创建用户名和密码来安装 WordPress 或删除你的实例。 -{{< /warning >}} + {{< warning >}} + + 不要在此页面上保留 WordPress 安装。如果其他用户找到了它,他们可以在你的实例上建立一个网站并使用它来提供恶意内容。

+ 通过创建用户名和密码来安装 WordPress 或删除你的实例。 + {{< /warning >}} ## {{% heading "cleanup" %}}