This repository implements a GitOps workflow for managing both infrastructure and application deployments. It is an extension of a previous project, with a focus on CI/CD pipelines for both infrastructure and application stacks.
full-stack_gitops/
├── application/ # Application stack (frontend, backend, etc.)
├── infrastructure/ # Infrastructure as Code (Terraform, Ansible, etc.)
├── .github/workflows/ # CI/CD workflows
└── README.md # Project documentation
deployment: Used for deploying the application stack.infra_features: Feature branch for infrastructure development.infra_main: Main branch for infrastructure deployment.integration: Used for integrating and testing application changes.
The infrastructure CI/CD pipelines are defined in the .github/workflows/ directory and include the following workflows:
- Trigger: Push to
infra_featuresbranch. - Purpose: Validates Terraform configurations.
- Steps:
- Initialize Terraform.
- Format and validate Terraform code.
- Trigger: Pull request to
infra_mainbranch. - Purpose: Generates a Terraform execution plan and posts it as a PR comment.
- Steps:
- Initialize Terraform.
- Generate and comment on the Terraform plan.
- Generate cost estimates using Infracost.
- Trigger: Push to
infra_mainbranch. - Purpose: Deploys infrastructure using Terraform and configures monitoring with Ansible.
- Steps:
- Initialize and apply Terraform configurations.
- Run Ansible playbooks to configure monitoring.
The application CI/CD pipelines are defined in the .github/workflows/ directory. These workflows manage Docker image builds, pushes, and deployments.
- Trigger: Push to
integrationbranch. - Purpose: Builds and pushes Docker images to Docker Hub.
- Steps:
- Build and push Docker images for the frontend and backend.
- Update the
compose.app.yamlfile with the new image tags.
- Trigger: Push to
deploymentbranch. - Purpose: Deploys the application stack to the provisioned infrastructure.
- Steps:
- Clone the repository on the remote VM.
- Pull the latest changes from the
deploymentbranch. - Deploy the application stack using Docker Compose.
The monitoring stack is managed using Ansible and includes Prometheus, Grafana, and Loki. The ansible_monitoring.yaml workflow sets up the monitoring stack after the infrastructure is deployed.
- Trigger: Completion of the
Deploy infrastructureworkflow. - Purpose: Configures and deploys the monitoring stack.
- Steps:
- Install Ansible and required collections.
- Create Docker networks for the monitoring stack.
- Deploy the monitoring stack using Docker Compose.
- Docker and Docker Compose
- Terraform
- Ansible
- GitHub Actions
- Clone the repository:
git clone git@github.com:deltron-fr/full-stack_gitops.git
- Navigate to the repository:
cd full-stack_gitops
- Push changes to the
infra_featuresbranch to validate Terraform configurations. - Create a pull request to
infra_mainto review and plan infrastructure changes. - Merge the pull request to
infra_mainto deploy infrastructure.
- Push changes to the
integrationbranch to build and push Docker images. - Push changes to the
deploymentbranch to deploy the application stack.
- Add automated tests for the application stack.
- Implement advanced monitoring and alerting.
- Enhance security with automated vulnerability scanning.
This project is licensed under the MIT License. See the LICENSE file for details.