In this article, you will learn how to deploy a production ready wordpress site to Amazon Elastic Kubernetes Service(EKS) with just a few easy steps. This is made possible using a package manager known as helm.
What is Helm?
Helm is a Kubernetes deployment tool for automating creation, packaging, configuration, and deployment of applications and services to Kubernetes clusters. It is an open source package manager that automates the deployment of software for Kubernetes in a simple, consistent way. Helm deploys packaged applications to Kubernetes and structures them into charts. The charts contain all pre-configured application resources along with all the versions into one easily manageable package.
What is a Helm Chart?
Helm charts are Helm packages consisting of YAML files and templates which convert into Kubernetes manifest files. These charts are reusable by anyone for any environment, which reduces complexity and duplicates.
For this demo, I made use of the helm chart for wordpress developed and maintained by bitnami.
Prerequisites
Ensure that you have the following utilities installed and configured on your machine.
AWS CLI, EKSCTL, HELM
1. Provision the EKS cluster
Run the following code on your terminal after placing the value for your preferred region and existing keypair name
cat <<EOF>>demo-eks-cluster.yaml
----
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: demo-eks-cluster
region: your-region
version: "1.21"
managedNodeGroups:
- name: dev-ng-1
instanceType: t3.large
minSize: 1
maxSize: 1
desiredCapacity: 1
volumeSize: 20
volumeEncrypted: true
volumeType: gp3
ssh:
allow: true
publicKeyName: your-keypair-name
tags:
Env: Dev
iam:
attachPolicyARNs:
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- arn:aws:iam::aws:policy/ElasticLoadBalancingFullAccess
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
- arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy
withAddonPolicies:
autoScaler: true
EOF
To confirm that the nodes have been provisioned, run:
kubectl get nodes
2. Deploy Wordpress to EKS
First, add the helm repo to your environment.
helm repo add my-repo https://charts.bitnami.com/bitnami
Then, install the helm chart for wordpress. For this use case, I did overwrite the default wordpressPassword value in values.yaml using the command:
helm install my-release my-repo/wordpress --set wordpressPassword=password
After successful deployment, check the pods and see if status reads "Running"
kubectl get pods
3. Accessing your wordpress site
To access your WordPress site from outside the cluster follow the steps below:
- Get the WordPress URL by running these commands: NOTE: It may take a few minutes for the LoadBalancer IP to be available.
export SERVICE_IP=$(kubectl get svc --namespace default wp-demo-wordpress --include "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
echo "WordPress URL: http://$SERVICE_IP/"
echo "WordPress Admin URL: http://$SERVICE_IP/admin"
- Open a browser and access WordPress using the obtained URL.
- Login with the following credentials below to see your blog:
username: user
password: password
Adding a /admin to the url gives the following:
Login with the credentials and you should hit your wordpress admin page
4. Cleaning up
To clean up the resources created using the eksctl utility, run the following:
eksctl delete cluster demo-eks-cluster
Congratulations, your have successfully deployed a production-grade wordpress website to amazon EKS. Feel free to connect with me on linkedin if you have any questions.
Top comments (1)
Would like to give try on EKS WordPress hosting. Thanks for this article.