Skip to content

abhinav12222363/wordpress-k8s-devops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WordPress on Kubernetes – Infra & DevOps Assignment (Syfe) πŸ“Œ Overview

This project demonstrates a production-grade WordPress deployment on Kubernetes using Docker, Helm, Nginx (OpenResty), Prometheus, and Grafana.

The goal of this assignment is to show:

Kubernetes fundamentals

Helm-based deployments

Reverse proxy configuration

Persistent storage

Monitoring and alerting

Practical DevOps troubleshooting

πŸ— Architecture Client | v Nginx (OpenResty + Lua) | v WordPress (Apache + PHP) | v MySQL (StatefulSet + Persistent Storage)

Monitoring stack:

Prometheus β†’ Alertmanager β†’ Grafana

πŸ“ Project Structure wordpress-k8s-devops-syfe/ β”œβ”€β”€ docker/ β”‚ β”œβ”€β”€ nginx/ β”‚ β”œβ”€β”€ wordpress/ β”‚ └── mysql/ β”‚ β”œβ”€β”€ helm/ β”‚ └── wordpress/ β”‚ β”œβ”€β”€ Chart.yaml β”‚ └── templates/ β”‚ β”œβ”€β”€ wordpress-deployment.yaml β”‚ β”œβ”€β”€ mysql-statefulset.yaml β”‚ β”œβ”€β”€ nginx-deployment.yaml β”‚ β”œβ”€β”€ services.yaml β”‚ β”œβ”€β”€ pv.yaml β”‚ └── pvc.yaml β”‚ β”œβ”€β”€ monitoring/ β”‚ └── prometheus/ β”‚ └── alerts.yaml β”‚ └── README.md

🧰 Prerequisites

Docker Desktop (with Kubernetes enabled)

kubectl

Helm

Git

Windows PowerShell

🐳 Docker Image Build (Custom Images) WordPress Image cd docker/wordpress docker build -t syfe-wordpress:1.0 .

Used for: Running WordPress with Apache + PHP inside Kubernetes.

MySQL Image cd docker/mysql docker build -t syfe-mysql:1.0 .

Used for: Persistent MySQL database (StatefulSet).

Nginx (OpenResty + Lua) cd docker/nginx docker build -t syfe-nginx-openresty:1.1 .

Used for: Reverse proxy in front of WordPress.

☸ Kubernetes Cluster Verification kubectl get nodes kubectl get pods kubectl get services

Used for: Verifying cluster readiness.

πŸ“¦ Helm Deployment (Main Application) Install WordPress Stack helm install my-release helm/wordpress

Upgrade (after changes) helm upgrade my-release helm/wordpress

Verify Pods kubectl get pods

Cleanup helm delete my-release

βœ… Application Verification (Correct Production Method)

Instead of browser-based verification, the app is validated inside the cluster.

kubectl exec -it deployment/nginx -- curl -I http://wordpress

Expected Output HTTP/1.1 302 Found Location: /wp-admin/install.php

This proves:

Nginx is running

WordPress is running

Apache & PHP are functional

MySQL connection works

Reverse proxy is correct

πŸ“Š Monitoring Setup (Prometheus & Grafana) Add Helm Repository helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update

Install Monitoring Stack helm install monitoring prometheus-community/kube-prometheus-stack

Verify Monitoring Pods kubectl get pods -l release=monitoring

πŸ” Grafana Access Get Admin Password (Windows PowerShell) [System.Text.Encoding]::UTF8.GetString( [System.Convert]::FromBase64String( (kubectl get secret monitoring-grafana -o jsonpath="{.data.admin-password}") ) )

Port Forward Grafana kubectl port-forward svc/monitoring-grafana 3000:80

Access:

http://localhost:3000

πŸ“ˆ Metrics Visualization Dashboards Used

Kubernetes / Compute Resources / Pod

Prometheus / Overview

Metrics include:

Pod CPU utilization

Pod memory usage

Kubernetes resource health

Note: Metrics may appear minimal on Windows Docker Desktop due to cAdvisor and node-exporter limitations.

🚨 Alerting Setup & Verification Check Loaded Alert Rules kubectl get prometheusrules

Open Alertmanager UI kubectl port-forward svc/monitoring-kube-prometheus-alertmanager 9093:9093

Access:

http://localhost:9093

Test Alert (Always Firing – Verification Only) alert: TestAlwaysFiring expr: vector(1)

Applied using:

kubectl apply -f test-alert.yaml

Verified in Alertmanager UI.

Cleanup:

kubectl delete -f test-alert.yaml

⚠ Known Limitations (Local Environment)

Running on Windows + Docker Desktop

node-exporter may crash

CPU graphs may appear empty

Port-forwarding may be unreliable

These are environment limitations, not application issues.

🧠 Production Improvements

In a real production environment:

nginx-prometheus-exporter for request & 5xx metrics

mysqld-exporter for MySQL metrics

Ingress controller

TLS & HPA

External alert receivers (Slack, Email, PagerDuty)

βœ… Assignment Completion Summary

βœ” Docker images created βœ” Kubernetes deployment βœ” Helm-based install/upgrade/delete βœ” Reverse proxy via Nginx βœ” Persistent storage βœ” Monitoring with Prometheus & Grafana βœ” Alerting with Alertmanager βœ” Proper verification & documentation

πŸ‘€ Author

Abhinav Prakash Infra & DevOps Intern Candidate

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published