A production-ready WordPress deployment on Kubernetes with custom Docker images, Prometheus monitoring, and Grafana visualization. Features OpenResty (Nginx with Lua) as a reverse proxy, persistent storage for scaling, and comprehensive metrics collection.
- Custom Docker Images: WordPress, MySQL, and OpenResty built from Dockerfiles
- OpenResty with Lua: Nginx compiled with Lua support for advanced routing
- ReadWriteMany Volumes: Persistent storage supporting horizontal scaling
- Prometheus Monitoring: Real-time metrics collection and alerting
- Grafana Dashboards: Visualization of nginx requests, error rates, and pod CPU
- Helm Charts: Easy deployment and management
- Kubernetes cluster (minikube, kind, or cloud provider)
kubectlconfigured to access your cluster- Helm 3.x installed
Internet → Nginx (OpenResty + Lua) → WordPress (PHP-FPM) → MySQL
↓
Nginx Exporter → Prometheus → Grafana
↓
Pod Metrics
Components:
- OpenResty (Nginx): Reverse proxy with Lua scripting and Prometheus exporter
- WordPress: PHP-FPM application server with persistent storage
- MySQL: Database with persistent volume
- Prometheus: Metrics collection and alerting engine
- Grafana: Metrics visualization with pre-configured dashboards
# From the project root
helm install my-release ./charts/wordpressThis creates:
- WordPress deployment with custom Docker image
- MySQL database with PersistentVolumeClaim (ReadWriteMany)
- OpenResty (Nginx) with Lua support and metrics exporter
- Persistent volumes for WordPress content and database
Verify deployment:
kubectl get pods
kubectl get pvc
kubectl get svc# Add Prometheus community Helm repository
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Install Prometheus and Grafana
helm install monitoring prometheus-community/kube-prometheus-stackWait for all pods to be ready:
kubectl get pods -w# Get the URL (for minikube)
minikube service nginx --url
# Or for cloud deployments
kubectl get svc nginxVisit the URL in your browser to complete WordPress installation.
# Port forward Grafana
kubectl port-forward svc/monitoring-grafana 3000:80- URL: http://localhost:3000
- Username:
admin - Password: Get with this command:
kubectl get secret monitoring-grafana -o jsonpath="{.data.admin-password}" | base64 --decodekubectl port-forward svc/monitoring-kube-prometheus-prometheus 9090:9090Grafana comes pre-configured with Prometheus and Alertmanager data sources. To verify:
- Navigate to Configuration → Data Sources in Grafana
- Both Prometheus and Alertmanager should show as connected
This project implements comprehensive monitoring as per production requirements:
1. Pod CPU Utilization
- Tracks CPU usage across all pods
- Alert threshold: >80% CPU usage
- Visualized in Grafana dashboards
2. Nginx Request Metrics
- Total Request Count: All HTTP requests through nginx
- Total 5xx Requests: Server error tracking
- Error Rate: Percentage of failed requests
- Alert threshold: >5% error rate
3. Additional Metrics
- Pod memory usage
- Nginx connection count
- MySQL connection status
- Container restart count
Navigate to Grafana → Dashboards to view:
- Total Nginx Requests: HTTP request volume over time
- 5xx Error Rate: Application error monitoring
- Pod CPU Usage: Resource utilization tracking
Prometheus alerting rules are configured for:
- HighPodCPU: Triggers when pod CPU usage exceeds 80%
- High5xxErrorRate: Triggers when 5xx error rate exceeds 5%
Check alerts in Prometheus UI → Alerts tab.
For complete metrics documentation including WordPress, Apache, and Nginx metrics, see METRICS.md.
kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>kubectl get svc
kubectl get servicemonitorkubectl port-forward svc/<release-name>-nginx-metrics 9113:9113
curl http://localhost:9113/metrics# Get MySQL password
kubectl get secret <release-name>-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode
# Connect to MySQL pod
kubectl exec -it <mysql-pod-name> -- mysql -u root -p# Delete WordPress stack
helm delete my-release
# Delete monitoring stack
helm delete monitoring
# Delete persistent volumes (optional)
kubectl delete pvc --allThis project uses custom-built Docker images located in charts/wordpress/docker/:
- Built from source with Lua support
- Compiled with configure options:
./configure --prefix=/opt/openresty \ --with-pcre-jit \ --with-ipv6 \ --without-http_redis2_module \ --with-http_iconv_module \ --with-http_postgres_module \ --with-http_stub_status_module \ -j8 - Includes nginx-prometheus-exporter for metrics
- Proxy pass configuration from nginx to WordPress
- Custom PHP-FPM setup
- Optimized for Kubernetes deployment
- ReadWriteMany volume support for scaling
- Production-ready configuration
- Persistent storage with proper permissions
The deployment supports horizontal scaling thanks to ReadWriteMany persistent volumes:
# Scale WordPress pods
kubectl scale deployment my-release-wordpress --replicas=3
# Verify scaling
kubectl get pods -l app=wordpressEdit values.yaml to customize:
- Docker image tags (nginx, wordpress, mysql)
- Replica count (default: 2)
- Storage size and class
- Persistent volume sizes (WordPress: 5Gi, MySQL: 5Gi)
- Helm Charts – https://helm.sh/docs/
- Prometheus – https://prometheus.io/
- Grafana – https://grafana.com/



