Getting Started with AWS EKS

Rohit Ranjan
5 min readJan 9, 2021

--

In this article, we’ll use Amazon Web Services to setup Kubernetes cluster and deploy and sample application.

Prerequisites:

AWS CLI:

https://cloudacademy.com/blog/how-to-use-aws-cli/

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

kubectl:

https://kubernetes.io/docs/tasks/tools/install-kubectl/

.aws directory in home, should have credentials & default location

.kube directory in home, should be present

Step 1:

Create IAM Role for EKS

Step 2:

Step 3:

Step 4:

Step 5: Role name is EKS-Cluster-Manager

Step 6: We’ll use this role for EKS cluster creation

Step 7: We’ll use AWS Cloudformation to create VPC . We can use templates shown in below link having 3 public subnets.

Step 8: Provide stack name for VPC, other details would be fetched from template file

Step 9: Below highlighted Outputs would be used in creation of nodes

Step 10: Let’s create EKS cluster

Step 11: Provide name for cluster, select Service created in Step 5

Step 12: Select VPC as shown in Step 9

Step 13: Click Next and create EKS cluster

Step 14: Wait for cluster to be active, also make sure AWS Geo locations has multiple availability zones which was Oregon (us-west-2) is this case

Step 15: Let’s update kubernetes config with below command where region was us-west-2 and cluster name was EKS

Step 16: We’ll now create nodes using Cloudformation and templates as shown below:

Step 17: Insert stack name, Cluster name, & select SG as shown in Step 9

Step 18: Select details shown below as per need, and NodeImageId can be selected from below link.

Above link presents EKS optimised Images as per Geo location. We used image optimised for us-west-2 (Oregon region) which is ami-0f9f033f2355ab1f8. You need to be logged in AWS Web UI Console to access web page hosting image.

Step 19: Select ssh key pair from EC2 instance service as shown below:

SSH Key pair is used to access nodes via ssh.

Step 20: Select VPC from Step 9

Step 21: Click on checkbox to acknowledge creation of IAM role

Checkbox

Step 22: IAM Role created

IAM Role

Step 23: Cloudformation Stacks

Step 24: We’ll add join node with EKS Cluster

vi ~/.kube/aws-auth-cm.yaml

We’ll add rolearn value obtained from arn is shown below:

Step 25: We’ll copy NodeInstanceRole value and paste it in below file

Step 26: We’ll run below command to connect Nodes with EKS

kubectl apply -f ~/.kube/aws-auth-cm.yaml

Deployment of Sample Application:

To launch an app on Kubernetes, we’ll use a deployment file and a service file.

Deployment can be reached on below link:

Service file can be reached on below link:

Note:

This deployment uses hello world docker images from below link:

https://hub.docker.com/r/dockercloud/hello-world/

Let’s launch app deployment & service with below commands:

kubectl apply -f helloworld.yaml

kubectl apply -f helloworld-service.yaml

Run below command to get service details, scroll down & copy hostname. Put copied hostname in browser and see running app

kubectl get svc service-helloworld -o yaml

References:

--

--

Rohit Ranjan
Rohit Ranjan

Written by Rohit Ranjan

Security Engineer, Open Source Enthusiast

No responses yet