Install WordPress on EKS

Are you looking to install WordPress on EKS ? Lot of our clients are migrating their sites off from dedicated/VPC/shared hosting services to Cloud (AWS, Azure, and GCP). 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, we helped a client migrate 14 of his WordPress sites to Amazon Kubernetes Service (EKS). Lightsail is another popular AWS service for hosted WordPress sites. For this blog, we 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:

Install EKS CLI –  eksctl cli

Install AWS CLI –  aws cli

Configure AWS CLI – aws cli configuration

Install and configure Kubectl – kubectl

Download our Github repo – link

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 – https://github.com/helm/charts/tree/master/stable/wordpress

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 we usually don’t recommend this for Production. For production sites, we 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 our 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 EKS with same Database 

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 our case, we 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

Our customized values.yaml can be found here: https://github.com/coderiseio/wordpress-eks/blob/master/values.yaml

Install WordPress on EKS 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 & DNS setup:

For Ingress, we decided to disable ingress setup in our values.yaml and manage it separately. You can see our ingress file here: https://github.com/coderiseio/wordpress-eks/blob/master/ingress.yaml

The Ingress and DNS setup is explained in detail here:

https://coderise.io/ingress-resource-for-hosting-multiple-sites-on-single-amazon-eks-cluster-part-1/
https://coderise.io/ingress-configuration-for-supporting-multiple-acm-issued-certificates-in-amazon-eks-part-2/

The above blog details steps on how you can enable SSL certificates using Amazon’s Certificate Manager (ACM) and also shows you how to configure those certificates in the application load balancer (ALB). The blogs also outline steps on how to redirect the site from http to https.

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 us know below.

Also, checkout our recent blog on how to deploy react app to AWS S3 using Github Actions here

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

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *