Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate (CON214-R1) - AWS re:Invent 2018

348 views

Published on

Help our Mythical Mysfits find their forever homes! Our Mythical stack is aging and needs to be revamped ASAP. Join this workshop to get hands-on experience with Docker as you containerize the Mythical monolithic application, start breaking it apart into microservices, and deploy it using AWS Fargate. This is a foundational workshop on containers. No Docker experience required. Basic AWS experience recommended. For more advanced workshops in this series, consider CON321 and CON322.

  • Be the first to comment

Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate (CON214-R1) - AWS re:Invent 2018

  1. 1. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate Ed Chan Solutions Architect AWS C O N 2 1 4 Andy Mui Solutions Architect AWS
  2. 2. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Related Breakouts Tuesday, Nov 27* CON321-R1: Mythical Mysfits: DevSecOps with Docker and AWS Fargate 12:15pm – 2:30pm | MGM, Level 3, Premier Ballroom 320 Wednesday, Nov 28** CON322-R: Mythical Mysfits: Management and Ops with AWS Fargate 11:30am – 1:45pm | Mirage, Mirage Event Center C1 * Repeat session if full – CON321-R2 ** Repeat session if full – CON322-R1 See session catalog for times and locations.
  3. 3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Agenda Containers and Docker Amazon Elastic Container Service (Amazon ECS) AWS Fargate Monolith to Microservices Hands-on Lab
  4. 4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Containers and Docker A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.1 1 https://www.docker.com/resources/what-container Server Operating System Docker Engine AppA AppB AppC AppD
  5. 5. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Docker Architecture Docker daemon manages images, containers, networks, and volumes Docker CLI communicates with Docker daemon through a REST API Sample commands: docker build – build image from Dockerfile docker images – list images on Docker host docker run – run an image docker ps – list running containers docker stop – stop a running container Docker daemon / REST API Docker Host Container 1 Container 2 Container n Ubuntu Image Nginx Image Custom Image Docker Client Docker Registry Docker Hub
  6. 6. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Docker Image Read-only template Used to launch container Start with base image, additional data or dependencies added as layers Union file system merges layers into single image Instructions documented in Dockerfile kernel Base Image Image layer Image layer Image layer References parent image layer
  7. 7. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dockerfile FROM dockerfile/ubuntu RUN add-apt-repository -y ppa:nginx/stable && apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/* && echo "ndaemon off;" >> /etc/nginx/nginx.conf && chown -R www-data:www-data /var/lib/nginx VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"] WORKDIR /etc/nginx CMD ["nginx"] EXPOSE 80 Pull base image Install Nginx Define mountable directories Define working directory Define default command Expose ports yourimage:1.0.0 9c9e81692ae9 02071fceb21b b35224abf821 fbc63d321d73 8c2e06607696 E7829950cee3
  8. 8. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon ECS and AWS Fargate Scheduling and Orchestration Cluster Manager Placement Engine Availability Zone 1 Availability Zone 2 Availability Zone 3 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1 Container 1
  9. 9. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon ECS Constructs Cluster • Resource grouping and isolation • IAM permissions boundary Service • Maintains desired # of running tasks • Replaces unhealthy tasks • ELB integration Task • Running instance of a task definition • One or more containers Task Definition • Template used by Amazon ECS to launch tasks • Parallels to docker run parameters • Defines requirements – e.g. • CPU/Memory • Container image(s) • Logging • IAM role Container 1 Container 1 Container 1 Container 1Container 1 { ; } JSON
  10. 10. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Task Definition { "containerDefinitions": [ { "memory": 128, "portMappings": [ { "hostPort": 80, "containerPort": 80, "protocol": "tcp" } ], "essential": true, "name": "nginx-container", "image": "nginx", "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "ecs-log-streaming", "awslogs-region": "us-west-2", "awslogs-stream-prefix": "fargate-task-1" } }, "cpu": 0 } ], …continued… "networkMode": "awsvpc", "executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", "memory": "2048", "cpu": "1024", "requiresCompatibilities": [ "FARGATE" ], "family": "example_task_1" }
  11. 11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Microservices “A software architecture style in which complex applications are composed of small, independent processes communicating with each other using language-agnostic APIs. These services are small, highly decoupled and focus on doing a small task, facilitating a modular approach to system-building.” –Wikipedia Further reading: https://martinfowler.com/articles/microservices.html
  12. 12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Monolith to Microservices https://www.martinfowler.com/bliki/StranglerApplication.html
  13. 13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Hands-on Lab www.mythicalmysfits.com
  14. 14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Our mission: Ethical, mythical creature care. Our priority: Find homes for the abandoned, and often misunderstood, mythical creatures in our community. Help us find their forever homes! Your mission: Modernize and innovate on the Mythical stack. Lab 1: Containerize the monolithic application Lab 2: Deploy containers using AWS Fargate Lab 3: Scale and lay the foundation for microservices with an AWS Application Load Balancer (ALB) Lab 4: Our developers completed Project Cuddle which adds a “like” feature to the application. Since we want to move to a microservices design, help us break this functionality from the monolith and deploy it with AWS Fargate as its own containerized microservice. Welcome to Mythical Mysfits
  15. 15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lab 1: Build/Test Monolith Docker Image VPC AWS Cloud Public subnet Private subnet users
  16. 16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lab 2: Deploy with Fargate VPC AWS Cloud Public subnet Private subnet users
  17. 17. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lab 3: Scale with ALB VPC AWS Cloud Private subnet Private subnet users /
  18. 18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lab 4: Deploy ”Like” Microservice VPC AWS Cloud Private subnet Private subnet users / + /fulfill-like /like /fulfill-like /fulfill-like
  19. 19. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Instructions: http://www.mythicalmysfits.com/fargate Raise your hand if you have any questions. Feel free to work together with folks at your table. Near the end, we’ll hand out AWS credit codes to cover costs for the workshop. High-five your neighbors and have fun! Please fill out feedback forms and follow the clean-up instructions once you are done! Email us with comments/questions/feedback: aws-mythical-mysfits@amazon.com Logistics
  20. 20. Thank you! © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  21. 21. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

×