Deploy a Web Application in Kubernetes with Terraform

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

Hey there, Gurus! Welcome to this hands-on lab. In this lab, you will first provision an EKS cluster with Terraform. Then, you will deploy an HTML5 web-based Pac-Man game that you can play in your browser to your EKS cluster with Terraform. Sounds like fun!

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Deploy Your EKS Cluster with Terraform
  1. In the AWS Management Console, in the IAM service, create an access key for the AWS CLI called Terraform_Access_Key.
  2. In the terminal, configure the AWS CLI to connect to your AWS instance.
  3. Download the EKS Terraform configuration.
  4. Unzip the EKS Terraform configuration zip file.
  5. Change into the eks directory and initialize your working directory.
  6. Deploy your EKS cluster with Terraform. (Note: This can take between 10 and 15 minutes.)
  7. Configure the Kubernetes CLI to use your EKS cluster context.
  8. Confirm your cluster is up and running.
Complete the Terraform Configuration
  1. Download the Pac-Man Terraform configuration.
  2. Unzip the Pac-Man Terraform configuration zip file.
  3. Change into the pac-man directory.
  4. Add the provided Docker image to your Pac-Man deployment configuration.
  5. Update the main Terraform configuration file to include your two modules and pass the pac-man namespace to them.
  6. Save your changes and initialize your pac-man working directory.
  7. Validate your configuration.
Deploy the Pac-Man Web Application with Terraform
  1. Apply the Terraform configuration and deploy the web application in the pac-man namespace.
  2. Confirm that your resources were deployed and are available.
  3. In a browser, launch the application and test that it’s working by playing some Pac-Man!
Scale the Kubernetes Web Application
  1. Change the replicas in your deployment configurations to 2 backend pods and 3 frontend pods.
  2. Apply the changes to the Pac-Man web application with Terraform.
  3. Confirm the changes were successfully applied.
  4. In the browser, refresh the application and test that it is still working as expected.
  5. Scale the application back down to 1 backend pod and 1 frontend pod.
  6. Confirm the changes were successfully applied.
  7. In the browser, refresh the application again and test that it is still working as expected.

Additional Resources

In this scenario, you are being asked to deploy an EKS cluster with Terraform. Once you have provisioned your cluster, you will then need to deploy a Kubernetes web application that allows you to play Pac-Man in your browser. It runs in Node.js and uses MongoDB as the backend database. You will need to deploy these resources in the pac-man namespace, using the provided Docker image. Once built, you will then need to use Terraform to scale the application up to 2 backend pods and 3 frontend pods, and then back down to 1 apiece like it was originally. Good luck!

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?