Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Deploy WordPress on Azure Kubernetes Service

2 min read

00-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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

  •  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"
01-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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
02-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Output:

03-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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
05-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Output:

06-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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

022-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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
07-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Now add the Azure Marketplace repo to the Helm repository:

helm repo add azure-marketplace https://marketplace.azurecr.io/helm/v1/repo
08-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Output:

09-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Check the configuration of your Azure Kubernetes Cluster

List all the contexts in your kubeconfig file:

kubectl config get-contexts
010-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Output:

011-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Now let’s install a clean installation of WordPress using Helm:

helm install aks-wp-demo azure-marketplace/wordpress
012-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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

013-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Now you can check your installation with the cmd below to fetch all Pods in all namespaces using:

kubectl get pods -w
014-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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

kubectl get svc
015-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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:

018-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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

kubectl get secret
016-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

Let’s get the encrypted password with the comand below:

kubectl get secret aks-wp-demo-wordpress -o yaml
017-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

You can DECRYPT PASSWORD USING: www.base64decode.org

  1. Copy the password from the previous step
  2. Paste the password on the first textbox
  3. Click decode
  4. Copy the wordpress password
019-Deploy-wordpress-on-Azure-Kubernetes-Service-wikiazure

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.

Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

2 Replies to “Deploy WordPress on Azure Kubernetes Service”

  1. Hi, your blog post is very interesting but how can you update the wordpress website. for example add some contents ?
    regards

    1. 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!

Leave a Reply

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