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.

Docker on AWS OpsWorks

23,970 views

Published on

Presentation about how to run Docker on AWS EC2 with AWS OpsWorks.

Published in: Technology, Self Improvement

Docker on AWS OpsWorks

  1. 1. © 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc. Running Docker on AWS Jonathan Weiss @jweiss Amazon Web Services
  2. 2. Docker on AWS Do it yourself on EC2 Automate with AWS OpsWorks AWS Beanstalk simplecontrol
  3. 3. “Integrated application management service on EC2 – powered by Chef”
  4. 4. Chef Setup Chef Client/Zero & OpsWorks Backend Chef Client & Chef Server
  5. 5. OpsWorks Architecture OpsWorks Backend OpsWorks Agent EC2, EBS, EIP, VPC, RDS, ELB, … Auto-Scaling, Auto-Healing,… On-instance execution via Chef client/zero Command JSON Command Log+Status
  6. 6. Chef Setup in OpsWorks •  Supported Chef versions: 0.9, 11.4 or 11.10 •  Built-in convenience cookbooks / bring your own •  Chef run is triggered by life cycle event firing •  Event comes with stack state JSON
  7. 7. Why run Docker on OpsWorks? •  Full control of Docker version & install •  Full control of mapping container to instance •  Automation of AWS resources •  Resource discovery, e.g. other containers
  8. 8. AWS OpsWorks
  9. 9. Stacks & Layers
  10. 10. Modeling in OpsWorks
  11. 11. Layers Group of instances with common behavior & settings –  Chef recipes / run_list –  Settings / attributes –  Similar to a Chef role
  12. 12. Built-in Layers Open Source at http://github.com/aws/opsworks-cookbooks Rails MySQL PHP HAProxy Node.js Memcached Java Ganglia
  13. 13. Custom Layers Define your own layers and their Chef run_list –  Erlang app server –  Cassandra DB cluster –  C daemon –  Custom PHP install –  … –  Docker!
  14. 14. Custom Layers
  15. 15. Custom Layers
  16. 16. Custom Layers
  17. 17. Event Life Cycle
  18. 18. Events Events are triggered when your stack changes: •  Chef run_list per event per layer •  Give you fine-grained control
  19. 19. Life Cycle Events 1 9 setup configure deploy undeploy shutdown
  20. 20. Instance Life Cycle new
  21. 21. Instance Life Cycle new
  22. 22. Instance Life Cycle new online setup configure
  23. 23. Instance Life Cycle new online setup configure deploy
  24. 24. Instance Life Cycle new/stopped online setup configure terminating shutting down deploy configure
  25. 25. Setup Event •  Sent when instance boots •  Includes deploy event •  Use for initial installation of software & services •  Install Docker
  26. 26. Configure Event •  Sent to all instances when any instance enters or leaves online state •  Use for making sure the configuration is up-to-date •  Update etcd config
  27. 27. Deploy Event •  Sent when you deploy via UI/API also part of each setup •  Use for custom deployment •  Deploy Dockerfiles / images
  28. 28. Undeploy Event •  Sent via UI/API when apps are deleted •  Use to remove apps from running instances •  Stop containers
  29. 29. Shutdown Event •  Sent when an instance is shut down •  ~45s to execute •  Use for clean shutdown
  30. 30. Stack State JSON Each event gets JSON / attributes that define the current stack state: node[:opsworks] search(:node, "role:db-master") node[:opsworks][:layers] search(:node, "*") node[:opsworks][:instance] node[:opsworks][:stack]
  31. 31. Creating a Docker Layer
  32. 32. Ingredients •  chef-docker cookbook from https://github.com/bflad/chef-docker •  OpsWorks custom layer
  33. 33. Docker Layer Create a custom layer: Name: Docker Shortname: docker
  34. 34. Setup – Install Docker recipe[docker::default] •  Installs Docker from source or package •  Handles dependencies like lxc, aufs or cgroups •  Docker service and /etc/init/docker.conf
  35. 35. Deploy – Manage Containers docker_image 'shipyard/shipyard' do action :pull notifies :redeploy,'docker_container[shipyard]', :immediately end docker_container 'shipyard' do action :run end
  36. 36. Configure – Update etcd if db_server = search(:node, "role:db-master").first execute "Publish database IP" do command "etcdctl set /db-ip #{db_server[:private_ip]}" end end
  37. 37. Undeploy docker_container 'shipyard' do signal 'QUIT' action :kill end
  38. 38. Next Steps •  Have one custom layer per Docker app •  Configure auto-scaling, ELBs, etc
  39. 39. Recap
  40. 40. AWS OpsWorks •  Life cycle automation framework •  Highly customizable – in the end everything is a Chef run •  Takes care of AWS integration
  41. 41. Docker on OpsWorks •  Automate install & configuration of Docker •  Fleet management •  Dynamic configuration
  42. 42. More information about AWS OpsWorks •  Follow us on twitter @AWSOpsWorks •  Find us on YouTube •  Docs: http://aws.amazon.com/documentation/opsworks •  Blog: http://blogs.aws.amazon.com/application-management
  43. 43. Thank You@jweiss aws.amazon.com/opsworks

×