Skip to content
All articles

The Hidden Risk of Running WordPress on Kubernetes: Debugging an Unexpected Downtime Issue

At 1000Farmacie, we recently migrated our entire infrastructure to Kubernetes, including a range of critical systems. One of the workloads we moved was a WordPress blog, which runs across multiple pods for high availability (HA). Despite this careful setup, after a couple of months we encountered a persistent issue with it: intermittent downtime. After extensive debugging, we discovered the root cause: an overlooked interaction between Kubernetes health checks and WordPress’s behavior during updates.

Debugging the issue

When the downtime began, we initially suspected issues related to resource allocation or external systems like the database and file system. Here’s the process we followed to debug the problem:

  1. Random Downtime: The issue was particularly difficult to debug because the downtime occurred randomly, both during the day and night, which made it hard to pinpoint. Sometimes, the downtime would require us to manually restart the pods, but this would only temporarily resolve the issue. Additionally, investigating during downtime was challenging, as doing so could potentially extend the downtime further. As a result, we had to limit real-time investigation until the issue was less disruptive.

  2. Investigating Resources: After noticing the downtime, we checked the resource usage on Kubernetes, including CPU, memory, and network traffic. We tried increasing pod limits to cover potential traffic peaks or issues caused by plugins, but these actions didn’t solve the problem. With high availability and autoscaling in place, resources didn’t seem to be the issue.

  3. Database and File System: Our database runs on AWS RDS and our file system is shared via EFS across pods. We investigated potential issues such as high DB load or excessive I/O operations on EFS. Both were ruled out, as neither exhibited signs of stress.

  4. Health Check Failures: After further investigation, we noticed that Kubernetes was repeatedly restarting the WordPress pods due to health check failures. This led us to believe the issue was related to the health check configuration.

  5. Manual Update Testing: The breakthrough came when I manually triggered a WordPress update. During the update, WordPress switched to maintenance mode and returned a 503 status code, causing Kubernetes to mark the pod as unhealthy and restart it. We discovered that maintenance mode was automatically disabled only after a brief period, which explained why the issue occurred randomly.

The breakthrough

The issue became clear: WordPress’s maintenance mode triggered a 503 status code on all endpoints during updates, which Kubernetes interpreted as a failure. This caused unnecessary container restarts, preventing the update from completing.

Since WordPress was running on multiple pods, this behavior caused inconsistent service across the pods, which amplified the downtime. The update cycle continued without resolution, as WordPress would attempt to retry the update after a delay.

Why this happens

WordPress does not provide a health check endpoint out of the box. When it enters maintenance mode during updates, it returns a 503 status code for all its endpoints. Kubernetes, seeing this as a failure, restarts the pods, which disrupts the update process.

However, there is one exception: the wp-admin/install.php endpoint. This endpoint remains functional during maintenance mode and validates key components like the database connection, making it suitable for Kubernetes health checks.

The solution

To solve this problem, we configured Kubernetes to use the wp-admin/install.php endpoint for health checks instead of the default WordPress endpoints. This allows updates to proceed without triggering unnecessary container restarts.

Steps to Implement:

  1. Modify Health Check Probes: Update the Kubernetes readiness and liveness probes to use wp-admin/install.php.

  2. Disable Automatic Updates (optional): If updates aren’t urgent, manually manage them to avoid unexpected restarts.

  3. Leverage Helm Charts: If you’re using the Bitnami Helm chart for WordPress, this solution is already implemented, making it a quick fix.

By aligning health checks with WordPress’s behavior, we were able to eliminate the risk of downtime during updates.

Conclusion

While WordPress remains a powerful tool for building websites, running it on modern infrastructure like Kubernetes requires understanding and adapting to its behavior. The lack of a built-in health check endpoint by Wordpress and its reliance on maintenance mode during updates can lead to unexpected downtime, especially in high-availability environments.

By using the wp-admin/install.php endpoint for health checks — or leveraging pre-configured solutions like the Bitnami Helm chart — you can prevent unnecessary restarts and ensure your WordPress site remains operational during updates. I hope this insight helps others avoid the issues we encountered during our transition.