This is article intends to be a guide to quickly deploy WordPress on Azure Kubernetes Service using CLI.
Pre-requisites to deploy WordPress on Azure Kubernetes Service
- Windows Terminal (optional)- You can get it here: https://github.com/microsoft/terminal
- Azure CLI – The Azure CLI is available to install in Windows, macOS and Linux environments. It can also be run in a Docker container and Azure Cloud Shell- https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
- Install AKS CLI, you can do so by using the cmd below
az aks install-cli
- Install kubernetes cli using chocolatey , you can do so by running the cmd below (run as admin)
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
- Install Kubernetes CLI, you can do so using the cmd below:
choco install kubernetes-cli
- Install Helm using the cmd below:
choco install kubernetes-helm
Create your Azure Kubernetes Cluster
First and foremost I will create a new resource group through Azure CLI. Using Windows Terminal run the cmd to set your default subscription:
az account set --subscription "Your-Subscription-Name"
In this case:
az account set --subscription "cloud trainee"

Now let’s create a new resource group in which we will provision our Azure Kubernetes Cluster:
az group create --name aks-wp-demo --location eastus

Output:

Let’s proceed to create AKS cluster. The cluster creation process can take up to 15 minutes.
az aks create --name aks-wp-demo --resource-group aks-wp-demo --node-count 3 --generate-ssh-keys

Output:

Now you have created your Azure Kubernetes Cluster! You can also check on the Azure Portal your new Azure Kubernetes Cluster:

Once created let’s configure kubectl to use the credentials for the new AKS cluster:
az aks get-credentials --name aks-wp-demo --resource-group aks-wp-demo

Now add the Azure Marketplace repo to the Helm repository:
helm repo add azure-marketplace https://marketplace.azurecr.io/helm/v1/repo

Output:

Check the configuration of your Azure Kubernetes Cluster
List all the contexts in your kubeconfig file:
kubectl config get-contexts

Output:

Now let’s install a clean installation of WordPress using Helm:
helm install aks-wp-demo azure-marketplace/wordpress

Now you should see the details of the installation of your WordPress on Azure Kubernetes Service:

Now you can check your installation with the cmd below to fetch all Pods in all namespaces using:
kubectl get pods -w

You can use the kubectl get svc command to see which IP address is in use
kubectl get svc

Now go to the the WordPress installation using the External-IP on your browser, you should see your WordPress on Azure Kubernetes Service up and running:

In order to access to the wordpress admin panel we need to RETRIEVE CREDENTIALS using:
kubectl get secret

Let’s get the encrypted password with the comand below:
kubectl get secret aks-wp-demo-wordpress -o yaml

You can DECRYPT PASSWORD USING: www.base64decode.org
- Copy the password from the previous step
- Paste the password on the first textbox
- Click decode
- Copy the wordpress password

Now you can access to the /wp-admin directory of your wordpress installation using that password, the username is “user” as shown in previous steps.
Maintain your WordPress installation!
Later on you might need to take some specific actions for maintenance, so you can list all of your current releases using the command below, this command lists all of the releases for a specified namespace (uses current namespace context if namespace not specified):
helm list
You might need to UPGRADE your repo, to do so you can use the cmd below:
helm repo update
In case you need to Check for newer version:
helm inspect chart azure-marketplace/wordpress
In case you want to upgrade if a new version is available:
helm upgrade aks-wp-demo azure-marketplace/wordpress
Additional resources:
https://docs.microsoft.com/en-us/learn/modules/aks-workshop/
Conclusion
Along this article we reviewed how you can deploy WordPress on Azure Kubernetes Service. We created a new Resource Group on Azure, then created the Azure Kubernetes Cluster, later on we deployed WordPress on top of AKS and reviewed how to access to the WordPress instance and some tips on how to maintain your WordPress installation.
Hi, your blog post is very interesting but how can you update the wordpress website. for example add some contents ?
regards
Hi Jean,
Thanks for taking the time to review this article, once your WordPress installation is operational you can login to the “http://Your-External-IP/wp-admin” directory and start configuring your WordPress site.
Let me know if you have any additional questions
Regards!
site is accessible but wp-admin is not. what could be the reason? ERR_CONNECTION_TIMED_OUT
How do you scale the number of replicas for wordpress? I know how to modify the replicas using kubectl edit, but to the best of my knowledge, 1 azure disk can only be mounted on one node. So how do wordpress pods on other nodes access the same azure disk?
Hi Parth,
Thanks much for taking the time to go over this blog post, if I understand correctly, you are provisioning wordpress on AKS and want to make use of a persistent volume so that multiple nodes can access to the same storage? If that’s the case then probably define the persistent volume and make use of Azure Files – https://docs.microsoft.com/en-us/azure/aks/concepts-storage
Let me know your thoughts,
Cheers!
-dave