# aws-samples/sample-aws-eks-auto-mode architecture

> Architecture diagram of the GitHub repository aws-samples/sample-aws-eks-auto-mode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-samples/sample-aws-eks-auto-mode
- Repository: https://github.com/aws-samples/sample-aws-eks-auto-mode

## Overview

##### Project Type & Purpose
- This is an infrastructure‐as‐code (IaC) repository using Terraform to provision an AWS EKS (Kubernetes) cluster in “Auto Mode” with multiple node pool types.
- It includes example Kubernetes manifests for Graviton, Spot, GPU, and Inferentia2 workloads.

##### File Structure
- Top‐level terraform/ folder: contains .tf files for VPC, EKS cluster, outputs, variables, versions.
- nodepool-templates/: Karpenter Provisioner templates for ARM (Graviton), Spot, GPU, Neuron node pools.
- examples/: sample Kubernetes YAMLs under subdirectories for GPU, Graviton, Neuron, Spot workloads.
- README.md: describes architecture, prerequisites, examples, security.

##### Main Components
a. Terraform Control Plane
- Terraform CLI (init, apply)
- Terraform modules (.tf files)
b. AWS Cloud Resources
- VPC with public/private subnets (automatically tagged)
- EKS Cluster (Auto Mode)
- Karpenter Provisioner (the Auto Mode engine)
- NodePools: Graviton (ARM64), Spot, GPU, Neuron
- Load Balancers: ALB (IngressClass), NLB (Service)
c. Kubernetes Control Plane & Resources
- API Server (kubectl configured via terraform output)
- Kubernetes namespaces (examples/gpu, /graviton, /neuron, /spot)
- Deployments/Services for sample workloads (2048 game, DeepSeek, Whisper)
- Ingress and Service YAMLs for ALB/NLB
d. External Services
- AWS IAM roles
- Third‐party ML models invoked by GPU/Neuron workloads

##### Relationships & Data Flows
- Terraform → AWS APIs: provisions VPC, EKS, subnets, IAM, tags.
- EKS Control Plane ↔ Karpenter Provisioner (CRDs) → automatically launches EC2 nodes in specified node pools.
- Kubernetes API → schedules Pods onto nodes (Graviton/Spot/GPU/Neuron).
- ALB Ingress → routes external traffic to Kubernetes Services → Pods.
- NLB Service → external network load balancer for high‐throughput services.
- kubectl ↔ API Server for deploying example YAMLs.

##### Architectural Patterns & Design Principles
- Infrastructure as Code: all AWS infra defined in Terraform.
- Cloud Native Auto Scaling: Karpenter dynamically provisions nodes based on workload.
- Separation of Concerns:
– nodepool-templates define compute parameters
– examples define application workloads
– terraform folder wires everything together
- Built‐in High Availability: multiple subnets, managed EKS control plane.
- Cost optimization: mixed instance types (Graviton, Spot, GPU, Inferentia2).

