/FastAPI

Primary LanguagePython

CI/CD Pipeline CI/CD Pipeline

Table of Contents

Getting Started

When committing to master branch, Github Actions triggers the below workflow:

  1. Setup
    • Checkout the repository.
    • Make an artifact and upload it.
  2. Lint & Test
    • Download the artifact.
    • Install Python.
    • Install the dependencies.
    • Lint with flake8.
    • Test with pytest.
  3. Build & Deploy
    • Download the artifact.
    • Start minikube.
    • Build Docker image.
    • Install Helm.
    • Lint helm chart.
    • Deploy helm chart.
    • Ensure the readiness of created pods.

Architecture Overview

Architecture diagram

Repository Structure

.
├── .github
│   └── workflows
|       └── pipeline.yaml   # Github Actions pipeline 
├── helm                    # Helm chart directory
│   ├── templates
│       ├── deployment.yaml
│       └── service.yaml
│   ├── .helmignore
│   ├── Chart.yaml
│   └── values.yaml
├── src                     # Source files
├── tests                   # Automated tests
├── Dockerfile
├── requirements.md
└── README.md

Improvements

There are a lot more things that we can add in the pipeline:

  • Environmental variables and secrets that are interpolated on the runner machine that runs the workflow.
  • Vulnerability scanning of the Docker image (e.g. snyk).
  • Testing of the service endpoint after the Kubernetes deployment.
  • Horizontal Pod autoscaling based on resource usage(cpu, memory) and metrics(client requests or I/O writes per second).
  • Execute the pipeline in higher environments after success.
  • Workflow notifications (e.g. Email, Slack)

References

  1. Events that trigger workflows
  2. Setup minikube as CI step in GitHub Actions
  3. Application deployment with Helm and GitHub actions to Kubernetes cluster