Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized WordPress with Nginx Reverse Proxy

This project demonstrates a multi-container WordPress application using Docker Compose and Kubernetes.

The project includes Nginx as a Reverse Proxy, WordPress, MySQL, persistent storage, health checks, resource management, Metrics Server, Horizontal Pod Autoscaler (HPA), GitHub Actions, and Kubernetes manifests for local development with Kind.

Technologies Used

  • Docker
  • Docker Compose
  • Kubernetes (Kind)
  • Nginx
  • WordPress
  • MySQL
  • GitHub Actions
  • GitHub Secrets
  • Metrics Server
  • Horizontal Pod Autoscaler (HPA)

Architecture

  • Nginx acts as a Reverse Proxy.
  • WordPress runs in its own container.
  • MySQL runs in a separate container.
  • Containers communicate over a dedicated Docker network.
  • Data is persisted using Docker volumes.
  • Health checks monitor service availability.
  • Resource requests and limits are configured for Kubernetes workloads.
  • Metrics Server is used for resource monitoring.
  • HPA is used to automatically scale WordPress replicas based on CPU utilization.
  • CI validation is performed using GitHub Actions.

Architecture Diagram

Browser
    │
    ▼
Nginx (Reverse Proxy)
    │
    ▼
WordPress
    │
    ▼
MySQL

Kubernetes Deployment

This repository also contains a Kubernetes version of the application inside the k8s/ directory.

Included resources:

  • Namespace
  • ConfigMap
  • Secret
  • PersistentVolume (PV)
  • PersistentVolumeClaim (PVC)
  • Deployment
  • Service
  • Ingress
  • NGINX Ingress Controller
  • Resource Requests and Limits
  • Liveness and Readiness Probes
  • Horizontal Pod Autoscaler (HPA)

The Kubernetes deployment was tested locally using Kind.

Note: The included ingress-nginx.yaml uses a mirror registry because the official Kubernetes registry may be inaccessible in some regions.

Prerequisites

  • Docker
  • Docker Compose
  • Kind
  • kubectl

How to Run

cp .env.example .env
docker compose up -d

Access

Docker Compose

http://localhost:8080

Kubernetes

After deploying the Kubernetes manifests and configuring the local host entry:

http://wordpress.local

Configuration

  • Environment variables are managed using a .env file
  • Create your .env file by copying .env.example.
  • MySQL credentials and WordPress DB config are stored in environment variables

Persistence

  • WordPress data is stored using Docker volumes
  • MySQL data remains intact even after containers are stopped or removed

Troubleshooting

  • Check logs:
docker compose logs
  • Restart containers if needed:
docker compose restart

Project Structure

.
├── docker-compose.yml
├── nginx/
│   └── default.conf
├── k8s/
│   ├── namespace.yaml
│   ├── configmap.yaml
│   ├── secret.yaml
│   ├── pv.yaml
│   ├── pvc.yaml
│   ├── mysql-pv.yaml
│   ├── mysql-pvc.yaml
│   ├── mysql-deployment.yaml
│   ├── mysql-service.yaml
│   ├── wordpress-deployment.yaml
│   ├── wordpress-service.yaml
│   ├── wordpress-hpa.yaml
│   ├── ingress.yaml
│   ├── ingress-nginx.yaml
│   └── kind-config.yaml
└── README.md

What I Learned

  • Designing multi-container applications using Docker Compose
  • Managing service dependencies
  • Using volumes for persistent data
  • Configuring Nginx as a Reverse Proxy
  • Managing application traffic through a reverse proxy
  • Applying DevOps best practices for local development environments
  • Building CI pipelines using GitHub Actions
  • Managing sensitive configuration with GitHub Repository Secrets
  • Deploying applications on Kubernetes
  • Managing Kubernetes networking using Services and Ingress
  • Configuring Kubernetes resource requests and limits
  • Monitoring resource usage with Metrics Server
  • Configuring Horizontal Pod Autoscaling based on CPU utilization
  • Understanding Kubernetes autoscaling and replica management
  • Understanding Kubernetes QoS classes and resource scheduling
  • Testing CPU and memory resource constraints
  • Running Kubernetes locally with Kind

Continuous Integration

This project uses GitHub Actions to:

  • Validate the Docker Compose configuration
  • Start the application stack
  • Verify service availability using an HTTP health check

Sensitive configuration is securely managed using GitHub Repository Secrets.

About

DevOps-focused WordPress stack using Docker Compose and Kubernetes, featuring Nginx, MySQL, persistent storage, health checks, resource management, HPA autoscaling, Ingress, and GitHub Actions CI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors