Kubernetes WordPress with Remote MySQL Access

Deploying WordPress to Azure Kubernetes Service (AKS) was a great exercise for me to learn and improve my Helm and Kubernetes knowledge. Bitnami has a Helm chart for WordPress on AKS.

The most ideal way of doing this is to modify the Helm Charts to include an additional load balancer, but, the purpose of this blog post is to expose people to the command line and how Kubernetes manages incoming traffic in a cloud environment. This also may be a functionality that you may want to enable only during maintenance. This blog post will teach you how to expose the MySQL port 3306 through a load balancer via command-line.


Pulling the Charts

You will need to do certain things like add the Helm repository and pull the charts locally.

helm repo add azure-marketplace https://marketplace.azurecr.io/helm/v1/repo

The Helm Pull command will pull the chart locally and the --untar flag will expand it.

helm pull azure-marketplace/wordpress --untar

Modifying Helm Charts

In order to have remote access, the easiest way is to enable the root user which by default allows remote access. This configuration setting is found in the values.yaml file. Uncommenting the value rootUser and setting a password value will enable the root user.

Deploying WordPress to AKS with Helm

Assuming you have an Azure Kubernetes Service set up and running in the cloud and you know how to connect using Azure CLI this part should be a breeze.

Login to Azure

az login --use-devicde-code
az account set --subscription "SUBSCRIPTION-NAME"
az aks get-credentials --name aks-cluster --resource-group aks-resource-group

Deploy Helm Charts

helm install my-release azure-marketplace/wordpress

Verifying if the install was successful is easy…

kubectl get all

Exposing MySQL Server via Load Balancer

With cloud infrastructure providers like Azure Kubernetes Service (AKS) the best way to expose a port is through a load balancer type.

kubectl expose pod/wp-mariadb --name wp-mariadb-lb --port=3306 --target-port=3306 --type=LoadBalancer

Connecting to the MySQL Database Remotely

I highly recommend using SQLyog it’s been very good to me for many years.

Further Reading