github-projects
tf-k8s-vm-cluster
What Is

Kubernetes Cluster Deployment with Terraform

This project provides a Terraform template for creating a Kubernetes (K8s) cluster on AWS. It is intended for testing and learning purposes, allowing users to experiment with a basic K8s setup on AWS infrastructure.

Prerequisites

Before deploying the cluster, ensure you have the following installed and configured:

  • Terraform: Install Terraform on your system.
  • AWS CLI: Installed and configured with user credentials that have permissions to create instances on AWS.

Configuration

Before running the Terraform script, update the following values in the Terraform files:

  1. AWS Secret Key Credentials: Provide valid AWS access credentials.
  2. AWS Region: Specify the region where you want to deploy the cluster.
  3. AMI ID: Use an AMI ID compatible with your chosen region.
  4. Security Group: Create a security group that allows all traffic, and update the security group ID in the configuration.
  5. Subnet ID: Provide a subnet ID within your chosen region.
  6. Instance Type: Select an instance type with at least 1 vCPU and 2 GB of RAM.

Architecture

The Terraform script creates the following resources:

  • 1 Master Node
  • 1 Worker Node

Pre-Created Resources

The following AWS resources should already exist:

  • Security Group: With rules to allow necessary traffic.
  • AWS Key Pair: For SSH access.
  • VPC and Subnet: Uses the default VPC and subnet.

Files in This Repository

  • main.tf: Main Terraform configuration file to set up the K8s cluster.
  • script.sh: Test script (can be ignored).
  • user-data-k8-master.sh: User data script to configure the master node.
  • user-data-k8-node1.sh: User data script to configure the worker node.
  • README.md: Project documentation.

How to Use This Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo-name.git
    cd your-repo-name
  2. Initialize the directory:

    terraform init
  3. Check formatting of the Terraform file:

    terraform fmt
  4. Validate the configuration:

    terraform validate
  5. Deploy the setup:

    terraform apply
  6. View the resources and configuration:

    terraform show
  7. To delete the infrastructure:

    terraform destroy


🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!