1 of 75

Module 8: Introducing Containers and Container Services

AWS Academy Cloud Developing

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

2 of 75

Section 1: Introduction

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

3 of 75

Module objectives

At the end of this module, you should be able to do the following:

  • Describe the history, technology, and terminology behind containers
  • Differentiate containers from bare-metal servers and virtual machines (VMs)
  • Illustrate the components of Docker and how they interact
  • Identify the characteristics of a microservices architecture
  • Recognize the drivers for using container orchestration services and the AWS services that you can use for container management
  • Host a dynamic website by using Docker containers
  • Describe how AWS Elastic Beanstalk is used to deploy containers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

3

4 of 75

Module overview

Sections

  1. Introduction
  2. Introducing containers
  3. Introducing Docker containers
  4. Using containers for microservices
  5. Introducing AWS container services
  6. Deploying applications with Elastic Beanstalk

Lab

  • Lab 1: Migrating a Web Application to Docker Containers
  • Lab 2: Running Containers on a Managed Service

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

4

Knowledge check

5 of 75

Café business requirement

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

5

Frank and Martha recently acquired a coffee bean supplier, and they would like to include the supplier’s inventory tracking system into the café's application infrastructure. Sofía is thinking about migrating the application database to containers to complete the integration.

6 of 75

Containers as part of developing�a cloud application

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

6

7 of 75

Section 2: Introducing containers

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

8 of 75

Shipping containers

Before shipping containers

  • Goods were shipped in a variety of vessels with no standardized weight, shape, or size.
  • Transporting goods was slow, inefficient, and costly.

After shipping containers

  • Uniformly sized shipping containers simplified loading, unloading, storing, and transferring between transport types.
  • Abstraction of shipment details improved efficiency, increased productivity, and reduced costs.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

8

9 of 75

A container is a standardized unit of software

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

9

    • Runtime engine
    • Application code
    • System tools
    • System libraries

10 of 75

Evolution of deployment models: �Bare-metal servers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

10

Host server

Host OS

Libraries

Applications A, B, C

Applications compete for server resources

Library versions must be shared across applications

Inflexible hardware costs

11 of 75

Evolution of deployment models:�VMs

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

11

Host server

Host OS

Virtualization platform

VM

Guest OS

Libraries

Application� A

VM

Guest OS

Libraries

Application�B

VM

Guest OS

Libraries

Application� C

Isolated applications

Isolated libraries

Better resource utilization

More OS maintenance

More server space for OS

12 of 75

Evolution of deployment models: Containers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

12

Host server

Host OS

Containerization platform

Shared libraries

Container

Application� A

Bins/libs

Container

Bins/libs

Application B

Container

Bins/libs

Application C

Better resource utilization

Shared OS kernel

Shared or isolated libraries

Highly portable ;�applications run identically across environments

Lightweight, efficient, and fast

13 of 75

Section 2 key takeaways

  • A container is a standardized unit of software that contains everything that an application needs to run.
  • Containers help to ensure that applications deploy quickly, reliably, and consistently regardless of the deployment environment.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

13

14 of 75

Section 3: Introducing Docker containers

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

15 of 75

Docker container virtualization platform

Lightweight container virtualization platform

Tools to create, store, manage, and run containers

Integration with automated build, test, and deployment pipelines

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

15

16 of 75

Docker container benefits

  • Portable runtime application environment
  • Application and dependencies can be packaged in a single, immutable artifact
  • Ability to run different application versions with different dependencies simultaneously
  • Faster development and deployment cycles
  • Better resource utilization and efficiency

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

16

17 of 75

Docker container components

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

17

Layer 1

Layer 2

Layer 3

Layer 4

Dockerfile

Plain text file that provides instructions to create a container image

Container image

Read-only template that is used to create writable containers

Container�Runnable instance of an image

Container registry�Private or public images that you can base other images on

Container layer

Thin read/write layer that is used to �make changes to the running container

18 of 75

Dockerfile simple example

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

18

# Start with the Ubuntu latest image

FROM ubuntu:latest

# Output hello world message

CMD echo "Hello World!"

19 of 75

Dockerfile example: �Start a Java application

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

19

# Start with open JDK version 8 image

FROM openjdk:8

# Copy the .jar file that contains your code from your system to the container

