Deploying a Web App Using Elastic Kubernetes Service in AWS

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

In this lab, you will be deploying a web app using Elastic Kubernetes Service (EKS) in AWS.

You will learn how to easily create a cluster with just a few commands.

Understanding how to create your cluster through the command line will give you the advantage of having granular control over your cluster and understanding exactly what’s going on under the hood.

For this lab, you should have a basic understanding of Kubernetes. This way, you have the basic knowledge and skills to comprehend what you will be achieving in this lab.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the Cluster

Create a two-node cluster.

Configure the Frontend on the Cluster

Use the provided YAML code to configure the frontend for the application.

Confirm the Site Is Working

Curl the load balancer’s DNS name to test that the cluster is working as expected and the website is functioning.

Test the High Availability Setup of the Cluster

Test the high availability setup of the cluster by terminating both worker node instances.

Additional Resources

You’re deploying a web app on Elastic Kubernetes Service (EKS) that consists of multiple nodes. This web app is made up of multiple microservices that are deployed as Kubernetes deployments on EKS. One of them is a frontend service that is responsible for displaying a website. Your mission is to set up this entire cluster and ensure that the web app is working as expected.

To accomplish this, you will complete the following tasks:

  • Create the cluster.
  • Configure the frontend on the cluster.
  • Test the cluster to ensure you can access the functioning website and have high availability.

Use the following commands to create the cluster:

Download AWS CLI version 2.

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

Install AWS CLI version 2.

sudo ./aws/install --bin-dir /usr/bin --install-dir /usr/bin/aws-cli --update

Download kubectl.

curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.25.6/2023-01-30/bin/linux/amd64/kubectl

Create the directory.

mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin

Download eksctl.

curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp

Create the cluster.

eksctl create cluster --name myeks --region us-east-1 --zones=us-east-1a,us-east-1b --nodegroup-name eks-workers --node-type t3.medium --nodes 2 --nodes-min 2 --nodes-max 4 --managed

Use the following YAML code to configure the frontend for the application:

apiVersion: v1
kind: Service
metadata:
  name: vote-service
  labels:
    app: vote
spec:
  selector:
    app: vote
  ports:
    - name: http
      port: 80
      targetPort: 80
    - name: udp
      port: 5000
      targetPort: 5000
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vote-deployment
  labels:
    app: vote
spec:
  replicas: 2
  selector:
    matchLabels:
      app: vote
  template:
    metadata:
      labels:
        app: vote
    spec:
      containers:
        - name: vote
          image: dockersamples/examplevotingapp_vote:before
          ports:
            - name: http
              containerPort: 80
            - name: udp
              containerPort: 5000

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?