Skip to main content

Deploying an Application to EKS

Hands-On Lab

 

Photo of Mark Richman

Mark Richman

AWS Training Architect II in Content

Length

01:00:00

Difficulty

Intermediate

Welcome to this hands-on AWS lab! In this lab, we will be deploying the nginx web server to an Elastic Container Service for Kubernetes (EKS) cluster.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Deploying an Application to EKS

Introduction

Welcome to this hands-on AWS lab! In this lab, we will be deploying the nginx web server to an Elastic Container Service for Kubernetes (EKS) cluster.

Connecting to the Lab

  1. Open your terminal application, and run the following command. (Remember to replace <PUBLIC_IP> with the public IP you were provided on the lab instructions page.)
    ssh cloud_user@<PUBLIC_IP>
  2. Type yes at the prompt.
  3. Enter your password at the prompt.

Clone the GitHub Repository

  1. Install Git.
    sudo yum install git
  2. Clone the repository.
    git clone https://github.com/linuxacademy/eks-deep-dive-2019.git
  3. Change to the eks-deep-dive-2019 directory.
    cd eks-deep-dive-2019/
  4. Change to the 2-LA1-Deploying-an-Application-to-EKS directory.
    cd 2-LA1-Deploying-an-Application-to-EKS
  5. List the contents of the directory.
    ll
  6. List the contents of the directory.
    ls -la

Create the Deployment

  1. Examine the deployment.yaml file.
    vim deployment.yaml
  2. Exit the vim text editor.
  3. Create the deployment.
    kubectl apply -f deployment.yaml
  4. Check the status of the deployment.
    kubectl get deployment nginx

Create the Service

  1. Examine the service.yaml file.
    vim service.yaml
  2. Exit the vi text editor.
  3. Create the service.
    kubectl apply -f service.yaml

Browse to the ELB's Public DNS Name

  1. Check the status of the service.
    kubectl get service nginx -o wide
  2. Test the connectivity.
    kubectl get service nginx -o json
  3. Install the jq JSON processor.
    sudo yum install jq
  4. Retrieve the DNS name of the ELB.
    kubectl get service nginx -o json | jq -r '.status.loadBalancer.ingress[].hostname'
  5. Assign the DNS name to a variable called ELB.
    ELB=$(kubectl get service nginx -o json | jq -r '.status.loadBalancer.ingress[].hostname')
    echo $ELB
  6. Run a curl request.
    curl -m3 -v $ELB
  7. Open a new tab in your web browser, and paste the DNS name into the address bar. Press Enter to load the page.
  8. You shoud see a "Welcome to Nginx!" message on the web page.
  9. Undeploy the application.
    kubectl delete -f service.yaml
    kubectl delete -f deployment.yaml

Conclusion

Congratulations, you've successfully completed this hands-on lab!