COPY /hello.jar /usr/src/hello.jar

# Call Java to run your code

CMD java –cp /usr/src/hello.jar

Org.example.App

20 of 75

Dockerfile example:�Common tasks

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

20

# Start with CentOS 7 image

FROM centos:7

# Update the OS and install Apache

RUN yum –y update && yum –y install httpd

# Expose port 80—the port that the web server “listens to”

EXPOSE Port 80

# Copy shell script and give it run permissions

ADD run-httpd.sh /run-httpd.sh

RUN chmod –v +x /run-httpd.sh

# Run shell script

CMD ["/run-httpd.sh"]

21 of 75

Each line of the Dockerfile adds a layer

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

21

# 1 Start with CentOS 7 image

FROM centos:7

# 2 Update the OS and install Apache

RUN yum –y update && yum –y install httpd

# 3 Expose port 80

EXPOSE Port 80

# 4 Copy shell script and give it run permissions

ADD run-httpd.sh /run-httpd.sh

RUN chmod –v +x /run-httpd.sh

CMD ["/run-httpd.sh"]

Image layers (read-only)

RUN yum –y update && yum –y �install httpd

EXPOSE 80

ADD run-httpd.sh /run-httpd.sh

RUN chmod –v +x /run-httpd.sh

Base: CentOS 7

1

2

3

4

4

22 of 75

Docker CLI commands

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

22

Command

Description

docker build

Build an image from a Dockerfile.

docker images

List images on the Docker host.

docker run

Launch a container from an image.

docker ps

List the running containers.

docker stop

Stop a running container.

docker start

Start a container.

docker push

Push the image to a registry.

docker tag

Tag an image.

Command

Description

docker logs

View container log output.

docker port

List container port mappings.

docker inspect

Inspect container information.

docker exec

Run a command in a container.

docker rm

Remove one or more containers.

docker rmi

Remove one or more images from the host.

docker update

Dynamically update the container configuration.

docker commit

Create a new image from a container's changes.

23 of 75

Example of docker build command

Build an image from a Dockerfile in the current directory, and name the image node_app

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

23

docker build --tag node_app .

Task

Docker command

Sending build context to Docker daemon 9.007MB

Step 1/7 : FROM node:11-alpine

11-alpine: Pulling from library/node

Successfully built a5886f101e12

Successfully tagged node_app:latest

Example output

24 of 75

Example of docker images command

List the images that your Docker client is aware of

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

24

docker images

Task

Docker command

Example output

REPOSITORY

TAG

IMAGE ID

CREATED

SIZE

<none>

node_app:latest

a5886f101e12

18 seconds ago

82.7MB

25 of 75

Example of docker run command

  • Create a container named node_app_1 from the image named node_app
  • Run in the background and print the container ID to the terminal
  • Publish container port 8000 to the host port 80 to make the container available to other services for HTTP

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

25

docker run -d --name node_app_1 -p 8000:80 node_app

Tasks

Docker command

Example output

5ed1ea04bcb58194100f71b2e7cd0aecab182313692ed833a6a700664994785f

docker ps

CONTAINER ID

IMAGE

COMMAND

CREATED

STATUS

PORTS

5ed1ea04bcb5

node_app

"docker-entrypoint.s…"

9 seconds ago

Up 7 seconds

0.0.0.0:8000->80/tcp

26 of 75

Example of docker exec command

  • Start an sh terminal session on a running container
  • List the files in the user/src/app directory
  • Exit the shell session on the running container

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

26

docker exec -it node_app_1 sh

Tasks

Docker command

Example output

/usr/src/app #

/usr/src/app # ls

�Dockerfile README.md app index.js network.template node_modules package-lock.json package.json public views

/usr/src/app # exit

27 of 75

Example of docker stop and docker rm commands

  • Stop the container
  • Remove the container

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

27

docker stop node_app_1 && docker rm node_app_1

Tasks

Docker command

Example output

node_app_1

node_app_1

28 of 75

Section 3 key takeaways

  • Docker containers are created from read-only templates, which are called images.
  • Images are built from a Dockerfile and often based on other images.
  • Containers are runnable instances of an image with a writable layer.
  • A container registry is a repository of images.
  • To manage your Docker images and containers, you can run Docker command line interface (CLI) commands from a Bash terminal.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

