How To Set Up Kubernetes in AWS Using EKS

Create the EKS cluster using the console / CLI

Then in the cloud shell run the following

aws eks update-kubeconfig --name {cluster_name} --region {aws_region}

Then create a Launch Template

After that, create an IAM role and security group for nodegroup

During the creation process, don’t choose any AMI, use instance type t3.medium ( or larger ) and use the Security group previously created.

After that, add the IAM role to the aws-auth config map. Commands are given below

curl -o aws-auth-cm.yaml https://s3.us-west-2.amazonaws.com/amazon-eks/cloudformation/2020-10-29/aws-auth-cm.yaml

Then edit the file and replace the rolearn with the IAM role arn

apiVersion: v1
kind: ConfigMap
metadata:
  name: aws-auth
  namespace: kube-system
data:
  mapRoles: |
    - rolearn: <ARN of instance role (not instance profile)>
      username: system:node:{{EC2PrivateDNSName}}
      groups:
        - system:bootstrappers
        - system:nodes

After that, run this command to apply.

kubectl apply -f aws-auth-cm.yaml

Then create nodegroup using the Launch Template.

If that is successful then you will see nodes running inside the EKS cluster.

Now you can deploy apps to the EKS via kubectl

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply