WordPress is a commonly used Blog and CMS engine that serves as an excellent introduction to a multi-tier application.
The WordPress example has two major components: A MySQL database to serve as the backing datastore and the WordPress container itself that combines the Apache webserver along with PHP and the needed application dependencies to run an instance of the blog engine.
The manifests used in this example function as the bare minimum to provision an instance and should not be used in a production deployment. For a more production ready deployment, see the WordPress Helm Chart.
- Create the Secret used for the MySQL root account:
$ kubectl create -f manifests/secret-mysql.yaml
- manifests/secret-mysql.yaml - Contains a base64 encoded string to serve as the MySQL Database password.
- Create the MySQL StatefulSet and its associated service.
$ kubectl create \
-f manifests/sts-mysql.yaml \
-f manifests/svc-mysql.yaml
- manifests/sts-mysql.yaml - MySQL StatefulSet.
- manifests/svc-mysql.yaml - Associated MySQL Service.
NOTE: The MySQL StatefulSet does not require a PVC to be created ahead of time for its storage. Instead, it uses
the volumeClaimTemplates
StatefulSet feature in combination with the default StorageClass provided by Kind to
dynamically provision a volume.
- Wait for the Pod to be up and running:
$ kubectl get pods --watch
- With MySQL up and running, WordPress can now be provisioned. Start by Creating the PVC used to store WordPress's internal data.
$ kubectl create -f manifests/pvc-wordpress.yaml
- manifests/pvc-wordpress.yaml - The Persistent Volume Claim used for the WordPress pod's own internal storage.
- Now create the WordPress deployment and its associated Service.
$ kubectl create \
-f manifests/dep-wordpress.yaml \
-f manifests/svc-wordpress.yaml
- manifests/dep-wordpress.yaml - WordPress deployment. The MySQL password is read from the secret and passed to MySQL as an environment variable.
- manifests/svc-wordpress.yaml - WordPress NodePort service
- Wait for the Pods to be up and running:
$ kubectl get pods --watch
- With both MySQL and WordPress up and running, visit the IP:Port combo from the command below in a browser to access the WordPress deployment.
$ echo $(docker inspect -f '{{.NetworkSettings.Networks.kind.IPAddress}}' kind-control-plane):80
At this point, you should see the WordPress default installation and configuration page. You can configure it and give it a go!
$ kubectl delete -f manifests/
$ kubectl delete pvc mysql-data-mysql-0