© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Containerize .NET Apps with Amazon EKS and AWS Fargate
Martin Beeby
W I N 3 0 9
Principal Technical Evangelist Amazon Web Services
Agenda
•
What are containers?
•
What is Docker?
•
Why containerize .NET?
•
What is Amazon Elastic Container Registry (Amazon ECR)
•
Amazon EKS
•
Amazon ECS
•
Wrap-up
For all the pictures go to:
thebeebs.co.uk/inception-slide
Tweet a picture of this slide to @thebeebs
with #inception
•
A software developer since I was 16
•
Developer for 20 years
•
Work at Amazon Web Services
MARTIN BEEBY
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Containers vs. VMs
App A App B App C
Bins/Libs Bins/Libs Bins/Libs Guest OS Guest OS Guest OS
Hypervisor Server (host)
App A App A App B App B App C App C Bins/Libs Bin/Libs
Container manager (e.g., Docker) Guest OS
Hypervisor
Server (host)
VMs Containers
Container benefits
•
Portable runtime application environment
•
Package application and dependencies in a single artifact
•
Run different application versions (dev/test/prod, different dependencies) simultaneously
•
Faster development and deployment cycles
•
Better resource utilization
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Docker containerization
•
Docker – Lightweight container virtualization platform
•
Provides tools to manage and deploy your applications
•
Over 80% of containers in 2018 run on Docker
•
Simplifies creation/management/operation of containers
•
Built by Docker, Inc.
•
Licensed under the Apache 2.0 license
Docker image
•
Read-only (immutable) base
•
Docker images built from base image, instructions to add layers on top
•
Union file systems to combine different layers into a single image
•
Used to launch container
•
Instructions stored in Dockerfile
bootfskernel Base image
Image Image Container
References parent image Image
Creating Docker container
2. Docker image 3. Docker container
FROM microsoft/windowsservercore RUN Add-WindowsFeature Web-server RUN Add-WindowsFeature NET-Frame...
COPY myapp /myappfiles 1. Dockerfile
f954msx83nc85b 50 MB k58cxbh48fj490d 300 MB akm34ks9dj5flf9d 500 MB ds8fmdsf895nlks 7 GB
Read/write layer
f954msx83nc85b 50 MB k58cxbh48fj490d 300 MB akm34ks9dj5flf9d 500 MB ds8fmdsf895nlks 7 GB
Dockerfile
FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build WORKDIR /src
COPY QuizUi/QuizUi.csproj QuizUi/
COPY WebApiLib/WebApiClient.csproj WebApiLib/
COPY QuizApiModels/QuizApiModels.csproj QuizApiModels/
COPY . .
WORKDIR /src/QuizUi
RUN dotnet publish QuizUi.csproj -c Release -o /app
FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS final WORKDIR /app
COPY --from=build /app . EXPOSE 80
ENTRYPOINT ["dotnet", "QuizUi.dll"]
Docker workflow
•
Pull base image from repository (e.g., Docker Hub)
•
Build an image from a Dockerfile
•
Inspect a container
•
Attach a volume to a container
•
Run a container
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why containers for .NET apps?
Better resource utilization
Deployment/
runtime consistency
Scaling
Two types of app
.NET Core
(Linux, Windows)
.NET
(Windows)
Windows container types
Windows Server Core
Support
traditional .NET applications
Nano Server Windows Windows IOT Core
Built for .NET
core applications Provides the full set of Windows APIs
Designed for IOT applications
Windows container types
Windows Server Core
mcr.microsoft.com/dotnet/framework/aspnet mcr.microsoft.com/dotnet/framework/runtime mcr.microsoft.com/dotnet/framework/wcf
Nano Server
mcr.microsoft.com/dotnet/core/aspnet:3.0 mcr.microsoft.com/dotnet/core/aspnet:2.1
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Fully managed
• Tight integration with Amazon EC
• Integration with Docker toolset
• AWS Management Console and AWS CLI
Highly available
• Amazon S3 backed
• Regional endpoints
Secure
• AWS Identity and Access Management (IAM) resource- based policies
• AWS CloudTrail audit logs
• Images encrypted at transit and at rest
Amazon ECR
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Choose your adventure
✓ .NET Core on Linux
✓ .NET Core on Windows
✓ .NET Framework on Windows
Amazon ECS
Amazon ECS
Amazon EKS
✓ .NET Core on Linux
✓ .NET Core on Windows
✓ .NET Framework on Windows
Amazon EKS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon ECS
•
Fully managed elastic service
•
Shared-state optimistic scheduling
•
Deep integration with other AWS services
Amazon Elastic Container Service (Amazon ECS) is a highly scalable, high-performance container
orchestration service that supports
Docker containers and allows you
to run and scale containerized
applications on AWS
Amazon ECS – EC2 cluster
EC2 instances
AMAZON AGENTECS Task
Container Task
Container
Agent communication service
Amazon ECS
API
Cluster management engine Key/value store AMAZON
AGENTECS Task
Container Task
Container
AMAZON AGENTECS Task
Container Task
Container
Internet balancerLoad
Load balancer
Amazon ECS: AWS Fargate
AWS Fargate is a technology that you can use with Amazon ECS to run
containers without having to manage servers or clusters of Amazon EC2
instances. With AWS Fargate, you no longer have to provision, configure,
or scale clusters of virtual machines to run containers.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Martin Beeby
Principal Technical Evangelist
@thebeebs
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.