# freakynit/go-k8s architecture

> Architecture diagram of the GitHub repository freakynit/go-k8s, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/freakynit/go-k8s
- Repository: https://github.com/freakynit/go-k8s

## Overview

##### Main Components

a) Development Environment:
- Local Go Application
- Docker Build Environment
- Local Docker Registry (k3d registry)

b) Kubernetes Cluster Components:
- K3d Cluster
- LoadBalancer
- Worker Nodes (2 agents)
- Pods running the application
- Internal Registry Service

##### Development Zone
- Local registry at registry.localhost:5000

##### Container Registry Zone
- K3d private registry
- Image tagging and pushing flow

##### Kubernetes Cluster Zone
- Include:
- LoadBalancer (port 8081:80)
- API Server (port 6550)
- Two worker nodes
- Deployed pods
- Internal networking

Key Flows to Represent:

##### Build Flow
- Source → Docker Build → Tagged Image
- Tagged Image → Local Registry Push

##### Deployment Flow
- Registry → K8s Cluster
- Internal Pod Distribution

##### Request Flow
- External Request (Port 8081) → LoadBalancer → Pods

Use these visual elements:

- Rectangles: For containers and nodes
- Blue: Development components
- Green: Registry components
- Orange: Kubernetes components
- Gray: Network boundaries

Important Details to Include:

##### Port Mappings
- Registry: 5000
- API: 6550
- LoadBalancer: 8081:80

##### Network Configurations
- localhost mappings
- Registry connections
- LoadBalancer routing

##### Component Labels
- Image tags (freakynit/go-k8s:1.0.0)
- Registry URLs (k3d-registry.localhost:5000)
- Service names

Level of Detail:

##### The external access points

Additional Notes:

- Annotations for important configuration requirements (like /etc/hosts entries)
- Relationship between the local development environment and the cluster
- Scalability aspect with the multiple worker nodes

- How to build and deploy the application
- Where the various components are located
- How the networking is configured
- How external users access the service

Remember to maintain clarity while showing the complete flow from development to deployment and external access.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef dev fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef registry fill:#90EE90,stroke:#333,stroke-width:2px
    classDef k8s fill:#FFB347,stroke:#333,stroke-width:2px
    classDef network fill:#DCDCDC,stroke:#333,stroke-width:2px

    %% Development Zone
    subgraph Development
        GoApp["Go Application"]
        DockerBuild["Docker Build Process"]
        LocalReg["Local Registry<br/>registry.localhost:5000"]
    end

    %% Container Registry Zone
    subgraph Registry
        K3DReg["K3D Private Registry<br/>k3d-registry.localhost:5000"]
    end

    %% Kubernetes Cluster Zone
    subgraph K8sCluster["K3D Kubernetes Cluster"]
        APIServer["API Server<br/>(Port 6550)"]
        LoadBalancer["LoadBalancer<br/>(Port 8081:80)"]
        subgraph Workers["Worker Nodes"]
            Worker1["Worker Node 1"]
            Worker2["Worker Node 2"]
            Pod1["Pod 1"]
            Pod2["Pod 2"]
        end
    end

    %% Relationships
    GoApp --> DockerBuild
    DockerBuild --> LocalReg
    LocalReg --> K3DReg
    K3DReg --> APIServer
    APIServer --> Workers
    LoadBalancer --> Pod1
    LoadBalancer --> Pod2
    Worker1 --- Pod1
    Worker2 --- Pod2

    %% External Access
    ExternalReq(("External<br/>Requests")) --> LoadBalancer

    %% Legend
    subgraph Legend
        Dev["Development"]:::dev
        Reg["Registry"]:::registry
        K8s["Kubernetes"]:::k8s
        Net["Network"]:::network
    end

    %% Styling
    class GoApp,DockerBuild,LocalReg dev
    class K3DReg registry
    class APIServer,LoadBalancer,Worker1,Worker2,Pod1,Pod2 k8s
    class ExternalReq network

    %% Click Events
    click GoApp "https://github.com/freakynit/go-k8s/blob/main/main.go"
    click DockerBuild "https://github.com/freakynit/go-k8s/tree/main/Dockerfile"
    click LocalReg "https://github.com/freakynit/go-k8s/blob/main/k3d-registries.yaml"
    click Pod1 "https://github.com/freakynit/go-k8s/blob/main/k8s-deployment.yaml"
    click GoApp "https://github.com/freakynit/go-k8s/blob/main/go.mod"
```
