# kgeorga/hello-minikube-ruby architecture

> Architecture diagram of the GitHub repository kgeorga/hello-minikube-ruby, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kgeorga/hello-minikube-ruby
- Repository: https://github.com/kgeorga/hello-minikube-ruby

## Overview

##### Main Components
- Ruby Application: Represented by the file helloworld.rb. This is the core web service that listens (in this case on port 8080) and returns a “Hello world” message with the pod’s IP.
- Docker Container: Created from the helloworld.dockerfile. This image encapsulates your Ruby application and ensures it runs in an isolated, portable environment.
- Kubernetes Deployment: Defined in helloworld-deployment.yaml. This describes the deployment of the Ruby app as 2 replica pods, ensuring the service is scalable and highly available.
- Kubernetes Service: Configured with helloworld-service.yaml. It load balances the incoming traffic across the pods and exposes the service on a specified external port (31000) on the Kubernetes node.
- Kubernetes Cluster (Minikube): The deployment runs within a local Minikube cluster, representing the underlying infrastructure that manages pods, services, and networking.

##### Relationships and Interactions
– The local Docker setup (adjusted using “eval $(minikube docker-env)”) builds the container image which is then consumed by the Kubernetes Deployment.
– The Deployment creates two pods running instances of your Ruby app.
– The Kubernetes Service acts as the front-facing component, receiving incoming network traffic (requests on port 31000) and forwarding them to the pods (internally, to port 8080 or port 80 as defined in the service YAML).
– External traffic (from a browser or curl command) is directed to the Minikube node IP at port 31000 and then load balanced across the pods.

##### Architectural Patterns and Design Principles
– Containerization: The use of Docker to package the application ensures consistency across environments.
– Declarative Infrastructure: Kubernetes YAML files (for deployment and service) facilitate repeatable, declarative deployments.
– Load Balancing: Kubernetes service abstracts the individual pods behind a single endpoint while managing the load distribution.
– Separation of Concerns: The application logic (Ruby code) is separated from deployment concerns (Docker and Kubernetes configurations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Developer("Developer Machine"):::developer
    DockerCont("Docker Container (helloworld.dockerfile)"):::container
    Developer -->|"builds_image"| DockerCont
    click DockerCont "https://github.com/kgeorga/hello-minikube-ruby/blob/master/helloworld.dockerfile"

    %% Minikube Cluster Subgraph
    subgraph "Minikube Cluster"
        ClusterLabel("Minikube Cluster"):::cluster
        K8sDeployment("Kubernetes Deployment (helloworld-deployment.yaml)"):::deployment
        K8sService("Kubernetes Service (helloworld-service.yaml)"):::service
        Pod1("Pod 1 (Ruby App)"):::pod
        Pod2("Pod 2 (Ruby App)"):::pod
    end
    click ClusterLabel "https://github.com/kgeorga/hello-minikube-ruby/blob/master/README.md"
    click K8sDeployment "https://github.com/kgeorga/hello-minikube-ruby/blob/master/helloworld-deployment.yaml"
    click K8sService "https://github.com/kgeorga/hello-minikube-ruby/blob/master/helloworld-service.yaml"
    click Pod1 "https://github.com/kgeorga/hello-minikube-ruby/blob/master/helloworld.rb"

    DockerCont -->|"deploys_container"| K8sDeployment

    K8sDeployment -->|"creates"| Pod1
    K8sDeployment -->|"creates"| Pod2

    K8sService -->|"routes_traffic"| Pod1
    K8sService -->|"routes_traffic"| Pod2

    Browser("User/BROWSER"):::external
    Browser -->|"HTTP_request:31000"| K8sService

    %% Styles
    classDef developer fill:#FAD7A0,stroke:#333,stroke-width:1px;
    classDef container fill:#AED6F1,stroke:#333,stroke-width:1px;
    classDef deployment fill:#F5B7B1,stroke:#333,stroke-width:1px;
    classDef service fill:#F9E79F,stroke:#333,stroke-width:1px;
    classDef cluster fill:#D2B4DE,stroke:#333,stroke-width:1px;
    classDef pod fill:#E8DAEF,stroke:#333,stroke-width:1px;
    classDef external fill:#D5F5E3,stroke:#333,stroke-width:1px;
```
