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
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
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
Check the configuration of your Azure Kubernetes Cluster
List all the contexts in your kubeconfig file:
kubectl config get-contexts
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):
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
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.