Simple Nginx website using EKS

Step 1: Create an IAM user for admin priviliges

https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html

Step 2: Launch an EC2 instance in your desired region and ssh into the instance.

https://docs.aws.amazon.com/quickstarts/latest/vmlaunch/step-1-launch-instance.html

Step 3: Install eksctl and kubectl using the links below:

https://docs.aws.amazon.com/eks/latest/userguide/eksctl.htmlhttps://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html

Step 4: Use eksctl to provision an EKS cluster with three worker nodes in your region

$ eksctl create cluster –name myeks1 –version 1.16 –region eu-central-1 –nodegroup-name my-workers –node-type t3.micro –nodes 1 –nodes-min 1 –nodes-max 1 –managed

Alternatively, you can create a cluster using a config file instead of flags.

First, create cluster.yaml file:

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
name: basic-cluster
region: eu-central-1

nodeGroups:

  • name: my-workers
    instanceType: t3.micro
    desiredCapacity: 3
    volumeSize: 20
    ssh:
    allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key
  • name: my-workers2
    instanceType: t2.micro
    desiredCapacity: 2
    volumeSize: 10
    ssh:
    publicKeyPath: ~/.ssh/ec2_id_rsa.pub

Next, run this command:

  eksctl create cluster -f cluster.yaml

If you needed to use an existing VPC, you can use a config file like this:

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
name: cluster-in-existing-vpc
region: eu-central-1

vpc:
subnets:
private:
eu-central-1a: { id: subnet-a45bf2cd }
eu-central-1b: { id: subnet-23945c58 }

nodeGroups:

  • name: my-workers
    labels: { role: workers }
    instanceType: t3.micro
    desiredCapacity: 3
    privateNetworking: true

Step 5 – Use the following command to view your cluster

eksctl get cluster

Step 6 – The following command will enable you to connect to your cluster. It allows kubectl to connect to the EKS cluster:

aws eks update-kubeconfig –name wordpress –region eu-central-1

Step 7 – sudo yum install git

Step 8 – git clonse https://github.com/ACloudGuru-Resources/Course_EKS-Basics

Step 9 – cd Course_EKS-Basics

Step 10 – kubectl apply -f ./nginx-svc.yaml

Step 11 – kubectl get service

Step 12 – kubectl apply -f ./nginx-deployment.yaml

Step 13 – kubectl get deployment

Step 14 – kubectl get pod

Step 15 – kubectl get rs

Step 16 – kubectl get node

Lastly, you can get access to your website using the loadbalancer DNS name.

No token or token has expired.