A real-time chat application built with React, Socket.IO, Express, and Redis, deployed on a Kubernetes cluster and automated with Ansible.
.github/workflows/ # CI
app/
├── frontend/ # React frontend application
├── backend/ # Express backend server
k8s/ # Kubernetes manifests
├── dev/ # Development environment configs
├── argocd/ # ArgoCD configuration
ansible/ # Automation scripts
The application consists of three main components:
- Frontend: React application with Socket.IO client
- Backend: Express server with Socket.IO for real-time communication
- Database: Redis for message persistence
- Real-time messaging
- Persistent chat history
- User avatars (Auto generated using DiceBear API)
- Active users list
- Responsive design
- Containerized deployment
ansible-playbook ansible/playbook.yaml
The playbook will:
- Set up K3d cluster
- Deploy the application components
- Configure ArgoCD
- Set up port forwarding
- Frontend Deployment and Service
- Backend Deployment and Service
- Redis Deployment, Service, and PersistentVolume
- ArgoCD Application
This project uses two GitHub Actions workflows for the frontend and backend components:
- Triggered on pushes to
main
branch when changes occur inapp/frontend/**
- Steps:
- Checks out code
- Logs in to DockerHub
- Creates a tag using current timestamp
- Builds and pushes frontend Docker image
- Updates Kubernetes manifest with new image tag
- Commits and pushes the updated manifest
- Triggered on pushes to
main
branch when changes occur inapp/backend/**
- Steps:
- Checks out code
- Logs in to DockerHub
- Creates a tag using current timestamp
- Builds and pushes backend Docker image
- Updates Kubernetes manifest with new image tag
- Commits and pushes the updated manifest
ArgoCD handles the continuous deployment by monitoring the Git repository:
- Deployed in
argocd
namespace - Configured to watch the Git repository
- Automatically syncs changes from the
k8s/dev
directory - Manages deployments for:
- Frontend service
- Backend service
- Redis database
-
Code Changes:
- Developer pushes changes to
main
branch - Changes in frontend or backend directories trigger respective GitHub Actions
- Developer pushes changes to
-
CI Process (GitHub Actions):
- Builds new Docker image
- Pushes image to DockerHub
- Updates K8s manifests with new image tag
- Commits changes back to repository
-
CD Process (ArgoCD):
- Detects changes in K8s manifests
- Automatically syncs cluster state with Git repository
- Rolls out new deployments with updated images