In my most recent post, I demonstrated how to deploy a containerised application onto ECS Fargate in a private subnet of a VPC and how to securely expose the deployed application via API Gateway. This time around I want to explore another COE (Container Orchestration Engine) that AWS has to offer, Amazon EKS. Both are managed, highly available and highly scalable container platforms. However, EKS is essentially Kubernetes as a service and thus requires an understanding of the powerful engine and its components in order to get the most out of it. It has a steeper learning curve than ECS with a more complex architecture despite some similarities. ECS has limited extensibility, whereas EKS has a wide variety of third-party and community add-ons.
In this post, I’ll walk-through the creation of a cluster with a public and private network mode using Terraform all the way through to deploying an application in our cluster and making it publicly accessible through a load balancer.
The code snippets in this post will only encompass the main resources. To have a better understanding of how everything fits together, please clone the source-code repository from here.
Our EKS Cluster Setup
I think this post will be most beneficial to you if you take a hands on approach. To do so, please make sure you have the following:
Amazon EKS (Amazon Elastic Container Service for Kubernetes) is a managed service that makes it easy for you to run Kubernetes on AWS without the need to setup, provision or maintain your own control plane. It is Kubernetes compliant and has a managed control plane.
AWS is responsible for provisioning, running, managing and auto-scaling the K8s master and etcd nodes across multiple AWS AZs (Availability Zones) for high availability.
The customer is responsible for adding and managing the EC2 worker nodes.
Amazon EKS cluters run within Amazon VPCs. In order to communicate with the cluster, you have to configure it to either have public endpoint access control, private endpoint access control or both. We’ll look at this in more detail later.
Before you run ahead and create an EKS cluster, you should be aware of the pricing that isn’t covered by the one free-tier that AWS offers. At the time of me writing this post, the pricing for an Amazon EKS cluster is $0.10 per hour. Also, you are also responsible for other resource costs like EC2, EBS, etc. Be sure to check this page for the latest pricing of this service.
I’m not going to give a detailed walk-through of this step because I’ve already done so in a separate post which you can refer to here under the same sub-heading. It is an important step nonetheless because it details the image that I’m going to pull from my pod in the private subnet node group.
All I’m doing is creating a Docker image for an NodeJS application server with a single route /test
that returns a response with the text “Working!”.
If you already have an image in ECR then you can skip this step.
#cloud-native #software-development #terraform #kubernetes #software-engineering