# chadmcrowell/k8s-up-and-running architecture

> Architecture diagram of the GitHub repository chadmcrowell/k8s-up-and-running, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chadmcrowell/k8s-up-and-running
- Repository: https://github.com/chadmcrowell/k8s-up-and-running

## Overview

##### Project type and purpose
- This is an infrastructure-as-code project (“k8s-up-and-running”) that automates the provisioning of an AKS (Azure Kubernetes Service) cluster and its supporting resources, then deploys a set of microservices onto it.
- Key indicators: multiple IaC tool directories (terraform, bicep, azurecli, powershell), a kubectl/manifests folder with microservice YAMLs, and TLS/Ingress/AppGW scripts.

##### File structure
- Top-level IaC tool wrappers:
- terraform/ (main.tf, variables.tf, outputs.tf)
- bicep/ (main.bicep)
- azurecli/ (run.sh, scripts)
- powershell/ (template.json, run.ps1)
- Kubernetes deployment manifests under kubectl/manifests for each microservice (cart, catalogue, dispatch, payment, ratings, shipping, user, web) plus supporting infra (mongodb, mysql, rabbitmq, redis).
- appgw/ holds scripts and YAMLs to set up an Azure Application Gateway and ingress.
- tls/ holds cert-manager and ingress TLS configuration.

##### README
- Confirms that AKS provisioning can be done via Terraform, Bicep, Azure CLI, or PowerShell, then uses kubectl manifests to deploy workloads.

##### Main components
a. IaC Provisioning Layer
- Four interchangeable toolchains: Terraform, Bicep, Azure CLI scripts, PowerShell scripts.
- Each produces: an Azure Resource Group, AKS cluster, managed identities, networking (VNet, subnets), and optionally an Application Gateway.
b. Azure Platform Layer
- Resource Group containing:
- AKS Cluster (control plane is managed by Azure)
- Azure Application Gateway (appgw) with ingress controllers
- Azure DNS / Public IP / Load Balancer
- TLS Certificates (cert-manager ClusterIssuer in AKS)
c. Kubernetes Cluster Layer
- Namespaces (optional if manifests specify): e.g., default or per-service.
- Deployments + Services for each microservice:
- Frontend “web”
- Business services: cart, catalogue, dispatch, payment, ratings, shipping, user
- Datastores: mongodb, mysql, redis (StatefulSet), rabbitmq
- Ingress resources behind the Application Gateway (tls/new-ingress.yml)
d. External Consumers / CI-CD
- Developers triggering IaC scripts (shell or PowerShell)
- kubectl apply of manifests
- End-users calling the public endpoint via AppGW

##### Relationships and interactions
- IaC Tools → calls Azure Resource Manager APIs → deploy RG, AKS, networking, AppGW.
- AKS → schedules pods for each Deployment.
- Services expose pods internally.
- Ingress (configured for TLS via cert-manager) routes traffic from AppGW to Services.
- Microservices communicate via internal Service DNS names or via RabbitMQ.
- Datastores present as Services (mongodb, mysql, redis).