28

29 of 75

Lab 8.1: Migrating a Web Application to Docker Containers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

29

30 of 75

Lab: Scenario

Recently, the café owners acquired one of their favorite coffee suppliers. The acquired coffee supplier runs an inventory tracking application on an AWS account.

In this lab, you again play the role of Sofía, and you will work to migrate the application to run on containers.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

30

31 of 75

Lab: Tasks

  1. Preparing the development environment
  2. Analyzing the existing application infrastructure
  3. Migrating the application to a Docker container
  4. Migrating the MySQL database to a Docker container
  5. Testing the MySQL container with the node application
  6. Adding the Docker images to Amazon ECR

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

31

32 of 75

Lab: Final product

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

32

AWS Cloud9 EC2 instance (being used as a container host)

EC2 instance guest OS

Bins/libs

node app

Docker engine

Docker container

Network

connectivity

Bins/libs

mysql

Docker container

33 of 75

Begin Lab 8.1: Migrating a Web Application to Docker Containers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

33

~ 90 minutes

34 of 75

Lab debrief: �Key takeaways

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

34

35 of 75

Section 4: Using containers for microservices

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

36 of 75

Comparing monolithic�and microservice architectures

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

36

Storefront UI

Account service

Cart service

Shipping service

Data access service

Storefront UI (Node.js)

Account service (Node.js)

Cart service (Python)

Shipping service (Java)

Monolithic

Microservices

Database

Load balancer

Browser

Load balancer

Browser

37 of 75

Microservices and containers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

37

Microservices design

Container characteristics

  • Decentralized, evolutionary design
  • Smart endpoints, dumb pipes
  • Each container uses the language and technology that are best suited for the service.
  • Each component or system in the architecture can be isolated, and can evolve separately, instead of updating the system in a monolithic style.
  • Independent products, not projects
  • You can use containers to package all of your dependencies and libraries into a single, immutable object.
  • Designed for failure
  • Disposable
  • You can gracefully shut down a container when something goes wrong and create a new instance. You start fast, fail fast, and release any file handlers.
  • The development pattern is like a circuit breaker. Containers are added and removed, workloads change, and resources are temporary because they constantly change.
  • Development and production parity

  • Containers can make development, testing, and production environments consistent.
  • This consistency facilitates DevOps, in which a containerized application that works on a developer's system will work the same way on a production system.

38 of 75

Section 5: Introducing AWS container services

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

39 of 75

Challenges of managing containers at scale

  • State of containers
  • Scheduling of starts and stops
  • Resources available on each server
  • Maximizing availability, resilience, and performance

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

39

40 of 75

Container orchestration platforms

Scheduling

Placement

Service integration

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

40

41 of 75

Amazon ECS

Fully managed container orchestration service

  • Scales rapidly to thousands of containers with no additional complexity
  • Schedules placement across managed clusters
  • Integrates with third-party schedulers and other AWS services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

41

Amazon Elastic Container Service (Amazon ECS)

42 of 75

Amazon ECR

Fully managed container registry that you can use to easily store, run, and manage container images for applications that run on Amazon ECS

  • Scalable and highly available
  • Integrated with Amazon ECS and Docker CLI
  • Secure:
    • Encryption at rest
    • Integration with the AWS Identity and Access Management Service (IAM)

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

42

Amazon Elastic Container Registry (Amazon ECR)

43 of 75

Amazon ECS solution architecture

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

43

Select the launch type

Amazon �ECS

AWS �Fargate

Amazon�EC2

Other �container �registry

Amazon �ECR

Pull the container �image from �a registry

Define your�application

Manage �your containers

44 of 75

Amazon ECS with Fargate�or Amazon EC2

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

44

Docker engines (one per OS in the cluster)

Bins/libs

App 1

Bins/libs

App 2

Bins/libs

App 3

Containers

VM guest operating systems in the Amazon ECS cluster

Container instance 1

Container instance 2

Container instance 3

AWS manages

You manage

Amazon ECS cluster backed by Fargate

Amazon ECS cluster backed by Amazon EC2

You manage

Choose Amazon EC2:

  • More predictable resource requirements, or the option of using reserved instances to reduce costs
  • Large workloads that are optimized for price
  • Compliance with organizational security requirements
  • Excess Amazon EC2 capacity

