# abdullahishs/tf-k8s-project architecture

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

- Interactive diagram: https://gitdiagram.com/abdullahishs/tf-k8s-project
- Repository: https://github.com/abdullahishs/tf-k8s-project

## Overview

##### Project Type & Purpose
- The project is an infrastructure automation tool. Its purpose is to set up an EKS cluster and deploy Kubernetes resources (like a frontend deployment and a service) via Terraform.
- The README outlines clear steps for configuring the Terraform provider, deploying a Kubernetes deployment (ft-deploy with nginx pods), and creating a Kubernetes service (web-service). There’s also a CI/CD workflow in the GitHub Actions configuration (under .github/workflows).

##### Main Components
- Code Repository (GitHub) – This contains your Terraform configuration files, the GitHub Actions workflow file, and any related documentation.
- CI/CD Pipeline (GitHub Actions) – Defined in the .github/workflows directory, it handles running Terraform plan and apply, automating the infrastructure deployments.
- Terraform Configuration Files – Various .tf files like:
- provider.tf: Sets up the Hashicorp Kubernetes provider and AWS provider configuration.
- deployment.tf: Defines the Kubernetes deployment (ft-deploy) with the nginx container.
- service.tf: Creates the Kubernetes service (web-service).
- eks.tf, eks/eks_cluster.tf, eks/eks_nodes.tf, eks/iam_role_cluster.tf, eks/iam_role_nodes.tf, eks/variables.tf: These files handle provisioning of the EKS cluster including cluster configuration, node groups, IAM roles, etc.
- deployment.tf and service.tf refer to the application components deployed on the Kubernetes cluster.
- AWS Cloud Infrastructure – Represents the AWS EKS cluster. Mark the different AWS components:
- EKS Cluster: The control plane managed by AWS.
- Worker/Node Groups: The compute resources where your Kubernetes workloads run.
- IAM roles for both cluster and nodes.
- Kubernetes Resources – Within the cluster:
- Kubernetes Deployment “ft-deploy”: Comprising 5 replicas of pods running an nginx container.
- Kubernetes Service “web-service”: Exposing the deployment on NodePort (port 30080 mapping to container port 8080).

##### Relationships and Data Flow
- Start from the Code Repository where configuration files and infrastructure code live.
- The CI/CD pipeline (GitHub Actions workflow) automatically triggers Terraform commands (plan, apply).
- Terraform processes provider.tf and EKS cluster configuration files (eks/ directory) to build the AWS infrastructure (EKS cluster, IAM roles, etc.).
- Once the cluster is created, Terraform provisions Kubernetes resources using the Kubernetes provider (configured with the local kubeconfig path).
- The Kubernetes deployment and service are created on the cluster, making the application available.

##### Architectural Patterns & Design Principles
- Infrastructure-as-Code (IaC): The whole system uses declarative Terraform configurations to manage an EKS cluster and associated Kubernetes resources.
- Modularity and separation of concerns: Different configuration files and directories (eks folder vs. other tf files) clearly delineate between cluster setup and Kubernetes resource creation.
- CI/CD Integration: The presence of a GitHub Actions workflow indicates automation and continuous deployment principles.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Code Repository (GitHub)"
        CR1["Terraform Provider Configuration"] 
        CR2["Kubernetes Deployment Configuration (ft-deploy)"]
        CR3["Kubernetes Service Configuration (web-service)"]
        CR4a["EKS Cluster Provisioning (eks.tf)"]
        CR4b["EKS Cluster Directory (eks/)"]
        CR5["GitHub Actions Workflow"]
    end

    CI["CI/CD Pipeline (GitHub Actions)"]
    TF["Terraform Engine (IaC Process)"]

    subgraph "AWS Infrastructure"
        AW1["EKS Cluster (Control Plane)"]
        AW2["Worker/Node Groups"]
        AW3["IAM Roles (Cluster & Nodes)"]
    end

    subgraph "Kubernetes Cluster"
        KUBE1["Kubernetes Deployment (ft-deploy)"]
        KUBE2["Kubernetes Service (web-service)"]
    end

    %% Relationships
    CR5 -->|"triggers"| CI
    CI -->|"executes"| TF
    CR1 -->|"configures"| TF
    CR4a -->|"configures"| TF
    CR4b -->|"configures"| TF
    TF -->|"provisions"| AW1
    TF -->|"provisions"| AW2
    TF -->|"provisions"| AW3
    TF -->|"applies"| KUBE1
    TF -->|"applies"| KUBE2
    CR2 -->|"defines"| KUBE1
    CR3 -->|"defines"| KUBE2
    AW1 -->|"hosts"| KUBE1
    AW1 -->|"hosts"| KUBE2

    %% Click events
    click CR1 "https://github.com/abdullahishs/tf-k8s-project/blob/main/provider.tf"
    click CR2 "https://github.com/abdullahishs/tf-k8s-project/blob/main/deployment.tf"
    click CR3 "https://github.com/abdullahishs/tf-k8s-project/blob/main/service.tf"
    click CR4a "https://github.com/abdullahishs/tf-k8s-project/blob/main/eks.tf"
    click CR4b "https://github.com/abdullahishs/tf-k8s-project/tree/main/eks/"
    click CR5 "https://github.com/abdullahishs/tf-k8s-project/blob/main/.github/workflows/tf.yml"

    %% Styles
    classDef terraform fill:#F9E79F,stroke:#D35400,stroke-width:2px;
    classDef aws fill:#AED6F1,stroke:#2E86C1,stroke-width:2px;
    classDef k8s fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef ci fill:#FCF3CF,stroke:#F39C12,stroke-width:2px;

    class CR1,CR4a,CR4b,TF terraform;
    class CR2,CR3,KUBE1,KUBE2 k8s;
    class CR5,CI ci;
    class AW1,AW2,AW3 aws;
```
