How to install Wordpress in Enterprise Managed Kubernetes with the use of Bitnami helm charts.
In this tutorial we will walk through setting up an Wordpress instance in Kubernetes by the help of Bitnami helm charts. The tutorial will contain:
- Setting up access to your cluster
- Finding and using the correct helm charts
- Exploring the resources the helm chart has deployed
- Access your Wordpress installation
Prerequisites
For management you need some software:
Create a new directory where you put everything for this deployment. This contains the configuration files for access to your EMK cluster and the services you roll out.
for example ~/EMK-demo (we will continue to use this).
Then go to https://my.fuga.cloud/managed-kubernetes and deploy an EMK cluster.
(If you are new with this, you can always check our "let's get started with EMK" tutorials)
Setting up access to your cluster
To use EMK, or K8S you need a kubeconfig.
You can find these at the Fuga dashboard at the right menu, as EMK,
or go straight to https://my.fuga.cloud/managed-kubernetes
Click the hamburger menu next to your cluster and choose 'Cluster Access'.
Download the Kubeconfig to ~/EMK-demo/kubeconfig and adjust the permissions, for example:
chmod 600 kubeconfig
By default this data is read by kubectl from ~/.kube/config but in this case, we put it somewhere else. To make sure that kubeconfig finds this file, we set the following variable, which tells kubectl to search the current path to the kubeconfig file.
export KUBECONFIG=./kubeconfig
Test this with kubectl get nodes
kubectl get nodes
NAME STATUS ROLES AGE VERSION
shoot--oswl827--demo-worker-demo-1-z1-7bc7d-hnjkm Ready <none> 8m57s v1.24.6
shoot--oswl827--demo-worker-demo-1-z2-5f96c-jvk46 Ready <none> 8m52s v1.24.6
Check your cluster:
kubectl cluster-info
Finding and using the correct helm charts
Now we have access to our cluster we have to setup the helm charts and deploy them to the cluster.
Bitnami
Bitnami is a party that offers ready-made solutions for a number of standard hosting software solutions. They also offer k8s configurations.
To make use of the charts they provide, you have to add the Bitnami catalog as follows:
helm repo add bitnami https://charts.bitnami.com/bitnami
Helm
Helm is a tool to define, install and upgrade applications that use Kubernetes. Basically Helm is a templating engine that generates and updates Kubernetes manifests from templates.
To start we have to update the current repo first with:
helm repo update
You can see the available helm repositories with:
helm repo list
NAME URL
bitnami https://charts.bitnami.com/bitnami
To check available software, you use
helm search repo
In this tutorial we are going to install wordpress, so find the wordpress chart repo with the search function:
helm search repo wordpress
AME CHART VERSION APP VERSION DESCRIPTION
bitnami/wordpress 15.2.5 6.0.2 WordPress is the world's most popular blogging ...
bitnami/wordpress-intel 2.1.12 6.0.3 WordPress for Intel is the most popular bloggin...
To get more information about the chart, we can check it out with:
helm show chart bitnami/wordpress
and if you want to show everything (that's a lot)
helm show all bitnami/wordpress
Installing the Wordpress chart:
We have found the chart and can now install it, to install it you can use the following command:
helm install bitnami/wordpress --generate-name
NAME: wordpress-1666174896
LAST DEPLOYED: Wed Oct 19 12:21:38 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: wordpress
CHART VERSION: 15.2.5
APP VERSION: 6.0.2
** Please be patient while the chart is being deployed **
Your WordPress site can be accessed through the following DNS name from within your cluster:
wordpress-1666174896.default.svc.cluster.local (port 80)
To access your WordPress site from outside the cluster follow the steps below:
1. Get the WordPress URL by running these commands:
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace default -w wordpress-1666174896'
export SERVICE_IP=$(kubectl get svc --namespace default wordpress-1666174896 --include "")
echo "WordPress URL: http://$SERVICE_IP/"
echo "WordPress Admin URL: http://$SERVICE_IP/admin"
2. Open a browser and access WordPress using the obtained URL.
3. Login with the following credentials below to see your blog:
echo Username: user
echo Password: $(kubectl get secret --namespace default wordpress-1666174896 -o jsonpath="{.data.wordpress-password}" | base64 -d)
This ensures that a wordpress deployment is rolled out.
The output shows how you can get to this, you can see it again afterwards, using:
helm status wordpress-1666174896
Please note that rolling out our HA Loadbalancer will take some time, probably much longer than it takes to roll out your deployment on k8s. In this tutorial-case, it took just under 3 minutes.
kubectl get svc --namespace default -w wordpress-1666174896
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
wordpress-1666174896 LoadBalancer 100.64.33.69 <pending> 80:30267/TCP,443:31728/TCP 77s
wordpress-1666174896 LoadBalancer 100.64.33.69 <pending> 80:30267/TCP,443:31728/TCP 2m52s
wordpress-1666174896 LoadBalancer 100.64.33.69 81.24.10.208 80:30267/TCP,443:31728/TCP 2m52s
The Wordpress installation is now accessible under http://81.24.10.208/
and the admin under http://81.24.10.208/admin
Exploring the resources the helm chart has deployed
To understand a bit better what we have done with the installation of the helm chart we are going to dive a bit deeper in what it actually has deployed.
It's possible to also understand this from the helm charts, but we have already deployed it. So we are going to checkout some resources.
Namespaces
In Kubernetes resources are deployed in something called namespaces, it is a kind of grouping of services, you can see these by using:
kubectl get namespaces
Services
Your services will be within a namespace, using the default namespace as a standard:
kubectl get services -n default
Pods
The services from above launches pods where the actual service is running in. So this is where the Wordpress pod is running.
kubectl get pods -n default
Persistent Volumes (PVC)
To safely store your data, Kubernetes can use Persistent Volumes also called PVC in short. Those are not on your worker nodes, but attached and stored outside of your cluster in a storage array. This will make sure that if a worker node is removed the data still exists in the PVC. To get a list of all the created PVC's use:
kubectl get pvc -n default
Deployments
You can find the deployment from the helm chart with:
kubectl get deployment -n default
kubectl describe deployment wordpress-1666174896
Replicaset
kubectl get replicaset -n default
kubectl describe replicaset wordpress-1666174896-5c46b8f74c
Secrets
As stated while deploying Wordpress, it would be possible for us to find the Wordpress password in a Secret. To view all the created secrets:
kubectl get secrets
NAME TYPE DATA AGE
sh.helm.release.v1.wordpress-1666174896.v1 helm.sh/release.v1 1 4h45m
wordpress-1666174896 Opaque 1 4h45m
wordpress-1666174896-mariadb Opaque 2 4h45m
To extract the Wordpress password from the Wordpress secret above, we can use the following commando to see the data of the secret:
kubectl get secret wordpress-1666174896 -o yaml
apiVersion: v1
data:
wordpress-password: WU9xMDhRM0J0ag==
kind: Secret
metadata:
annotations:
meta.helm.sh/release-name: wordpress-1666174896
meta.helm.sh/release-namespace: default
creationTimestamp: "2022-10-01T10:21:39Z"
labels:
app.kubernetes.io/instance: wordpress-1666174896
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: wordpress
helm.sh/chart: wordpress-15.2.5
name: wordpress-1666174896
namespace: default
resourceVersion: "5436"
uid: 5656c234-c2d6-4c22-a7db-514404334a60
type: Opaque
In the above output you can find "wordpress-password: WU9xMDhRM0J0ag==". Only this is in base64 encoded, to get the actual value we have to decode the string with:
echo WU9xMDhRM0J0ag== | base64 --decode
YOq08Q3Btj
Access your Wordpress installation
Get the IP address of your cluster with the following command from the service:
export SERVICE_IP=$(kubectl get svc --namespace default wordpress-<your_number> --include "")
echo "WordPress URL: http://$SERVICE_IP/"
With the IP address we can access the Wordpress installation at: http://<your_ip>/ or go to the admin interface at: http://<your_ip>/admin.
To login use as user: "user" and the password you have retrieved from the Wordpress secret.