This project demonstrates the deployment of WordPress and MySQL on Kubernetes using StatefulSets. WordPress relies on MySQL as its backend, and the stateful nature of StatefulSets ensures stable storage and network identities for these applications.
- A running Kubernetes cluster
kubectl
command-line tool configured to communicate with the cluster- Basic understanding of Kubernetes concepts
- mysql-pv-pvc.yaml: Defines PersistentVolume (PV) and PersistentVolumeClaim (PVC) for MySQL.
- mysql-statefulset.yaml: Deploys MySQL as a StatefulSet.
- mysql-service.yaml: Creates a Headless Service for MySQL.
- wordpress-pv-pvc.yaml: Defines PV and PVC for WordPress.
- wordpress-statefulset.yaml: Deploys WordPress as a StatefulSet.
- wordpress-service.yaml: Creates a Headless Service for WordPress.
- LICENSE: MIT License file.
-
Create MySQL PersistentVolume and PersistentVolumeClaim:
kubectl apply -f mysql-pv-pvc.yaml
-
Create MySQL StatefulSet:
kubectl apply -f mysql-statefulset.yaml
-
Create MySQL Headless Service:
kubectl apply -f mysql-service.yaml
-
Create WordPress PersistentVolume and PersistentVolumeClaim:
kubectl apply -f wordpress-pv-pvc.yaml
-
Create WordPress StatefulSet:
kubectl apply -f wordpress-statefulset.yaml
-
Create WordPress Headless Service:
kubectl apply -f wordpress-service.yaml
-
Access WordPress:
Obtain the NodePort or LoadBalancer IP:
kubectl get svc wordpress
Visit the obtained IP in your browser to access the WordPress installation page.
- Adjust resource requests and limits in StatefulSet configurations based on your environment.
- Customize MySQL and WordPress environment variables in respective StatefulSet configurations.
- Modify storage configurations in PV/PVC files to use cloud-based storage solutions or other storage classes.
To delete the deployed resources, run the following commands:
kubectl delete -f wordpress-service.yaml
kubectl delete -f wordpress-statefulset.yaml
kubectl delete -f wordpress-pv-pvc.yaml
kubectl delete -f mysql-service.yaml
kubectl delete -f mysql-statefulset.yaml
kubectl delete -f mysql-pv-pvc.yaml
This project is licensed under the MIT License - see the LICENSE file for details.
This project provides a robust example of deploying stateful applications on Kubernetes. Feel free to extend and modify it to suit your specific requirements and production environment.