This repository contains a CI/CD pipeline for a basic Flask-based to-do application. The pipeline automates the deployment process from testing and building Docker images to pushing them to a Harbor registry, followed by deploying to Google Kubernetes Engine (GKE) clusters. It includes performance testing to ensure application stability before deploying to production.
- App: A Flask-based to-do application.
- Requirements: Listed in
requirements.txt
(includes Flask, Pytest, and Gunicorn). - Dockerfile: Configures the app's production environment and exposes the app on port 80.
- Jenkinsfile: Defines the CI/CD pipeline stages, including testing, building, pushing, and deploying.
- Jenkins: Automates the CI/CD pipeline.
- Docker: Containerizes the application for deployment.
- Kubernetes (GKE): Manages deployment in both development and production clusters.
- Harbor: Serves as a secure, TLS-enabled Docker registry.
- k6: Provides performance testing to validate application stability.
- Check Environment Path: Verifies the environment path setup.
- Install Dependencies: Installs required dependencies for the application.
- Run Tests: Runs unit tests using
pytest
to ensure application functionality. - Build Docker Image: Builds a Docker image from the application code.
- Login to Harbor: Authenticates with Harbor to push the Docker image securely.
- Push to Harbor: Pushes the Docker image to the Harbor registry.
- Deploy to Dev Cluster: Deploys the image to the development Kubernetes cluster.
- k6 Performance Test: Executes performance tests to validate stability.
- Deploy to Prod Cluster: Deploys to the production cluster if all stages succeed.
-
Dockerfile: Configures the application environment, installs dependencies, and sets Gunicorn for production.
-
Jenkinsfile: Manages the entire CI/CD pipeline, with key steps such as testing, building, and deploying.
-
Kubernetes Deployment:
- Clusters: Sets up development and production clusters on GKE in autopilot mode.
- Configuration Files: Kubernetes deployment and service files manage app deployment across environments.
-
Harbor Registry:
- Registry Setup: Configured with TLS on Google Compute Engine for secure image storage.
- Credentials: Managed through Jenkins for secure access to the Harbor registry.
-
k6 Load Testing: Runs performance tests to verify the application can handle expected loads.
-
Clone the repository:
- Clone the GitHub repository and navigate to the project directory.
-
Build and run the Docker container:
- Build the Docker image and run the container locally to test the application.
-
Run tests locally:
- Use
pytest
to run unit tests and verify application functionality.
- Use
This CI/CD pipeline ensures a smooth, automated deployment workflow from development to production, providing testing, secure registry integration, and Kubernetes-based orchestration. The addition of k6
load testing makes the pipeline reliable and production-ready, ensuring stability before each release.