Choose Fargate:

  • Services subject to wide swings in demand
  • Large workloads that are optimized for low overhead
  • Small test environments
  • Batch workloads that run on a schedule

45 of 75

Creating an Amazon ECR repository�and pushing an image

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

45

# Create a repository called hello-world

> aws ecr create-repository \

--repository-name hello-world \

--region us-east-1

# Build and tag an image

> docker build -t hello-world .

> docker tag hello-world:latest aws_account_id.dkr.ecr.us-east-1.amazonaws.com/hello-world:latest

# Authenticate Docker to your Amazon ECR registry

# You can skip the `docker login` step if you have amazon-ecr-credential-helper set up

> aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com

# Push an image to your repository

> docker push aws_account_id.dkr.ecr.us-east-1.amazonaws.com/hello-world:latest

46 of 75

Amazon EKS

Managed service that runs Kubernetes on �the AWS Cloud

  • Built with the Kubernetes community
  • Conformant and compatible
  • Secure by default

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

46

Amazon Elastic Kubernetes Service (Amazon EKS)

47 of 75

Amazon EKS

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

47

Amazon EKS

Run Kubernetes�applications

Connect to �Amazon EKS

Provision an �Amazon EKS �cluster

Amazon EC2

Deploy worker�nodes for your�Amazon EKS�cluster

Fargate

48 of 75

Section 5 key takeaways

  • Container orchestration services (or systems) simplify managing containers at scale.
  • Amazon ECS is a fully managed container orchestration service that you can use to launch containers to either Fargate or EC2 instances.
  • Amazon ECR is a fully managed container registry service.
  • Amazon EKS is a managed service that you can use to run Kubernetes in the cloud.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

48

49 of 75

Section 6: Deploying applications with�Elastic Beanstalk

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

50 of 75

Elastic Beanstalk

Service for deploying and scaling web applications and services

  • Automatically handles deployment details like capacity provisioning, load balancing, automatic scaling, and application health monitoring
  • Provides a variety of platforms on which to build your applications
  • Use to manage all of the resources that run your application as an environment

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

50

AWS Elastic Beanstalk

51 of 75

Elastic Beanstalk components

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

51

Component

Description

Application

Logical collection of Elastic Beanstalk components. Conceptually similar to a folder.

Application version

Specific, labeled iteration of deployable code for a web application.

Environment

Collection of AWS resources that run an application version.

Environment tier

Designation of the type of application that the environment runs. Determines what resources Elastic Beanstalk provisions to support it.

Environment configuration

Collection of parameters and settings that define how an environment and its associated resources behave.

Saved configuration

Template that you can use as a starting point for creating unique environment configurations.

Platform

Combination of an OS, programming language runtime, web server, application server, and Elastic Beanstalk components. You design and target your web application to a platform.

Elastic Beanstalk CLI

CLI for Elastic Beanstalk. Provides interactive commands that simplify creating, updating, and monitoring environments from a local repository.

52 of 75

IAM permissions in Elastic Beanstalk environments

Service role

  • Assigned during creation
  • Elastic Beanstalk assumes that it uses other services on your behalf
  • Default service role: �aws-elasticbeanstalk-service-role

Instance profile

  • Assigned during creation
  • Applied to instances that are launched in your environment
  • Default instance profile: �aws-elasticbeanstalk-ec2-role

User policies

  • Optionally assigned
  • Can be attached to users or groups who create and manage Elastic Beanstalk applications and environments
  • Two managed user policies are available to grant either full administrative access or read-only access

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

52

IAM roles assigned during environment creation

53 of 75

Service role policy example

"Effect": "Allow",

"Action": [

"elasticloadbalancing:DescribeInstanceHealth",

"elasticloadbalancing:DescribeLoadBalancers",

"elasticloadbalancing:DescribeTargetHealth",

"ec2:DescribeInstances",

"ec2:DescribeInstanceStatus",

"ec2:GetConsoleOutput",

"ec2:AssociateAddress",

"ec2:DescribeAddresses",

"ec2:DescribeSecurityGroups",

"sqs:GetQueueAttributes",

"sqs:GetQueueUrl",

"autoscaling:DescribeAutoScalingGroups",

"autoscaling:DescribeAutoScalingInstances",

"autoscaling:DescribeScalingActivities",

"autoscaling:DescribeNotificationConfigurations",

"sns:Publish"

],

