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

Docker on AWS using Fargate, CDK, and Github Actions

Docker on AWS using Fargate, CDK, and Github Actions

Thorsten Hoeger

November 26, 2019
Tweet

More Decks by Thorsten Hoeger

Other Decks in Technology

Transcript

  1. @hoegertn About me • Thorsten Höger • Cloud Evangelist -

    Taimos GmbH • Cloud Consultant • AWS Community Hero • twitter: @hoegertn • web: www.taimos.de
  2. @hoegertn Leistungen oTraining o Wir helfen Ihnen, ihr Team und

    ihr Unternehmen für die Cloud fit zu machen o Workshops, Trainings, Reviews oBeratung o Mit unserer Erfahrung unterstützen wir Sie bei der Migration in die Cloud o Erfahrung, Kultur, DevOps oEntwicklung o Wir entwickeln Ihre Geschäftsanwendung mit Hilfe aktueller Technologien und Frameworks o Amazon Web Services, Docker, Serverless
  3. @hoegertn Agenda • What do we want to do? •

    What is ECS / Fargate? • How to deploy using Infrastructure-as-Code? • How to build a pipeline using Github Actions • Questions & Feedback
  4. @hoegertn What do we want to do? VPC AWS Cloud

    Availability Zone 1 ECS Service Availability Zone 2 NAT Gateway NAT Gateway Task Task ECR https://github.com/taimos/cdk-fargate-demo
  5. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Elastic Container Service • Highly scaleable, high performance container management system. • Eliminates the need to install, operate and scale your own container management system.
  6. What are orchestration tools and why should I care? Containers

    are lots of work (and moving pieces)! Orchestration tools help you manage, scale, and deploy your containers.
  7. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon ECS • ECS provides a managed platform for: Cluster management Container orchestration Deep AWS integration
  8. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon ECS • No software to: Deploy Manage Scale
  9. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Deep AWS integration Autoscaling Load balancing IAM Monitoring Networking Logging
  10. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. How does ECS map to traditional workloads? Instances: standard EC2 boxes. Once registered to a Cluster, your Tasks run here Service: layer that manage and place your Tasks Task: container wrapper and configuration around a process running on the instance
  11. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. How does ECS work? Staging cluster Production cluster Container instance Container instance Container instance Container instance Container instance Container instance
  12. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. A closer look Load balancer (ALB, NLB, or ELB Classic) routes traffic to the cluster instances Cluster is made up of one or more EC2 instances Each Container instance runs one or more Services
  13. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. A closer look A Service controls things like the number of copies of a Task you want running (Desired Count), and registers your Service with a load balancer A Task Definition controls things like container image, environment variables, resource allocation, logger, and other parameters
  14. © 2017, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Fargate Fargate mode! For ECS available, for EKS in the future • No infrastructure to manage or scale • Scale seamlessly on demand • Manage everything at the container level
  15. © 2019, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Infrastructure as Code Options High level Low level • AWS CDK, Pulumi (third party) • Full power of supported languages, OO, abstractions, imperative logic • In the case of CDK, still generates CloudFormation code Componentized • Troposphere (Python), SparkleFormation (Ruby), GoFormation (Go) • Leverages higher-level language constructs, some abstraction also possible • Generates CloudFormation code (in the specific cases above) DSLs • CloudFormation (with and without macros), Terraform modules • Declare desired state, engine finds path to provision/update resources • Some abstraction and logic flow possible Declarative • Automate with the AWS SDKs & CLIs • Step-by-step, imperative instructions • Left to developer: error handling, manage state, rollbacks, dependency graphs, stabilization, etc. Scripted
  16. © 2019, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS Cloud Development Kit (CDK) A multi-language software development framework for modeling cloud infrastructure as reusable components AWS CloudFormation
  17. © 2019, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS Cloud Development Kit (CDK) AWS Construct Library Framework CLI CDK Application Stack(s) Construct Construct Core Framework CDK CLI Serverless Containers CI/CD Application Integration / Foundational Autoscaling
  18. © 2019, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS CDK Core Framework CDK Application Stack(s) Construct Construct
  19. © 2019, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. CloudFormation Template “compiler” CDK CLI “processor” “assembly language” “source” synthesize deploy executes AWS Cloud Development Kit (CDK)
  20. @hoegertn How to build a pipeline using Github Actions Create

    .github/workflows folder Create workflow file push.yml Configure IAM user in Github Push changes to Github