Tutorials

How to Install WordPress on AWS EKS

Listen to this article
Advertisements
Advertisements

Are you looking to install WordPress on EKS? There are a lot of advantages of moving your site to the cloud-like you can obtain free SSL certificates from Amazon Certificate Manager (ACM). Recently, I helped a client migrate 50 of his WordPress sites to Amazon Kubernetes Service (EKS). Lightsail is another popular AWS service for hosted WordPress sites. For this blog, I will focus on setting up WordPress on EKS. While this blog will focus more on the AWS cloud, the same concepts can be applied to other managed Kubernetes services like Azure Kubernetes Service (AKS) or Google Kubernetes Engine (GKE). If there is significant interest, I can write future blogs explaining the set up for WordPress on AKS or WordPress on GKE.

If you are planning to install or migrate WordPress on EKS, this guide is for you.

Pre-requisites/Tooling

To setup WordPress on EKS, you will need to install and configure the following tools first:w

Install EKS CLI –  eksctl cli

Install AWS CLI –  aws cli

Configure AWS CLI – aws cli configuration

Install and configure Kubectl – kubectl

Setup EKS cluster

Create an EKS cluster:

eksctl create cluster –name=eks-wp –node-type t3.medium  –nodes=2 –region=us-east-1 –version 1.14

Download Helm Chart and update values.yaml

Clone the Helm Charts repo:

git clone https://github.com/helm/charts.git
cd charts

Update values.yaml based on your requirements.

Database setup – Local or RDS

For database setup, the helm chart  will install a Maria DB as the default database. This may be good for test and development sites, but I usually don’t recommend this for Production. For production sites, I would recommend to set up an RDS  database and use that instead. You can create an RDS instance and update the values.yaml file with database configuration. Also, make sure to set Maria DB to false in values.yaml. You can refer to my values.yaml file as a reference, which is configured to use RDS for the database. Here’s the snippet from values.yaml that you need to update:

externalDatabase:
## All of these values are only used when mariadb.enabled is set to false
## Database host
host: wp-db.cddaikeir.us-east-1.rds.amazonaws.com

## non-root Username for WordPress Database
user: wp-db-username

## Database password
password: wp-db-password

## Database name
database: wp_databasename

## Database port number
port: 3306

Installing multiple WordPress sites on same Database 

Advertisements
Advertisements

Also Read: How to rotate a WordPress MySQL database secret using AWS Secrets Manager in Amazon EKS

If you plan to install multiple sites on the same RDS instance, please ensure to use unique table prefix in values.yaml i.e.

wordpressTablePrefix: cr_

In my case, I installed multiple WordPress sites on the same RDS instance with different table prefixes. That being said, keep an eye on performance as high-volume sites may require dedicated RDS instances.

Update Values.yaml

My customized values.yaml can be found here: https://github.com/rbiswas-mirp/wordpress-eks/blob/main/values.yml

Install WordPress using Helm charts

Install WordPress using the Helm install command –

helm install mysitename eks-wpstable/wordpress/

Get the WordPress URL and login using credentials specified in values.yaml

Get the WordPress URL:

NOTE: It may take a few minutes for the LoadBalancer IP to be available.

Watch the status with: ‘kubectl get svc –namespace default -w eks-wp-wordpress’

export SERVICE_IP=$(kubectl get svc –namespace default eks-wp-wordpress –template “{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}”)

echo “WordPress URL: http://$SERVICE_IP/”

echo “WordPress Admin URL: http://$SERVICE_IP/admin”

Ingress setup:

For Ingress, I decided to disable ingress setup in our values.yaml and manage it separately. You can see my ingress file here: https://github.com/rbiswas-mirp/wordpress-eks/blob/main/values.yml

Conclusion

This blog details the steps on how to install WordPress on EKS (Managed Kubernetes Service – AWS).  You can run one or multiple WordPress sites on EKS and help them scale at the Kubernetes level. If you liked the blog, please comment and let me know below.

Finally, if you need any help with WordPress migration to Cloud, feel free to contact me.

Also Read: How to install WordPress on Docker

Advertisements
Advertisements

Leave a Reply

%d bloggers like this: