Skip to content

hyukjuns/fastapi-sample-webapp

Repository files navigation

FastAPI Sample API Server

Environments

  • Azure
    • Azure Kubernetes Service 1.28.13
    • Kubernetes Addons: Ingress NGINX Controller, ArgoCD, Argo Rollouts
    • Azure Container Registry
  • Github Repository
    • Application Source Code & Kubernetes Manifest
    • Github Actions Pipeline (CI)
  • Slack for Notification
  • Python > 3.11.x
  • FastAPI > 0.115.0
  • VSCode

CI Step (Github Actions)

File: docker-image.yml

Job 01

  1. Checkout repo
  2. Setup Python
  3. Setup pip cache (actions/cache@v3)
  4. Install Dependencies and PyTest Application
  5. Upload Pytest Results as Github Actions Artifacts
  6. Post to a Slack channel
  7. Approve / Deny (environment)

Job 02

  1. Checkout repo
  2. Setup Docker Buildx
  3. Login to ACR
  4. Build and Push Container Image to ACR (docker/build-push-action@v6.9.0) (registry type 빌드 캐시 사용)
  5. Modify Rollout Manifest by yq
  6. Post to a Slack channel

CD Step (GitOps) - Argo CD & Argo Rollouts

  1. Detect manifest change by Argo CD
  2. Auto Sync by Argo CD
  3. Blue / Green Deploy by Argo Rollouts
  4. Promote or Abort (Manually)
  5. Swap Active / Preview Service's Selector Hash
  6. Monitoring and rollback or not

cicd

FastAPI Sample Application

Directory: /app

  • main.py: 샘플 GET / POST / PUT / DELETE 구현

  • test_rest.py: 빌드 전 pytest를 위한 샘플 테스트 코드

Containerizing

Dockerfile

Kubernetes Manifests

Directory: kubernetes

Ingress NGINX Controller Installation

rollouts.yaml

ingress.yaml

Reference

About

python-sample-webapp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published