Thursday, March 14, 2024

GitOps Example with Github Action, AWS EKS, Terraform and Docker

 This project showcases a comprehensive GitOps workflow designed for deploying a web application onto an Amazon EKS cluster. It employs a dual-repository strategy and a set of automated CI/CD pipelines facilitated by Github Actions to achieve continuous integration and deployment seamlessly.


Technology Stack:

  • Terraform: An infrastructure as code (IaC) tool enabling the definition and provisioning of cloud resources via declarative configuration files.
  • AWS EKS: A managed service simplifying Kubernetes deployment on AWS without managing the control plane or nodes.
  • AWS ECR: A fully managed container registry facilitating storage, management, and deployment of container images on AWS.
  • Maven: A tool for managing build, testing, and deployment of Java applications.
  • SonarCloud: A cloud-based service for code quality and security analysis integrated with Github repositories.
  • Docker: A platform for building, running, and sharing applications using containers.
  • Helm: A Kubernetes package manager streamlining application definition, installation, and upgrading.

The project comprises two Github repositories and workflows:

IaC Repository

Contains Terraform code defining the EKS cluster and its dependencies.

Utilizes a Github workflow triggered on pushes to the staging or main branch, performing steps like syntax validation and infrastructure provisioning.

Application Repository

Houses the application source code, Dockerfile, and Helm chart.

Employs a Github workflow triggered on pushes to the main branch or manually, executing steps such as testing, image building, and deployment to the EKS cluster.

Configuration and Deployment

Ingress Resource: The Helm chart includes an Ingress resource defining external traffic routing to application pods.

DNS Settings: Guide provided for configuring DNS settings to map the Ingress controller load balancer.

Post-Workflow Steps

Upon completion of the workflow, the Ingress configuration becomes effective, allowing access to the deployed web application via the custom subdomain.

GitOps Principles

  • Infrastructure as code stored in Git repositories.
  • Automated deployments through CI/CD pipelines.
  • Declaration of desired state using Terraform and Helm charts.
  • Continuous code quality monitoring using SonarCloud.

Benefits

  • Increased automation, minimizing manual intervention and deployment errors.
  • Improved reproducibility, ensuring consistent and repeatable deployments.
  • Enhanced reliability with automated tests and code quality checks.
  • Scalability and flexibility to adapt deployments as needed.

Conclusion

This project exemplifies the use of Github workflows for automating web application deployment on EKS clusters using a variety of technologies. It showcases the effectiveness of GitOps principles, emphasizing automation, consistency, and reliability in deployment processes. Additionally, it highlights best practices in managing workflows using branches, conditions, secrets, and environment variables, resulting in a fully functional web application deployed on a scalable Kubernetes cluster.

0 comments:

Post a Comment