ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Follow publication

Member-only story

Build EKS cluster with Terraform

Nico Singh
ITNEXT
Published in
13 min readSep 4, 2020

--

Last Update ⏰ October 2024

Stuck behind a paywall? Click Here

Introduction

This post describes the creation of a multi-zone Kubernetes Cluster in AWS, using Terraform with some AWS modules. Specifically, we are going to use infrastructure as code to create:

  • A new VPC with multi-zone public & private Subnets, and a single NAT gateway.
  • A Kubernetes Cluster, based on Spot EC2 instances running in private Subnets, with an Autoscaling Group based on average CPU usage.
  • An Application Load Balancer (ALB) to accept public HTTP calls and route them into Kubernetes nodes, as well as run health checks to scale Kubernetes services if required.
  • An AWS Load Balancer Controller inside the Cluster, to receive & forward HTTP requests from the outside world into Kubernetes pods.
  • A DNS zone with SSL certificate to provide HTTPS to each Kubernetes service. This zone will be managed from Kubernetes by a service called External DNS.
  • A sample application to deploy into our Cluster, using a small Helm Chart.
EKS Cluster components diagram
diagram source code — made with a wonderful tool called Diagrams

The usage of official Terraform modules brings us simplicity of coding AWS components following the best practices from verified providers (A.K.A. do not reinvent the wheel), like Private Networks or Kubernetes Clusters.

Project structure

All Terraform definitions in this example are distributed between two modules:

  • Base: terraform module that creates VPC & EKS resources in AWS.
  • Config: terraform module that configures the Kubernetes components in the EKS Cluster (ingress controller, namespaces, spot termination handler, …).

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

--

--

Published in ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Responses (21)

Write a response