A project demonstrating how to deploy a WordPress site on an Azure Kubernetes Service (AKS) cluster using Kubernetes manifests, Kustomize, and persistent storage. This project showcases best practices for cloud-native application deployment.
- Overview
- Tech Stack
- Architecture
- Prerequisites
- Setup Instructions
- Project Highlights
- Contributing
- Issues
- License
This project automates the deployment of a WordPress website on Azure Kubernetes Service (AKS). It includes features such as:
Persistent storage for WordPress data. Configurable scalability using Kubernetes. Customizable environment through Kustomize.
- Azure Kubernetes Service (AKS): For managed Kubernetes clusters.
- Kustomize: To manage application environments.
- PersistentVolume (PV): For durable storage.
- Terraform: For infrastructure provisioning.
- ArgoCD: To automate application deployment and management.
This architecture consists of:
- WordPress Pod: Runs the WordPress application.
- PersistentVolume (Azure Disk): Ensures data persists even if the pod restarts.
- AKS Cluster: Hosts the application.
- LoadBalancer Service: Exposes WordPress to the internet.
Before deploying this project, ensure the following are installed and configured:
Terraform kubectl An Azure account
-
Clone the repository:
git clone https://github.com/Ahmedelsa3eed/Wordpress_AKS_Cluster.git cd Wordpress_AKS_Cluster
-
Create an Active Directory service principal account
az ad sp create-for-rbac --skip-assignment
-
Put the generated
appId
andpassword
at the terraform variables -
Provision the infrastructure using terraform
cd terraform terraform init terraform apply
-
Configure
kubectl
az aks get-credentials --resource-group $(terraform output -raw resource_group_name) --name $(terraform output -raw kubernetes_cluster_name)
-
Install Ingress
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.4/deploy/static/provider/cloud/deploy.yaml
-
Get the loadbalancer IP address to be used in Cloudflare
kubectl get svc -n ingress-nginx
-
Install argocd
kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
-
Setup argocd
kubectl apply -f argocd/ingress.yml
-
Create the
tls-secret
using one of the follwing methods:kubectl create -n argocd secret tls argocd-server-tls --cert=path/to/cert.pem --key=/path/to/key.pem
or run
kubectl apply -f argocd/tls-secret.yml
on this fileapiVersion: v1 kind: Secret metadata: name: tls-secret namespace: argocd type: kubernetes.io/tls data: tls.crt: <base64-of-tls.crt> tls.key: <base64-of-tls.key>
-
Create an
A
record on Cloudflare such that saeed-argocd points at the loadbalancer IP address -
Now argocd should open at https://saeed-argocd.cloud-stacks.com
-
Find the initial admin password using:
argocd admin initial-password -n argocd
-
Configure argocd to connect to this repository
-
Create another
tls-secret
at thedev
namespaceapiVersion: v1 kind: Secret metadata: name: tls-secret namespace: dev type: kubernetes.io/tls data: tls.crt: <base64-of-tls.crt> tls.key: <base64-of-tls.key>
-
Create an application that points at the path
overlays/dev
-
Now you could open the wordpress application at https://saeed-wordpress.cloud-stacks.com
- Scalability: Utilizes Kubernetes for scaling pods.
- Persistence: Employs Azure Disk for data durability.
- Modularity: Uses Kustomize for flexible configuration.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-branch-name
- Commit your changes:
git commit -m "Add a new feature"
- Push to your fork and submit a pull request.
If you encounter any problems, please create an issue.
This project is licensed under the MIT License. See the LICENSE file for details.