Code Monkey home page Code Monkey logo

eks-cluster's Introduction

EKS Cluster from scratch

This module deploys a complete publicly accessible EKS cluster in an empty AWS account. All that is required is to have an AWS account and user created, awscli configured, and kubectl installed.

By leveraging existing EKS and VPC modules from the terraform modules registry, this module itself is kept relatively simple.

Deploying this module

Use the following terraform.auto.tfvars to deploy a VPC, EIP, NAT gateway, routes, public/private subnets, security groups, NAT gateway, IAM roles & policies, EKS backplane, and two worker groups (one using on-demand instances, the other on spot instances).

NOTE: If you wish to deploy to an existing VPC, the VPC module can be disabled by adding create_vpc = false in the .tfvars and then existing VPC referenced using the existing_vpc_* variables. Note that all resources that would have been created by the VPC module must be present.

# terraform.auto.tfvars

region = "us-east-1"

cluster_name       = "demo"
kubernetes_version = "1.24"
ami_type           = "BOTTLEROCKET_x86_64"

vpc_cidr        = "10.0.0.0/16"
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

eks_managed_node_groups = [
  {
    name           = "demo-on-demand"
    instance_types = ["t3.small"]

    min_size     = 1
    max_size     = 1
    desired_size = 1
  },
  {
    name           = "demo-spot"
    instance_types = ["t3.small"]

    capacity_type = "SPOT"

    min_size     = 1
    max_size     = 1
    desired_size = 1
  },
]

Once the file has been added, run terraform plan to see what will be deployed. Then run terraform apply -auto-approve to deploy the infrastructure. This will take around 10-15 minutes.

Configuring kubectl

After the apply is complete, run the following to configure the Kubernetes client:

aws eks update-kubeconfig --name $(terraform output -raw cluster_name)

The nodes and pods can then be checked by running the following:

kubectl get nodes
kubectl get pod -A

Finally, run terraform destroy -auto-approve when you are ready to destroy all the created resources.

Module details

Requirements

Name Version
terraform ~> 1.3
aws ~> 4.50
cloudinit ~> 2.2
kubernetes ~> 2.16
random ~> 3.4
tls ~> 4.0

Providers

Name Version
aws 4.51.0
random 3.4.3

Modules

Name Source Version
eks terraform-aws-modules/eks/aws 19.5.1
vpc terraform-aws-modules/vpc/aws 3.19.0

Resources

Name Type
random_string.suffix resource
aws_availability_zones.available data source

Inputs

Name Description Type Default Required
ami_type The AMI type of the node groups. See EKS Node Group documentation for valid types. string n/a yes
cluster_name The name of the cluster. This will be given a random suffix. string n/a yes
create_vpc Set to false and use the existing_vpc_* variables to deploy to an existing VPC. bool true no
eks_managed_node_groups A list of EKS managed node groups.
list(object({
name = string

instance_types = list(string)

min_size = number
max_size = number
desired_size = number

capacity_type = optional(string, "ON_DEMAND") # Alternatively "SPOT"
labels = optional(map(string), {})

}))
n/a yes
existing_vpc_id Pass the vpc_id of an existing VPC. string null no
existing_vpc_subnet_ids Pass the subnet ids where the cluster will be deployed to. list(string) [] no
kubernetes_version The version to deploy on the EKS cluster. string n/a yes
private_subnets n/a list(string) n/a yes
public_subnets n/a list(string) [] no
region AWS region string n/a yes
vpc_cidr n/a string "10.0.0.0/16" no

Outputs

Name Description
cluster_endpoint Endpoint for EKS control plane
cluster_name Kubernetes Cluster Name
cluster_security_group_id Security group ids attached to the cluster control plane
region AWS region

eks-cluster's People

Contributors

im2nguyen avatar brianmmcclain avatar burdandrei avatar judithpatudith avatar robin-norwood avatar ejstreet avatar alanszlosek avatar duplo83 avatar danielcalvo avatar topfunky avatar liorrozen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.