Kubernetes has been the platform of choice for Container Orchestration
for years now. Amazon, despite being the industry leading Cloud Provider
only released Kubernetes as a Service
in 2018. In this post I will explain how a Kubernetes Cluster
can be created using command line on Amazon
. The source code for this post can be found here. Note that you need to know AWS
and Kubernetes
fairly well as I will only cover certain sections sparingly.
Prerequisites
- A Key Pair in your region
- A Hosted Zone in Route 53( e.g. example.com)
- An ACM Certificate for your domain( e.g. for example.com and *.example.com)
- AWS CLI
- eksctl
- helm 3
Basic EKS Setup
eksctl simplifies EKS setup. To create a simple cluster create eks-basic.yaml
from the gist below. Change publicKeyName
to the name of the Key Pair in your region( us-east-1
).
The execute the command below to create the cluster.
You will see a Kubernetes cluster made up of three t2-small
in us-east-1
upon successful completion of the command. As of now EKS only supports Spot Instances in Unmanaged Node Groups.
Production EKS Setup
Shell Scripts 0 through 4( *-deploy.sh
) will deploy and test the infrastructure. Do exercise caution when using the destroy scripts as the deletions will be permanent.
0-eks-deploy.sh
Deploys an EKS cluster with one On- Demand Node Group and one Spot Node Group, initializes Helm, installs a Spot Interrupt Handler and configures AWS ALB Ingress Controller and Cluster Autoscaler.
1-eks-test-deploy.sh
Deploys a Docker image, exposes it as a Service and adds an Ingress to it. DNS entries in your Hosted Zone will be updated when the Ingress gets created.
2-rds-deploy.sh
Deploys Aurora on 3 Private Subnets and creates a Service pointing to the Database Host.
3-rds-test-deploy.sh
Checks the connectivity to the Database from the Kubernetes Cluster by installing a MySQL Client Pod.
4-jenkins-deploy.sh
Deploys Jenkins in the given Namespace.
Final Thoughts
It is always a good idea to use a managed Kubernetes service if possible as maintaining the infrastructure does require substantial effort from the infrastructure team. DO NOT attempt to reinvent the wheel.