# cloudtechner/ct-k8s-canary-deployment architecture

> Architecture diagram of the GitHub repository cloudtechner/ct-k8s-canary-deployment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cloudtechner/ct-k8s-canary-deployment
- Repository: https://github.com/cloudtechner/ct-k8s-canary-deployment

## Overview

##### Project type and purpose
- This is a minimal Python web application packaged in a Docker container and used as a sample for demonstrating canary deployment on Kubernetes.
- The README describes building and pushing the image, then running it on a Kubernetes cluster to test traffic splitting between stable and canary versions.

##### File structure
- Top-level:
- Dockerfile – builds the Python app image
- requirements.txt – Python dependencies
- README.md – project description and setup
- src/app.py – the application entry point (likely a small HTTP server)
- No frontend or database directories—this is purely a backend microservice for deployment testing.

##### Extract additional insights from the README
- The focus is on canary deployment, so we must show both “stable” and “canary” workloads running in parallel.
- The image is pushed to a private registry, so include the registry interaction.

a. Main components to include
- Developer / CI system
- Container Registry (private image repository)
- Kubernetes cluster
- Ingress or LoadBalancer
- Service for the app
- Two Deployments (stable and canary)
- Pods for each Deployment
- End users or test clients generating traffic
b. Relationships and interactions
- Developer/CI builds Docker image → pushes to Container Registry
- Kubernetes Deployment controller pulls images from the registry
- Ingress or LoadBalancer routes HTTP traffic to the Service
- The Service load-balances requests across pods in both the stable and canary Deployments according to configured weights
- Monitoring/alerting subsystem (optional) observes canary metrics and can trigger promotion or rollback
c. Architectural patterns and design principles
- Microservice containerization
- Canary release pattern (traffic splitting)
- Declarative infrastructure as code (Kubernetes manifests)
- Immutable deployments (new pods for each version)
d. Key technologies/frameworks
- Python (Flask, FastAPI, or built-in HTTP server)
- Docker
- Kubernetes (Deployments, Services, Ingress)
- Private container registry (e.g., ECR, GCR, Artifactory)
- CI/CD tool (e.g., Jenkins, GitLab CI, GitHub Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CI/CD Pipeline"
        Dev["Developer / CI System"]:::infra
        DockerfileDef["Dockerfile"]:::infra
        Requirements["requirements.txt"]:::infra
        README["README.md"]:::infra
        Appsrc["src/app.py"]:::infra
    end

    Registry["Container Registry"]:::infra

    Dev -->|"build image"| DockerfileDef
    Dev --> Requirements
    Dev --> README
    Dev -->|"package app"| Appsrc
    DockerfileDef --> Registry
    Appsrc --> DockerfileDef
    Requirements --> DockerfileDef
    README --> Dev
    Dev -->|push image| Registry

    subgraph "Kubernetes Cluster"
        Ingress["Ingress / LoadBalancer"]:::infra
        Service["Service"]:::infra

        subgraph "Stable Deployment v1"
            StableDep["Deployment v1"]:::stable
            StablePod1["Pod v1"]:::pod
            StablePod2["Pod v1"]:::pod
            StableDep --> StablePod1
            StableDep --> StablePod2
        end

        subgraph "Canary Deployment v2"
            CanaryDep["Deployment v2"]:::canary
            CanaryPod1["Pod v2"]:::pod
            CanaryPod2["Pod v2"]:::pod
            CanaryDep --> CanaryPod1
            CanaryDep --> CanaryPod2
        end

        Ingress --> Service
        Service --> StablePod1
        Service --> StablePod2
        Service --> CanaryPod1
        Service --> CanaryPod2
        Registry --> StableDep
        Registry --> CanaryDep
    end

    TestClient["Test Clients / End Users"]:::infra
    Monitoring["Monitoring / Alerting"]:::infra

    TestClient --> Ingress
    StablePod1 --> Monitoring
    StablePod2 --> Monitoring
    CanaryPod1 --> Monitoring
    CanaryPod2 --> Monitoring

    click DockerfileDef "https://github.com/cloudtechner/ct-k8s-canary-deployment/tree/main/Dockerfile"
    click Requirements "https://github.com/cloudtechner/ct-k8s-canary-deployment/blob/main/requirements.txt"
    click README "https://github.com/cloudtechner/ct-k8s-canary-deployment/blob/main/README.md"
    click Appsrc "https://github.com/cloudtechner/ct-k8s-canary-deployment/blob/main/src/app.py"

    classDef stable fill:#ADD8E6,stroke:#000
    classDef canary fill:#90EE90,stroke:#000
    classDef infra fill:#D3D3D3,stroke:#000
    classDef pod fill:#F0F8FF,stroke:#000
```