"Resource": [

"*"

]

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

53

AWSElasticBeanstalkEnhancedHealth

54 of 75

Elastic Beanstalk simplifies container deployment

Getting started with �Amazon ECS

  1. Create a task definition
  2. Create and configure a cluster including:
    • EC2 instances
    • VPC settings
    • IAM role definition
  3. Create a service to run and maintain a specified number of instances of a task

Getting started with �Elastic Beanstalk

  1. Write a Dockerrun.aws.json file and provide your zipped code
  2. Select the platform for your language
  3. Launch your application

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

54

55 of 75

Multicontainer Docker platform

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

55

Elastic Beanstalk

Auto Scaling group, Amazon ECS cluster

Instance 1

Task 1-1

Instance 2

Task 1-2

app1.elasticbeanstalk.com:80

app1.elasticbeanstalk.com:9000

Elastic Load Balancing

56 of 75

Dockerrun.aws.json file

{

"AWSEBDockerrunVersion": 2,

"volumes": [

{

"name": "php-app",

"host": {

"sourcePath": "/var/app/current/php-app"

}

},

{

"name": "nginx-proxy-conf",

"host": {

"sourcePath": "/var/app/current/proxy/conf.d"

}

}

]

"containerDefinitions": [

{

"name": "php-app",

"image": "php:fpm",

"environment": [

{

"name": "Container",

"value": "PHP"

}

],

"essential": true,

"memory": 128,

"mountPoints": [

{

"sourceVolume": "php-app",

"containerPath": "/var/www/html",

"readOnly": true

}

]

}

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

56

57 of 75

Elastic Beanstalk deployment policies

All at once

  • Deploys the new version to each instance
  • Requires some downtime
  • Quickest deployment method

Rolling

  • Deploys to a batch of instances at a time
  • Avoids downtime
  • Minimizes reduced availability
  • Longer deployment

Rolling with batch

  • Launches an extra batch of instances, then performs a rolling deployment
  • Avoids reduced availability
  • Longer deployment than rolling

Traffic splitting

  • Launches a full set of new instances like an immutable deployment
  • Tests the health of the new version by using a portion of traffic while keeping the rest of the traffic served by the old version
  • Supports canary testing
  • No interruption of service if you must roll back

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

57

Immutable

  • Launches a second Auto Scaling group, and serves traffic to both old and new versions until the new instances pass health checks
  • Ensures that the new version always goes on new instances
  • Allows for quick and safe rollback
  • Longer deployment time

Faster

More control

58 of 75

Deployment option namespaces

aws:elasticbeanstalk:command

  • Choose the deployment policy
  • Set a timeout
  • Choose options for size and type of batches to use
  • Choose whether to cancel deployment on a failed health check

aws:elasticbeanstalk:trafficsplitting

  • Choose the percentage of traffic to go to new instances
  • Choose how long to wait before continuing to shift more traffic

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

58

59 of 75

Example of traffic splitting�(canary testing)

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

59

Temporary Auto Scaling group

ELB

Auto Scaling group

v1

v2

option_settings:

aws:elasticbeanstalk:command:

DeploymentPolicy: TrafficSplitting

aws:elasticbeanstalk:trafficsplitting:

NewVersionPercent: "15"

EvaluationTime: "10"

Example deployment configurations

15%

Health checks: 10 minutes

Elastic Beanstalk

15%

v1

v2

60 of 75

Blue/green deployments�on Elastic Beanstalk

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

60

Elastic Beanstalk environment (blue)

Elastic Beanstalk environment (green)

myapp.useast-1.elasticbeanstalk.com

myapp_new.useast-1.elasticbeanstalk.com

3

Swap the CNAMEs

1

Clone the environment

2

Deploy and test in the new environment

61 of 75

Section 6 key takeaways

  • You can use Elastic Beanstalk to manage all of the resources that run your application as an environment.
  • You can quickly launch a Docker multicontainer environment with Elastic Beanstalk without worrying about Amazon ECS configuration details.
  • Deployment options include traffic splitting and blue/green to support testing new versions.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

61

62 of 75

Lab 8.2: Running Containers on a Managed Service

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

62

63 of 75

Lab: Scenario

Sofía has containerized the coffee suppliers application, but wants to reduce the effort to maintain the application and improve its scalability.

As noted in the previous lab, Sofía wants to move the database to a managed database service rather than running it in a container.

Based on her research, she has made these decisions:

    • Use AWS Elastic Beanstalk to deploy the application website.
    • Use Amazon Aurora Serverless for the database. Sofía must retire the container-based MySQL database and load the required user, tables, and data into an Aurora Serverless database.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

63

64 of 75

Aurora Serverless

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

64

Amazon Aurora

Fully managed relational database engine that is compatible with MySQL and PostgreSQL

  • Part of the Amazon Relational Database Service�(Amazon RDS), a managed database service
  • Combines the performance and availability of�high-end commercial databases with the simplicity and cost-effectiveness of open-source databases
  • Offers Aurora Serverless, an on-demand configuration that automatically scales up or down based on traffic and shuts down when not in use

65 of 75

Lab: Tasks

  1. Preparing the development environment
  2. Configuring the subnets for Amazon RDS and Elastic Beanstalk to use
  3. Setting up an Aurora Serverless database
  4. Reviewing the container image
  5. Configuring communication between the container and the database
  6. Creating the application database objects
  7. Seeding the database with supplier data
  8. Reviewing the AM policy and role for Elastic Beanstalk
  9. Creating an Elastic Beanstalk application
  10. Configuring the API Gateway proxy

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

65

66 of 75

Lab: Final product

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

66

Public subnet 1

AWS

Cloud9

IDE

Region

VPC

ECR

Website image

Public subnet 2

Elastic Beanstalk

Classic

Load

Balancer

EC2 hosting

website image

EC2 hosting

website image

Deployment

Aurora Serverless

Aurora Serverless

Data

API

67 of 75

Begin Lab 8.2: Running Containers on a Managed Service

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

67

~ 90 minutes

68 of 75

Lab debrief: �Key takeaways

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

68

69 of 75

Module wrap-up

Module 8: Introducing Containers and Container Services

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

70 of 75

Module summary

In summary, in this module, you learned how to do the following:

  • Describe the history, technology, and terminology behind containers
  • Differentiate containers from bare-metal servers and VMs
  • Illustrate the components of Docker and how they interact
  • Identify the characteristics of a microservices architecture
  • Recognize the drivers for using container orchestration services and the AWS services that you can use for container management
  • Host a dynamic website by using Docker containers
  • Describe how Elastic Beanstalk is used to deploy containers

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

70

71 of 75

Complete the knowledge check

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

71

72 of 75

Sample exam question

A cloud architect wants to migrate a web application to containers. The team does not have much experience with AWS or containers, but the architect wants to get them started quickly to be able to experiment.

Which solution would be best?

  1. Use Elastic Beanstalk to launch a multicontainer Docker environment.
  2. Use Amazon ECR to host Docker images that they create from scratch.
  3. Configure EC2 instances with automatic scaling, and install Docker images on the instances.
  4. Configure Amazon ECS with a cluster of EC2 instances that run Docker containers.

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

72

73 of 75

Additional resources

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

73

74 of 75

Thank you

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon Web Services, Inc. Commercial copying, lending, or selling is prohibited. Corrections, feedback, or other questions? Contact us at https://support.aws.amazon.com/#/contacts/aws-training. All trademarks are the property of their owners.

75 of 75

Containers as part of developing�a cloud application

© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

75

AWS WAF �secures API endpoint

Café employees

Refresh cache per settings

CloudFront distribution

ElastiCache �for Memcached

AWS WAF �secures website

SNS

SQS

Suppliers

Coffee inventory

updates

Lambda

Step Functions �retrieves data from RDS and posts report to S3 with presigned URL

Amazon Cognito provides token for report requests

Amazon S3�

Developers

AWS Cloud9

CloudShell

AWS CLI

SDK for Python

Console

�bucket hosts café website

Café website users

Webpage �requests

Bucket policy

DynamoDB database stores products table

API Gateway REST API

Lambda function �does database lookups

Café employees

Elastic Beanstalk

ECR hosts Docker image

EC2 instance with Docker container runs coffee supplier website

Aurora Serverless on RDS stores supplier database