Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dear AWS Please Run My Containers for Me

Dear AWS Please Run My Containers for Me

Using Amazon Elastic Container Service (ECS) with AWS Fargate.

tiffany jernigan

June 12, 2018
Tweet

More Decks by tiffany jernigan

Other Decks in Technology

Transcript

  1. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. dear aws please run my containers for me t iffa n y je r n ig a n t iffa n y fa y j
  2. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J OUR JOURNEY
  3. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J AMAZON EC2
  4. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J DOCKER EC2 Instance Containers Customers started containerizing applications
  5. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J Containers made it easy to build and scale cloud-native applications
  6. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J Customers needed an easier way to manage large clusters of instances and containers
  7. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J AMAZON ELASTIC CONTAINER SERVICE Cluster Management as a hosted service Scheduling and Orchestration Cluster Manager Placement Engine
  8. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J PRODUCTION WORKLOADS ON AWS DEEP INTEGRATION WITH AWS SERVICES AWS VPC networking mode IAM roles Load Balancers CloudWatch Service Discovery ADVANCED TASK PLACEMENT AND SCHEDULING MANAGE VIA CONSOLE OR CLI
  9. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J BUT CLUSTER MANAGEMENT IS ONLY HALF THE EQUATION… ECS Agent Docker Engine OS EC2 Instance
  10. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Scheduling and Orchestration Cluster Manager Placement Engine ECS AMI Docker Engine ECS Agent EC2 Instance ECS AMI Docker Engine ECS Agent EC2 Instance ECS AMI Docker Engine ECS Agent EC2 Instance
  11. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J INTRODUCING AWS FARGATE MANAGED BY AWS No EC2 Instances to provision, scale or manage ELASTIC Scale up & down seamlessly Pay only for what you use INTEGRATED with the AWS ecosystem: VPC Networking, Elastic Load Balancing, IAM Permissions, CloudWatch, Service Discovery, and more
  12. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J AWS CONTAINER SERVICES LANDSCAPE MANAGEMENT Deployment, Scheduling, Scaling & Management of containerized applications HOSTING Where the containers run Amazon Elastic Container Service Amazon Elastic Container Service for Kubernetes Amazon EC2 AWS Fargate IMAGE REGISTRY Container Image Repository Amazon Elastic Container Registry
  13. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J FOCUS FOR THIS TALK MANAGEMENT Deployment, Scheduling, Scaling & Management of containerized applications HOSTING Where the containers run Amazon Elastic Container Service AWS Fargate
  14. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J HOW DO I RUN CONTAINERS ON FARGATE? • Primitives • Compute • Networking • IAM • Container Registries • Cloudformation • Visibility & Monitoring • Storage
  15. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J Define application containers: Image URL, CPU & Memory requirements, etc. register Task Definition create Cluster • Infrastructure Isolation boundary • IAM Permissions boundary run Task • A running instantiation of a task definition • Use FARGATE launch type create Service Elastic Load Balancer • Maintain n running copies • Integrated with ELB • Unhealthy tasks automatically replaced PRIMITIVES
  16. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J RUNNING FARGATE CONTAINERS WITH ECS Use ECS APIs to launch Fargate containers Easy migration – Run Fargate and EC2 launch type tasks in the same cluster Same Task Definition schema
  17. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J { "family": “nginx-demo", "containerDefinitions": [ { "name":“nginx", "image":”nginx" } ] } JSON document Contains a list of up to 10 container definitions All containers are co-located on the same host Each container definition has: • A name • Image URL (Amazon ECR or public images) • And more…stay tuned! Task Definition Snippet TASK DEFINITION
  18. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J COMPUTE
  19. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J CPU & MEMORY { ”cpu": “1 vCPU”, ”memory": “2 gb”, "networkMode": “awsvpc", "compatibilities": [”FARGATE", ”EC2"], "placementConstraints": [], "containerDefinitions": [ { ... Task level resources • Configurable independently (within a range) Dimensions: Task level CPU and memory Per-second billing Task Level Resources
  20. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J TASK CPU & MEMORY CONFIGURATIONS Flexible configuration options – 50 CPU/memory configurations CPU Memory 256 (.25 vCPU) 512MB*, 1GB, 2GB 512 (.5 vCPU) 1GB to 4GB (1GB increments) 1024 (1 vCPU) 2GB to 8GB (1GB increments) 2048 (2 vCPU) 4GB to 16GB (1GB increments) 4096 (4 vCPU) 8GB to 30GB (1GB increments)
  21. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J NETWORKING
  22. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J VPC INTEGRATION Subnet Internet Other Entities in VPC LB DB etc. • AWS VPC Networking Mode – each task gets its own interface • All Fargate Tasks run in customer VPC and subnets • Configure security groups to control inbound & outbound traffic • Public IP support ENI Fargate Task
  23. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J VPC CONFIGURATION { "family": ”nginx-demo", "cpu": "1 vCpu", "memory": "2 gb", "networkMode": "awsvpc", "containerDefinitions": [ { … $ aws ecs run-task ... -- task-definition nginx-demo:1 -- network-configuration “awsvpcConfiguration = { subnets=[subnet1-id, subnet2-id], securityGroups=[sg-id] }” Enables ENI creation & attachment to Task Run Task Task Definition Snippet
  24. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J LOAD BALANCING APPLICATION LOAD BALANCER NETWORK LOAD BALANCER
  25. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J ECS MANAGED SERVICE DISCOVERY • Service registry: • Predictable Names for services • Auto updated with latest, healthy IP, port • Managed: No overhead of installation or monitoring • High availability, high scale • Extensible: Flexible boundaries for auto discovery NEW!
  26. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J IAM
  27. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J PERMISSION TIERS Cluster Permissions Task Role Task Execution Role Cluster Fargate Task CLUSTER Control who can launch/describe tasks in your cluster APPLICATION: TASK ROLE Allows your application containers to access AWS resources securely HOUSEKEEPING: TASK EXECUTION ROLE Allows us to perform housekeeping activities around your task: • ECR Image Pull • CloudWatch Logs pushing • ENI creation • Register/Deregister targets into ELB
  28. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J CONTAINER REGISTRIES
  29. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J REGISTRY SUPPORT 3rd Party Private Repositories (coming soon!) Public Repositories supported Amazon Elastic Container Registry (ECR)
  30. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J CLOUDFORMATION SUPPORT
  31. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J
  32. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J VISIBILITY & MONITORING
  33. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J VISIBILITY AND MONITORING Service-level metrics available CloudWatch Logs CloudWatch Events supported
  34. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J ECS TASK METADATA ENDPOINT • Query environmental data and statistics for running tasks • Enables third party monitoring tools like Datadog, etc. NEW!
  35. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J Define custom health check commands in the ECS Task Definition CONTAINER HEALTH CHECKS NEW!
  36. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J STORAGE
  37. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J STORAGE Writable Layer Storage – 10GB EBS backed non-persistent storage provided in the form of: Volume Storage – 4GB
  38. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J DEMO
  39. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J TAKE AWAYS • Fargate is a launch type within ECS to run containers without having to manage EC2 instances • If you’re debating between EC2 and Fargate mode, start architecting with Fargate. It forces good design practice by keeping your application containers truly independent of the underlying host. • If you think you must have access to the underlying host, think again. • There are some good reasons: special instance type needs, EC2 dedicated instances, utilizing EC2 reserved instances • And tell us about your use case, we want to support it on Fargate! • Start using Fargate today! • Fargate works with most Docker container images • You can run existing task definitions on Fargate with only minor modifications.
  40. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. T I F F A N Y F A Y J WANT TO LEARN MORE? https://aws.amazon.com/fargate/ https://aws.amazon.com/blogs/compute/category/compute/aws-fargate/ https://youtu.be/wrZvlJlcZio https://github.com/aws-samples/eb-java-scorekeep/tree/fargate
  41. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. tiffanyfayj http://bit.ly/codeeuropetfj Special thanks to: Deepak Dayama, Anthony Suarez, Archana Srikanta, Dan Gerdesmeier, and many more… THANK YOU