Spin Up Kubernetes on AWS Under 30 min Prep

Moon
3 min readNov 21, 2020

You usually can get some free credits if this is your first time registering your AWS account, but this whole series should take less than 2 hours, so even if you pay for it out of your own pocket, it will be less than $0.20.

(You can see the last picture in this blog where I run my cluster for more than 10 hours and it only cost $0.78. With that being said, it does happen that you accidentally did not turn off your services and get charged $100 at the end of the month, but as long as you follow my instructions step by step, that should not happen. If you are interested in, I will show you extra steps on how to monitor and alert your bills at the end of the series. But for now, let’s not worry about it yet!)

Step 1. Set up your AWS account & Payment

Go to the AWS website and register an account as you would on any website.

Once you log in, you can see this overwhelming panel throwing everything that you don’t need at this moment. Ignore them and just type “billing” in the search bar on the top. You will end up on the billing page as shown on the second picture.

(As you can see, I spent only $0.78 for running a Kubernetes cluster for more than 10 hours)

Once you are on the billing page, you can go check if you have credit to use under the credit tab, or you can simply add your credit card. I know it’s generally not a good idea to add your credit card to any website unless you 100% needs it, but that’s how I was motivated to get familiar with billing dashboard and setting alert things like that.

Step 2. Install CLIs

You will need three CLIs to run your Kubernetes clusters. They are:

  • AWS CLI
  • kubectl
  • eksctl

(1) For Mac:

(2) For Windows

Download and install awscli as any other program: https://awscli.amazonaws.com/AWSCLIV2.msi

Then run the following command in your powershell:

mkdir kubectlbinary
cd kubectlbinary
curl -o kubectl.exe https://amazon-eks.s3.us-west-2.amazonaws.com/1.16.8/2020-04-16/bin/windows/amd64/kubectl.exe
C:\Users\KALYAN\Documents\kubectlbinary
kubectl version --short --client
kubectl version --client

Download and install eksctl as any other program: https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html#installing-eksctl

Step 3. Start your cluster

(You will need to wait ~15 min for step (1) and (4), so your prep time is 10 min, but the total cooking time is about 30 min)

(1) Create EKS Cluster without nodegroup

Copy the following commands to whatever terminal you are using

eksctl create cluster --name=demo-1 \
--region=us-east-1 \
--zones=us-east-1a,us-east-1b \
--without-nodegroup

(2) IAM OIDC Provider

Copy the following commands to whatever terminal you are using

eksctl utils associate-iam-oidc-provider \
--region us-east-1 \
--cluster demo-1 \
--approve

(3) Create Keypair

Use the command below to create a key called k8s-demo.pem

aws ec2 create-key-pair - key-name k8s-demo - query 'KeyMaterial' - output text > k8s-demo.pem

(4) Create Node Group

Make sure you are in the directory of your computer where the pem file above is create, then type the command below.

eksctl create nodegroup --cluster=demo-1 \
--region=us-east-1 \
--name=demo1-nginx \
--node-type=t3.medium \
--nodes=2 \
--nodes-min=2 \
--nodes-max=4 \
--node-volume-size=20 \
--ssh-access \
--ssh-public-key=k8s-demo \
--managed \
--asg-access \
--external-dns-access \
--full-ecr-access \
--appmesh-access \
--alb-ingress-access

(5) Verify it is running

eksctl get cluster

Type the command above you should see some result like this:

NAME  REGION
demo-1 us-east-1

(6) Delete the Cluster

To avoid further charges, you can delete you the cluster you just created by simply typing the command below.

eksctl delete cluster demo-1

--

--