# exploitx3/setup-k8-with-ansible-and-terraform architecture

> Architecture diagram of the GitHub repository exploitx3/setup-k8-with-ansible-and-terraform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/exploitx3/setup-k8-with-ansible-and-terraform
- Repository: https://github.com/exploitx3/setup-k8-with-ansible-and-terraform

## Overview

##### Project Type Analysis
This is an Infrastructure as Code (IaC) automation project that uses Terraform for infrastructure provisioning and Ansible for configuration management to set up a Kubernetes cluster on AWS.

##### Main Components

A. Infrastructure Layer (Terraform-managed):
- AWS Cloud boundary
- VPC and networking components
- EC2 instances (Master and Worker nodes)
- Security groups
- Key pair management

B. Configuration Management Layer (Ansible-managed):
- Kubernetes master setup
- Kubernetes worker nodes setup
- Docker configuration
- Network policies

C. Kubernetes Cluster Components:
- Control plane (on master)
- Worker nodes
- kubectl access point

**[Infrastructure Provisioning Layer]**
- ↓
**[Configuration Management Layer]**
- ↓
**[Kubernetes Cluster Layer]**

##### Specific Elements

a) Infrastructure Layer:
- Terraform components with terraform-kubernetes-infrastructure/ structure
- EC2 instances with proper networking

b) Configuration Management Layer:
- Ansible playbook flow:
- setup_kubernetes.yml (initial setup)
- setup_kube_master.yml (master node configuration)
- setup_kube_nodes.yml (worker nodes configuration)

c) Kubernetes Cluster Layer:
- Master node with control plane components
- Worker nodes with kubelet
- External kubectl access point

##### Important Relationships

- Terraform to AWS infrastructure provisioning
- Ansible inventory generation from Terraform outputs
- Ansible playbook execution flow
- Kubernetes control plane to worker node communication
- External kubectl access path

##### Additional Details

- Notes about key pair management
- Remote access configuration flow
- Security group boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph AWS["AWS Cloud Environment"]
        subgraph InfrastructureLayer["Infrastructure Provisioning Layer"]
            TF[("Terraform")]:::terraform
            MainTF["Main Configuration"]:::terraform
            VarsTF["Variables"]:::terraform
            OutputsTF["Outputs"]:::terraform
            InventoryTF["Inventory Management"]:::terraform
            InventoryTPL["Inventory Template"]:::terraform
            
            TF --> MainTF
            TF --> VarsTF
            TF --> OutputsTF
            TF --> InventoryTF
            InventoryTF --> InventoryTPL
            
            subgraph Network["Network Components"]
                VPC["VPC"]:::aws
                SG["Security Groups"]:::aws
                KP["Key Pair Management"]:::aws
            end
            
            MainTF --> Network
            
            subgraph Instances["EC2 Instances"]
                Master["Master Node"]:::aws
                Workers["Worker Nodes"]:::aws
            end
            
            Network --> Instances
        end
        
        subgraph ConfigLayer["Configuration Management Layer"]
            Ansible[("Ansible")]:::ansible
            InitSetup["Initial Setup"]:::ansible
            MasterConfig["Master Configuration"]:::ansible
            WorkerConfig["Worker Configuration"]:::ansible
            AnsibleCfg["Ansible Config"]:::ansible
            
            Ansible --> InitSetup
            Ansible --> MasterConfig
            Ansible --> WorkerConfig
            Ansible --> AnsibleCfg
            
            InventoryTPL -.-> Ansible
        end
        
        subgraph K8sLayer["Kubernetes Cluster Layer"]
            ControlPlane["Control Plane"]:::kubernetes
            WorkerNodes["Worker Nodes"]:::kubernetes
            Kubectl["kubectl Access"]:::kubernetes
            
            ControlPlane --- WorkerNodes
            Kubectl --> ControlPlane
        end
        
        InitSetup -.-> Master
        MasterConfig -.-> ControlPlane
        WorkerConfig -.-> WorkerNodes
    end
    
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef terraform fill:#7B42BC,stroke:#232F3E,color:white
    classDef ansible fill:#EE0000,stroke:#232F3E,color:white
    classDef kubernetes fill:#326CE5,stroke:#232F3E,color:white
    
    click MainTF "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/terraform-kubernetes-infrastructure/main.tf"
    click VarsTF "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/terraform-kubernetes-infrastructure/variables.tf"
    click OutputsTF "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/terraform-kubernetes-infrastructure/outputs.tf"
    click InventoryTF "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/terraform-kubernetes-infrastructure/inventory.tf"
    click InventoryTPL "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/terraform-kubernetes-infrastructure/files/inventory.tpl"
    click InitSetup "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/ansible-setup-kubernetes/setup_kubernetes.yml"
    click MasterConfig "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/ansible-setup-kubernetes/setup_kube_master.yml"
    click WorkerConfig "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/ansible-setup-kubernetes/setup_kube_nodes.yml"
    click AnsibleCfg "https://github.com/exploitx3/setup-k8-with-ansible-and-terraform/blob/master/ansible-setup-kubernetes/ansible.cfg"
```
