How abdullahishs/tf-k8s-project works
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.