Skip to content

Projeto Backend da Turma de Pós Graduação em Software Architecture da FIAP em 2024.

Notifications You must be signed in to change notification settings

software-architecture-fiap/tech-challenge

Repository files navigation

Tech Challenge - SOAT 2024 - #25

Este projeto é um sistema de gerenciamento de pedidos desenvolvido para uma lanchonete em expansão. A solução de software é projetada para ser responsiva tanto em plataformas Web quanto Mobile. O backend, documentado e acessível via Swagger, permite uma administração eficiente e integrada dos pedidos, garantindo escalabilidade e facilidade de manutenção.

Você encontrará todos os passos do nosso projeto através deste link na nossa Plataforma de Documentação.

Interrogate

Desenvolvido com

  • Python
  • FastAPI
  • Kubernetes
  • Docker
  • PostgresSQL
  • Typed with: pydantic

Contribuição

Open Issues Closed Issues Open Pulls Closed Pulls Contributors Activity


CI/CD using Github Actions

The pipeline build-and-deploy is designed to build and push container images to Amazon ECR and deploy them to an EKS cluster based on specific triggers.

Repository Integration with AWS Credentials

Note: This step is crucial to ensure a secure connection with AWS resources. Credentials are necessary for the pipeline to authenticate and interact with AWS ECR and EKS.

Update the repository settings under Secrets and variables > Actions with the following values:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_SESSION_TOKEN

Workflow Triggers

The pipeline is triggered by the following events:

  • Issue Comment: When a comment is created, edited, or deleted on an issue that contains /deploy-dev
  • Push: When code is pushed to the main branch.

Environment Variables

The following environment variables are defined for use throughout the pipeline:

  • AWS_REGION: The AWS region where resources are located (us-east-1).
  • ECR_REPOSITORY: The ECR repository name (app/web).
  • EKS_CLUSTER_NAME: The EKS cluster name (EKS-lanchonete-cluster).

Tasks

Build and Deploy

This job runs on ubuntu-latest and is executed if the event is an issue comment or a push to the main branch.

Steps

  1. Checkout Repository

    • Uses the actions/checkout@v4 action to check out the repository.
  2. Check for Deploy-Dev Comment

    • Checks if the event is an issue comment containing /deploy-dev and prints a message if true.
  3. Versioning Image

    • Determines the image tag based on the event type:
      • Production: using push events to the main branch, increments the semantic version, considering the main branch as production.
      • Development: it is triggered using the commit SHA with a -dev suffix.
  4. Configure AWS Credentials

    • Uses the aws-actions/configure-aws-credentials@v1 action to configure AWS credentials using secrets.
  5. Login to ECR Registry

    • Uses the aws-actions/amazon-ecr-login@v1 action to log in to the ECR registry.
  6. Build and Push the Container Image

    • Builds and pushes the container image to the ECR repository using the tag.
  7. Commit and Push Updated Version

    • Commits and pushes the updated version file if the event is a push to the main branch.
  8. Setup Kubeconfig

    • Sets up the kubeconfig for the EKS cluster using AWS CLI.
  9. Deploy Application to Kubernetes Cluster

    • Deploys the application to the Kubernetes cluster in the development namespace if the event is an issue comment containing /deploy-dev.
    • Deploys the application to the production namespace on the EKS cluster when a commit is pushed to the main branch after merging a pull request.

Deployment Logic

The deployment logic varies based on the environment:

  • Development Environment: Triggered by issue comments containing /deploy-dev.
  • Production Environment: Triggered by pushes to the main branch.

The deployment process includes:

  • Setting the environment and kustomize directory.
  • Checking and creating the namespace if it doesn't exist.
  • Updating the image in the kustomize configuration.
  • Applying the Kubernetes resources using kubectl.