##### Essential Elements Checklist
- [ ] Clear labels for each Terraform module and AWS resource
- IaC/Control (Terraform)
- AWS Infrastructure
- Kubernetes Control Plane
- Worker Nodes & Workloads
- [ ] Annotations for key services (e.g., “Karpenter Auto-Scaling”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Terraform Control Plane"
        CLI["Terraform CLI"]:::terraform
        Main["main.tf"]:::terraform
        VPC["vpc.tf"]:::terraform
        EKS["eks.tf"]:::terraform
        Vars["variables.tf"]:::terraform
        Outputs["outputs.tf"]:::terraform
        Setup["setup.tf"]:::terraform
        Versions["versions.tf"]:::terraform
        CLI --> Main
        Main --> VPC
        Main --> EKS
        Main --> Vars
        Main --> Outputs
        Main --> Setup
        Main --> Versions
    end
    click Main "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/main.tf"
    click VPC "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/vpc.tf"
    click EKS "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/eks.tf"
    click Vars "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/variables.tf"
    click Outputs "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/outputs.tf"
    click Setup "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/setup.tf"
    click Versions "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/terraform/versions.tf"

    subgraph "AWS Cloud"
        style AWS fill:#fed976,stroke:#333,stroke-width:1px
        VPCres["VPC (public & private subnets)"]:::aws
        IAM["IAM Roles"]:::aws
        EKSres["EKS Cluster"]:::aws
        VPCres --> EKSres
        IAM --> EKSres
        subgraph "EKS Control Plane"
            APISrv["API Server"]:::k8s
            ETCD["etcd"]:::k8s
            Karp["Karpenter Provisioner"]:::k8s
            APISrv --> ETCD
            APISrv --> Karp
        end
        EKSres --> APISrv
    end

    Kubectl["kubectl"]:::external
    Kubectl --> APISrv

    subgraph "Worker Nodes & Workloads"
        subgraph "Graviton NodePool (ARM64)"
            GrpNP["Graviton NodePool"]:::nodepool
            IngressG["2048 Ingress"]:::workload
            App1["2048 Game Deployment"]:::workload
            GrpNP --> App1
            App1 --> IngressG
        end
        subgraph "Spot NodePool"
            SpotNP["Spot NodePool"]:::nodepool
            IngressS["2048 Ingress"]:::workload
            App2["2048 Game Deployment"]:::workload
            SpotNP --> App2
            App2 --> IngressS
        end
        subgraph "GPU NodePool"
            GPU_NP["GPU NodePool"]:::nodepool
            OWUI["Open-WebUI Deployment"]:::workload
            DeepProc["DeepSeek Deployment"]:::workload
            DNSvc["GPU NLB Service"]:::workload
            GPU_NP --> OWUI
            GPU_NP --> DeepProc
            DeepProc --> DNSvc
        end
        subgraph "Inferentia2 (Neuron) NodePool"
            NeuronNP["Neuron NodePool"]:::nodepool
            PVC["PVC"]:::workload
            WhisperComp["Whisper Compile"]:::workload
            WhisperUI["Whisper Gradio UI"]:::workload
            WhisperSvc["Whisper Service"]:::workload
            NeuronNP --> PVC
            PVC --> WhisperComp
            WhisperComp --> WhisperUI
            WhisperUI --> WhisperSvc
        end
    end

    APISrv --> GrpNP
    APISrv --> SpotNP
    APISrv --> GPU_NP
    APISrv --> NeuronNP

    IngressG -->|"HTTP"| ALB["ALB Ingress"]:::aws
    IngressS -->|"HTTP"| ALB
    DNSvc -->|"TCP"| NLB["NLB Service"]:::aws

    click GrpNP "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/nodepool-templates/graviton-nodepool.yaml.tpl"
    click SpotNP "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/nodepool-templates/spot-nodepool.yaml.tpl"
    click GPU_NP "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/nodepool-templates/gpu-nodepool.yaml.tpl"
    click NeuronNP "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/nodepool-templates/neuron-nodepool.yaml.tpl"

    click IngressG "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/graviton/2048-ingress.yaml"
    click App1 "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/graviton/game-2048.yaml"
    click IngressS "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/spot/2048-ingress.yaml"
    click App2 "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/spot/game-2048.yaml"
    click DNSvc "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/gpu/lb-service.yaml"
    click OWUI "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/gpu/open-webui.yaml"
    click DeepProc "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/gpu/vllm-deepseek-gpu.yaml"

    click PVC "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/neuron/pvc.yaml"
    click WhisperComp "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/neuron/whisper-compile.yaml"
    click WhisperUI "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/neuron/whisper-gradio-ui.yaml"
    click WhisperSvc "https://github.com/aws-samples/sample-aws-eks-auto-mode/blob/main/examples/neuron/whisper-service.yaml"

    classDef terraform fill:#8e44ad,stroke:#fff,color:#fff
    classDef aws fill:#f39c12,stroke:#333
    classDef k8s fill:#3498db,stroke:#fff,color:#fff
    classDef nodepool fill:#1abc9c,stroke:#fff
    classDef workload fill:#2ecc71,stroke:#fff
    classDef external fill:#7f8c8d,stroke:#fff,color:#fff
```
