A comprehensive Ruby on Rails application demonstrating modern DevOps practices with Docker containerization, Kubernetes orchestration, ArgoCD GitOps deployment, and Tekton CI/CD pipelines.
This project showcases a full DevOps workflow for a Rails application with PostgreSQL database, featuring:
- Containerization: Docker multi-stage builds with separate app and database containers
- Orchestration: Kubernetes deployment with StatefulSet for PostgreSQL
- GitOps: ArgoCD for declarative continuous deployment
- CI/CD: Tekton pipelines for automated build and push workflows
- Ingress: NGINX ingress controller for traffic management
- Quick Start
- Docker Setup
- Kubernetes Deployment
- ArgoCD GitOps
- Tekton Pipelines
- Project Structure
- Documentation References
Tool | Version | Purpose |
---|---|---|
Docker | 20.10+ | Container runtime |
Docker Compose | 2.0+ | Multi-container orchestration |
Kubernetes | 1.20+ | Container orchestration |
Minikube | 1.25+ | Local Kubernetes cluster |
kubectl | 1.20+ | Kubernetes CLI |
ArgoCD | 2.5+ | GitOps deployment |
Tekton | 0.40+ | CI/CD pipelines |
# Clone the repository
git clone https://github.com/srikxcipher/rails_app.git
cd rails_app
# Docker deployment
docker pull srikant25/railsapp:latest
docker-compose up
# Kubernetes deployment
chmod +x k8s-scripts/*.sh
./k8s-scripts/get-all-up.sh
- Rails Application: Multi-stage Dockerfile with Ruby 3.2 and Rails 7
- PostgreSQL Database: Official PostgreSQL 15 image with custom initialization
- Networking: Docker Compose bridge network for service communication
# Ensure Docker daemon is running
sudo systemctl start docker
# Pull pre-built image
docker pull srikant25/railsapp:latest
# Start the application stack
docker-compose up -d
# View application
# Navigate to http://localhost:3000
├── Dockerfile # Multi-stage Rails application build
├── docker-compose.yaml # Multi-container orchestration
├── init.sql # PostgreSQL initialization script
└── bin/docker-entrypoint # Container entry point script
- Namespace:
rails-app
for resource isolation - PostgreSQL: StatefulSet with persistent volume claims
- Rails App: Deployment with rolling update strategy
- Services: ClusterIP for internal communication, NodePort for external access
- Ingress: NGINX controller for HTTP routing
Set permissions and execute deployment scripts:
# Set execution permissions
chmod +x k8s-scripts/*.sh
# Automated deployment sequence
./k8s-scripts/01-start-minikube.sh # Initialize Minikube cluster
./k8s-scripts/02-create-namespace.sh # Create rails-app namespace
./k8s-scripts/03-deploy-postgres.sh # Deploy PostgreSQL StatefulSet
./k8s-scripts/04-deploy-rails-app.sh # Deploy Rails application
./k8s-scripts/05-enable-and-deploy-ingress.sh # Configure ingress
./k8s-scripts/06-status-check.sh # Verify deployment status
# Access application via NodePort
minikube service webapp-service -n rails-app
# Connect to PostgreSQL for debugging
./k8s-scripts/07-connect-postgres.sh
# Check deployment status
kubectl get all -n rails-app
Resource | File | Purpose |
---|---|---|
PostgreSQL StatefulSet | kubernetes-files/dbdeploy.yaml |
Database persistence |
Database Service | kubernetes-files/dbservice.yaml |
Internal DB access |
Rails Deployment | kubernetes-files/webdeploy.yaml |
Application pods |
Web Service | kubernetes-files/webservice.yaml |
Load balancing |
Ingress Controller | kubernetes-files/ingress.yaml |
HTTP routing |
# Destroy all resources
./k8s-scripts/99-destroy-all.sh
ArgoCD continuously monitors the Git repository and automatically synchronizes the desired state with the Kubernetes cluster.
Component | File | Description |
---|---|---|
Application Definition | config/argocd/application.yaml |
ArgoCD app configuration |
Config Map | config/argocd/argocd-cm.yaml |
ArgoCD server settings |
RBAC Configuration | config/argocd/argocd-rbac-cm.yaml |
Role-based access control |
Manual Setup Guide | config/argocd/argo-cd-manual.txt |
Step-by-step instructions |
- Declarative Configuration: Infrastructure as Code approach
- Automated Sync: Continuous deployment from Git repository
- Rollback Capability: Easy reversion to previous application states
- Multi-Environment Support: Separate configurations for dev/staging/prod
- Installation and overview |
tekton/tekton-inst.txt
The Tekton pipeline automates the complete CI/CD workflow:
- Source Code Fetch: Clone repository from GitHub
- Container Build: Build Docker image using Kaniko
- Image Push: Upload to Docker Hub registry
- Deployment Trigger: Notify ArgoCD for automatic deployment
Resource | File | Purpose |
---|---|---|
Git Clone Task | tekton/git-clone-task.yaml |
Source code retrieval |
Kaniko Build Task | tekton/kaniko-task.yaml |
Containerless image building |
Pipeline Definition | tekton/pipeline.yaml |
Workflow orchestration |
Pipeline Execution | tekton/pipelinerun.yaml |
Runtime configuration |
Service Account | tekton/service-account.yaml |
Authentication setup |
Docker Credentials | tekton/docker-credentials.yaml |
Registry authentication |
# Initialize and execute Tekton components
./tekton/tek-init-script.sh
# Monitor pipeline execution
kubectl get pods --namespace tekton-pipelines --watch
# Access Tekton Dashboard
kubectl --namespace tekton-pipelines port-forward svc/tekton-dashboard 9097:9097
# Visit: http://localhost:9097
# Remove all Tekton resources
./tekton/tek-del-script.sh
rails_app/
├── app/ # Rails application code
├── config/ # Application & ArgoCD configuration
│ └── argocd/ # ArgoCD GitOps manifests
├── kubernetes-files/ # Kubernetes deployment manifests
├── k8s-scripts/ # Automated deployment scripts
├── tekton/ # CI/CD pipeline definitions
├── Dockerfile # Container build instructions
├── docker-compose.yaml # Local development stack
└── README.md # This documentation
Technology | Official Documentation | Quick Start |
---|---|---|
Docker | docs.docker.com | Get Started Guide |
Kubernetes | kubernetes.io | Learning Path |
Minikube | minikube.sigs.k8s.io | Installation Guide |
Tool | Documentation | Tutorials |
---|---|---|
ArgoCD | argo-cd.readthedocs.io | Getting Started |
Tekton | tekton.dev/docs | Tutorial |
Tekton Dashboard | tekton.dev/docs/dashboard | Installation |
NGINX Ingress | kubernetes.github.io/ingress-nginx | Deployment Guide |
Registry | Purpose | Access |
---|---|---|
Docker Hub | Public image repository | hub.docker.com/r/srikant25/railsapp |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.