|
| 1 | +# Deploy WordPress with NFS Persistent Volumes |
| 2 | +This document explains how to deploy a WordPress site using OpenEBS NFS Volume. Since OpenEBS NFS volume supports RWX(ReadWriteMay) storage mode, WordPress deployment using OpenEBS NFS volumes is highly scalable. |
| 3 | + |
| 4 | +## Prerequisites |
| 5 | +Kubernetes cluster with OpenEBS NFS Provisioner installed. Refer [QuickStart guide on How to install OpenEBS NFS Provisioner](https://github.com/openebs/dynamic-nfs-provisioner/blob/develop/docs/intro.md#quickstart) |
| 6 | + |
| 7 | +## Deploying WordPress |
| 8 | +We will use the Helm package to install WordPress in our kubernetes cluster. If you don't have Helm installed, follow the [Installing Helm](https://helm.sh/docs/intro/install/) guide for installation. |
| 9 | + |
| 10 | +### Adding Help repo for WordPress |
| 11 | +Use the below command to add helm repo for WordPress. |
| 12 | + |
| 13 | +``` |
| 14 | +helm repo add bitnami https://charts.bitnami.com/bitnami |
| 15 | +``` |
| 16 | + |
| 17 | +Once repo has been added successfully, update helm repo using the following command: |
| 18 | + |
| 19 | +``` |
| 20 | +helm repo update |
| 21 | +``` |
| 22 | + |
| 23 | +### Installing WordPress |
| 24 | +Once the helm repo is added, you can install WordPress using `helm install` as mentioned below. In this command, we are using Storageclass `openebs-rwx` created using [QuickStart guide](https://github.com/openebs/dynamic-nfs-provisioner/blob/develop/docs/intro.md#quickstart). If you have created a different OpenEBS NFS Storageclass then you need to update the value of `--set persistence.storageClass`. |
| 25 | +You can also configure [the other parameters through the `--set` argument](https://github.com/bitnami/charts/tree/master/bitnami/wordpress#parameters) |
| 26 | + |
| 27 | +``` |
| 28 | +helm install my-release -n wordpress --create-namespace \ |
| 29 | + --set wordpressUsername=admin \ |
| 30 | + --set wordpressPassword=password \ |
| 31 | + --set mariadb.auth.rootPassword=secretpassword \ |
| 32 | + --set persistence.storageClass=openebs-rwx \ |
| 33 | + --set persistence.accessModes={ReadWriteMany} \ |
| 34 | + --set volumePermissions.enabled=true \ |
| 35 | + --set autoscaling.enabled=true \ |
| 36 | + --set autoscaling.minReplicas=2 \ |
| 37 | + --set autoscaling.maxReplicas=6 \ |
| 38 | + --set autoscaling.targetCPU=80 \ |
| 39 | + bitnami/wordpress |
| 40 | +``` |
| 41 | + |
| 42 | +The above will create two WordPress application pods with RWX persistent volume. We are using `my-release` as a release name for the WordPress installation. You can replace `my-release` with a different name also. |
| 43 | + |
| 44 | +You can check the generated pods using the command `kubectl get pods -n wordpress`. |
| 45 | +``` |
| 46 | +$ kubectl get pods -n wordpress |
| 47 | +NAME READY STATUS RESTARTS AGE |
| 48 | +my-release-mariadb-0 1/1 Running 0 3m14s |
| 49 | +my-release-wordpress-79969f558-lqs56 1/1 Running 0 2m59s |
| 50 | +my-release-wordpress-79969f558-qjblc 1/1 Running 0 3m14s |
| 51 | +``` |
| 52 | + |
| 53 | +To check PVC/PV created for WordPress pods, |
| 54 | +``` |
| 55 | +$ kubectl get pvc -n wordpress |
| 56 | +NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE |
| 57 | +data-my-release-mariadb-0 Bound pvc-9dfec460-fc8a-4033-b26c-a28637dcaa3e 8Gi RWO openebs-hostpath 3m33s |
| 58 | +my-release-wordpress Bound pvc-0234ee9c-befc-4824-8230-3dd6779214cb 10Gi RWX openebs-rwx 3m33s |
| 59 | +``` |
| 60 | + |
| 61 | +You can see PVC `my-release-wordpress` is using Storageclass `openebs-rwx` which is having `RWX` access mode. |
| 62 | + |
| 63 | +## Clean up WordPress installation |
| 64 | +To uninstall WordPress, run the below command: |
| 65 | + |
| 66 | +``` |
| 67 | +helm uninstall my-release -n wordpress |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | +To delete the `wordpress` namespace, run |
| 72 | +``` |
| 73 | +kubectl delete ns wordpress |
| 74 | +``` |
0 commit comments