##### Architectural patterns and design principles
- Microservices architecture: each service in its own Deployment + Service.
- Infrastructure as Code: declarative provisioning via multiple tool options.
- GitOps-style: manifests stored in source control.
- Separation of concerns: IaC vs. workload manifests.
- TLS offloading and ingress centralization via AppGW and cert-manager.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layer 1: IaC Toolchain
    subgraph "IaC Toolchain"
        direction TB
        TF["Terraform"]:::iac
        BICEP["Bicep"]:::iac
        AZCLI["Azure CLI"]:::iac
        PS["PowerShell"]:::iac
    end

    %% Layer 2: Azure Platform
    subgraph "Azure Platform"
        direction TB
        RG["Resource Group"]:::azure
        AKS["AKS Cluster"]:::azure
        APPGW["Application Gateway"]:::azure
        DNS["Azure DNS / Public IP / LB"]:::azure
    end

    %% Layer 3: Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        direction TB
        CM["cert-manager"]:::k8s
        CI["ClusterIssuer"]:::k8s
        INGRESS["Ingress (TLS)"]:::k8s
    end

    %% Layer 4: Microservices & Datastores
    subgraph "Microservices & Datastores"
        direction TB
        subgraph "Microservices"
            direction TB
            WEB["web"]:::ms
            CART["cart"]:::ms
            CATALOGUE["catalogue"]:::ms
            DISPATCH["dispatch"]:::ms
            PAYMENT["payment"]:::ms
            RATINGS["ratings"]:::ms
            SHIPPING["shipping"]:::ms
            USER["user"]:::ms
        end
        subgraph "Datastores"
            direction TB
            MONGO["mongodb"]:::db
            MYSQL["mysql"]:::db
            REDIS["redis"]:::db
            RABBIT["rabbitmq"]:::db
        end
    end

    %% Connections IaC -> Azure
    TF -->|provisions| RG
    BICEP -->|provisions| RG
    AZCLI -->|provisions| RG
    PS -->|provisions| RG

    %% Azure internal
    RG --> AKS
    RG --> APPGW
    RG --> DNS
    APPGW -->|routes| AKS

    %% Kubernetes cluster components
    AKS --> CM
    CM --> CI
    CM --> INGRESS
    CI --> INGRESS

    %% Ingress to services
    INGRESS --> WEB
    INGRESS --> CART
    INGRESS --> CATALOGUE
    INGRESS --> DISPATCH
    INGRESS --> PAYMENT
    INGRESS --> RATINGS
    INGRESS --> SHIPPING
    INGRESS --> USER

    %% Services to datastores
    CART --> RABBIT
    CATALOGUE --> MYSQL
    DISPATCH --> RABBIT
    PAYMENT --> MYSQL
    RATINGS --> MONGO
    SHIPPING --> REDIS
    USER --> MONGO
    WEB --> CATALOGUE
    WEB --> USER

    %% Datastore deployments
    AKS --> MONGO
    AKS --> MYSQL
    AKS --> REDIS
    AKS --> RABBIT

    %% Click Events
    click TF "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/terraform/"
    click TF "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/terraform/main.tf"
    click TF "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/terraform/variables.tf"
    click TF "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/terraform/outputs.tf"
    click TF "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/terraform/run.sh"
    click BICEP "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/bicep/"
    click BICEP "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/bicep/main.bicep"
    click BICEP "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/bicep/run.sh"
    click AZCLI "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/azurecli/"
    click AZCLI "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/azurecli/run.sh"
    click AZCLI "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/azurecli/scripts/"
    click PS "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/powershell/"
    click PS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/powershell/template.json"
    click PS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/powershell/parameters.json"
    click PS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/powershell/run.ps1"
    click APPGW "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/appgw/"
    click APPGW "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/appgw/createAppGW.sh"
    click APPGW "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/appgw/ingress.yml"
    click APPGW "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/appgw/newWebSvc.yml"
    click CM "https://github.com/chadmcrowell/k8s-up-and-running/tree/main/tls/"
    click CM "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/tls/cert-manager.sh"
    click INGRESS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/tls/new-ingress.yml"
    click CM "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/tls/cluster-issuer.yml"
    click CM "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/tls/cert.yml"
    click WEB "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/web-deployment.yaml"
    click WEB "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/web-service.yaml"
    click CART "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/cart-deployment.yaml"
    click CART "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/cart-service.yaml"
    click CATALOGUE "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/catalogue-deployment.yaml"
    click CATALOGUE "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/catalogue-service.yaml"
    click DISPATCH "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/dispatch-deployment.yaml"
    click DISPATCH "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/dispatch-service.yaml"
    click PAYMENT "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/payment-deployment.yaml"
    click PAYMENT "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/payment-service.yaml"
    click RATINGS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/ratings-deployment.yaml"
    click RATINGS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/ratings-service.yaml"
    click SHIPPING "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/shipping-deployment.yaml"
    click SHIPPING "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/shipping-service.yaml"
    click USER "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/user-deployment.yaml"
    click USER "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/user-service.yaml"
    click MONGO "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/mongodb-deployment.yaml"
    click MONGO "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/mongodb-service.yaml"
    click MYSQL "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/mysql-deployment.yaml"
    click MYSQL "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/mysql-service.yaml"
    click REDIS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/redis-statefulset.yaml"
    click REDIS "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/redis-service.yaml"
    click RABBIT "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/rabbitmq-deployment.yaml"
    click RABBIT "https://github.com/chadmcrowell/k8s-up-and-running/blob/main/kubectl/manifests/rabbitmq-service.yaml"

    %% Styles
    classDef iac fill:#D6EAF8,stroke:#1B4F72;
    classDef azure fill:#D5F5E3,stroke:#1D8348;
    classDef k8s fill:#FCF3CF,stroke:#B7950B;
    classDef ms fill:#FADBD8,stroke:#922B21;
    classDef db fill:#E8F8F5,stroke:#117A65;
```
