Deploying WordPress over Rancher

Abhinavsharma
3 min readJul 7, 2022

Overview

In this blog, we will see how to deploy WordPress over Rancher in few minutes. For this purpose, we are going to import our existing cluster on Rancher, install LongHorn to serve as a Storage Class and finally, we will use Wordpress helm charts to deploy it on our Cluster.

Pre-Requisite

  1. Kubernetes Cluster, either K3S, RKE, Kubeadm or KinD, if not then see my previous blog: https://medium.com/@abhinavsharma332/deploy-single-node-cluster-using-k3s-or-rke-6fc9e6a38b66
  2. Install Helm: https://helm.sh/docs/intro/install/

Rancher: With Rancher, you can unify the clusters to ensure consistent operations, workload management, and enterprise-grade security. Now, move from Core to Cloud to Edge with Rancher.

LongHorn: Longhorn is an official CNCF project, when combined with Rancher, Longhorn makes the deployment of highly available persistent block storage in your Kubernetes environment easy, fast and reliable.

LongHorn Interface

WordPress: WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database with supported HTTPS.

Steps to Deploy WordPress:

Installing Rancher

  1. Ensure that your cluster is up and running: kubectl get nodes
  2. Deploy Rancher: sudo docker run — privileged -d — restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
  3. Access the Rancher portal on the Machine’s IP: https://<IP>

Import Cluster on Rancher

  1. Open the Rancher dashboard: https://<server-ip>
  2. Below click on Import Cluster button

3. Select the Provider where your cluster is up and Running. We are going to use the cluster, so we use Generic

4. Give cluster a name and a description (optional) and Click on next

5. Some commands will appear, run those commands in your local cluster you set up earlier to import those clusters to Rancher. Command should look like this: kubectl apply -f https://<server-ip>/v3/import/42ql8klfghhgv7zplr2mwtqm4gvpn6t766g4gmjnzzsfztzbq64wmb_c-m-8rdkjd4k.yaml

Or if certificate errors arise, you can use the second command, looks like this: curl — insecure -sfL https://172.16.220.83:4431/v3/import/42ql8klfghhgv7zplr2mwtqm4gvpn6t766g4gmjnzzsfztzbq64wmb_c-m-8rdkjd4k.yaml | kubectl apply -f -

6. After running those command return to Homepage and you can see the clusters are registered on Rancher.

Installing Longhorn to Clusters

There are 3 ways to install Longhorn to the cluster:

a. Using the Apps and Marketplace in Rancher UI

b. Using the kubectl manifests files: kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.2.4/deploy/longhorn.yaml

c. Using the Helm:
1. Add Longhorn Helm repository: helm repo add longhorn https://charts.longhorn.io

2. helm repo update

3. Install the helm chart: helm install longhorn/longhorn -name longhorn -namespace longhorn-system

4. Access the UI by going to change: LoadBalancer to ClusterIP

Installing WordPress

  1. Setup Helm Repo Access: helm repo add bitnami https://charts.bitnami.com/bitnami
  2. Grab/configure current WordPress Helm Chart:
  3. helm pull bitnami/wordpress and tar -zxvf wordpress-<ver>.tgz
  4. Go to WordPress directory: cd wordpress
  5. Modify the following values:
modify values.yaml
in global stanz
- storageClass: "longhorn"
in service stanza
- http: 8081
- https: 4431
cd ..

6. Deploy Wordpress: helm install <yourDeployNaming> ./wordpress

7. Access your WordPress deployment on cluster node, via Web Browser:

  • Landing Page: http://<ExternalIP>:8081
  • Admin Page: http://<ExternalIP>:8081/admin
WordPress Deployment Page

Congratulations🥳 !! You have successfully deployed WordPress over K8S cluster using Rancher

--

--