Baremetal deployment scale

658 views

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
658
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
8
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Baremetal deployment scale

  1. 1. Automated deployments with SaltStack & Docker Roberto Aguilar, roberto@baremetal.io @baremetalio
  2. 2. How many of us have: roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  3. 3. Spent too much time deploying new software? roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  4. 4. Spent too much time ack software? deploying new ng b rolli roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  5. 5. Or have answered the question: roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  6. 6. “Can we get an install of _________________ ?” Cassandra roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  7. 7. “Can we get an install of _________________ ?” Memcached roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  8. 8. “Can we get an install of _________________ ?” RabbitMQ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  9. 9. “Can we get an install of _________________ ?” Redis roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  10. 10. … “Can we get an install of _________________ ?” roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  11. 11. With: roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  12. 12. “maybe next week.” –Your friendly devops / sysadmin roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  13. 13. The answer should be: roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  14. 14. “on it!” –Your friendly devops / sysadmin roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  15. 15. “you can do it yourself!” –Your friendly devops / sysadmin roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  16. 16. How do we get there? roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  17. 17. “How to build a dynamic compute environment?” roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  18. 18. Dynamic Compute Environment ❖ Easily start and stop services! ❖ Experimentation with a low barrier to entry! ❖ Scale processes as needed! ❖ Unique, isolated application environments! ❖ Self-service roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  19. 19. Separation of concerns service service service service service service service service serveservice serve serve serveservice serve serve service service service service service server server server server server server service server server server server server server server server server server server server server server server server server server roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  20. 20. Separation of concerns ❖ Host systems are identical! ❖ Host systems are application/service -unaware! ❖ Services are self-contained roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  21. 21. The Application Layer roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  22. 22. XII The Twelve-Factor App http://12factor.net roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  23. 23. XII I. Codebase & II. Dependencies roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  24. 24. XII V. Build, Release & Run roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  25. 25. XII IV. [Backing] Services roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  26. 26. XII VII. Port-binding roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  27. 27. XII III. Environment-based Config roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  28. 28. Application Layer service pg service service rmq service service service service service cache serveservice serve serve serveservice serve serve service service service service django service server server server server server server service server server server server server server server server server server server server server server server server server server roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  29. 29. The nuts and bolts roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  30. 30. Compute Environment ❖ ❖ ❖ ❖ The way to interact with systems! Server provisioning! Base software stack! System configuration! ❖ logging (syslog config)! ❖ networking (/etc/hosts, floating IPs, etc.)! ❖ metrics collection roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  31. 31. Application Environment Image creation! ❖ Image distribution! ❖ Application runtime ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  32. 32. Fill in the blanks roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  33. 33. XII I. Codebase & II. Dependencies roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  34. 34. I. Codebase nginx service repo [0][~/Projects/baremetal/containers/nginx(master)] [berto@g6]$ find . -type f | grep -v .git ./Dockerfile ./files/etc/apt/nginx.pgp ./files/etc/apt/sources.list.d/nginx.list ./files/etc/nginx/nginx.conf […] roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  35. 35. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) ❖ FROM - Defines the base image: OS, version, etc.! ❖ ADD - Adds files to image! ❖ RUN - Commands to configure image! ❖ EXPOSE - Specifies exposed ports! ❖ ENV - Defines environment variables! ❖ VOLUME - Filesystem directories that are sharable! ❖ CMD - Default command to run when launched roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  36. 36. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) FROM ubuntu:quantal MAINTAINER Roberto Aguilar roberto@baremetal.io ! ADD files/etc/apt/nginx.pgp /etc/apt/nginx.pgp ADD files/etc/apt/sources.list.d/nginx.list /etc/apt/sources.list.d/nginx.list ! RUN apt-key add /etc/apt/nginx.pgp RUN apt-get update RUN apt-get install -y nginx ! EXPOSE 80 443 CMD /usr/sbin/nginx -g 'daemon off;' roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  37. 37. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) FROM ubuntu:quantal MAINTAINER Roberto Aguilar roberto@baremetal.io roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  38. 38. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) ADD files/etc/apt/nginx.pgp /etc/apt/nginx.pgp ADD files/etc/apt/sources.list.d/nginx.list /etc/ apt/sources.list.d/nginx.list roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  39. 39. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) RUN apt-key add /etc/apt/nginx.pgp RUN apt-get update RUN apt-get install -y nginx roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  40. 40. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) EXPOSE 80 443 roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  41. 41. II. Dependencies Dockerfile (http://docs.docker.io/en/latest/use/builder/) CMD /usr/sbin/nginx -g 'daemon off;' roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  42. 42. XII V. Build, Release & Run roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  43. 43. Docker Builds images docker build -t <image_name> . Container runtime docker run -d <image_name> [command] roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  44. 44. Docker Registry github.com/dotcloud/docker-registry Host images docker push <image_name> Distribute images docker pull <image_name> roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  45. 45. Check out the Docker Index Ready-made, downloadable images http://index.docker.io roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  46. 46. Anatomy of an image name registry.local/baremetal/postgresql roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  47. 47. Anatomy of an image name registry.local/baremetal/postgresql service roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  48. 48. Anatomy of an image name registry.local/baremetal/postgresql user (optional) roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  49. 49. Anatomy of an image name registry.local/baremetal/postgresql user/service (push to index) roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  50. 50. Anatomy of an image name registry.local/baremetal/postgresql registry (optional) roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  51. 51. Anatomy of an image name registry.local/baremetal/postgresql registry (optional) user (optional) service roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  52. 52. XII VII. Port-binding roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  53. 53. VII. Port-binding $ docker run -d -p 80 -p 443 registry.local/baremetal/nginx 1052eb879f4e[…] ! $ docker ps | chop CONTAINER ID IMAGE PORTS 1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157- >80/tcp ! $ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t" roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  54. 54. VII. Port-binding $ docker run -d -p 80 -p 443 registry.local/baremetal/nginx 1052eb879f4e[…] ! $ docker ps | chop CONTAINER ID IMAGE PORTS 1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157- >80/tcp ! $ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t" roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  55. 55. VII. Port-binding $ docker run -d -p 80 -p 443 registry.local/baremetal/nginx 1052eb879f4e[…] ! $ docker ps | chop CONTAINER ID IMAGE PORTS 1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157- >80/tcp ! $ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t" roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  56. 56. VII. Port-binding $ docker run -d -p 80 -p 443 registry.local/baremetal/nginx 1052eb879f4e[…] ! $ docker ps | chop CONTAINER ID IMAGE PORTS 1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157- >80/tcp ! $ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t" roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  57. 57. VII. Port-binding $ docker run -d -p 80 -p 443 registry.local/baremetal/nginx 1052eb879f4e[…] ! $ docker ps | chop CONTAINER ID IMAGE PORTS 1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157- >80/tcp ! $ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t" roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  58. 58. VII. Port-binding baremetal@baremetal:~$ docker port 1052eb879f4e 443 0.0.0.0:49155 baremetal@baremetal:~$ docker port 1052eb879f4e 80 0.0.0.0:49157 roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  59. 59. VII. Port-binding All interfaces, dynamic host port -p 80 All interfaces, explicit host port -p 80:80 Explicit interface, dynamic host port -p 192.168.42.147::80 Explicit interface, explicit host port -p 192.168.42.147:80:80 roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  60. 60. XII III. Environment-based Config roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  61. 61. III. Environment-based Config pg po stg res ql: // u:p @1 .2. 3.4 :49 15 6 /d b amqp://u:p@1.2.3.35:49901 rmq cache : .11 .3 302 49 1.2 / e:/ ach mc me django roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  62. 62. III. Environment-based Config $ docker run -d -p 1.2.3.42::8000 -e MEMCACHED_URL=memcache://1.2.3.11:49302 -e AMQP_URL=amqp://u:p@1.2.3.35:49901 -e POSTGRESQL_URL=postgresql://u:p@1.2.3.4:49156/db registry.local/app1/djangoapp roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  63. 63. III. Environment-based Config settings.py - memcached setup import os from urlparse import urlparse ! backend = 'django.core.cache.backends.memcached.MemcachedCache' memcached_url = urlparse(os.environ['MEMCACHED_URL']) CACHES = { 'default': { 'BACKEND': backend, 'LOCATION': memcached_url.netloc, } } roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  64. 64. III. Environment-based Config settings.py - RabbitMQ setup import os ! BROKER_URL = os.environ['AMQP_URL'] roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  65. 65. III. Environment-based Config settings.py - postgresql setup import dj_database_url ! dj_db_config = dj_database_url.config() if dj_db_config: DATABASES['default'] = dj_db_config roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  66. 66. Baremetal Platform roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  67. 67. Baremetal Platform Thin as possible! ❖ Run the platform on the platform! ❖ Run as many services as possible in containers ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  68. 68. Baremetal Platform Two main components! ❖ container manager! ❖ orchestration! ❖ Two major goals! ❖ minimize downtime! ❖ eliminate single point of failure ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  69. 69. Container Manager Starts containers assigned to the host! ❖ Stops containers no longer assigned! ❖ Restarts containers that should be running and die! ❖ Restarts containers when service config changes ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  70. 70. Orchestration Aware of all hosts in cluster! ❖ Reacts to hosts joining and leaving cluster! ❖ Reacts to configuration changes! ❖ Assigns containers to hosts ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  71. 71. Orchestration Configuration Repositories! ❖ tracks Docker image, git repo and branch! ❖ Services! ❖ repo, dependencies, failover! ❖ Applications! ❖ services, # instances, configuration, memory allocation ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  72. 72. The nuts and bolts roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  73. 73. Additional Services etcd - fault-tolerant configuration store! ❖ serf - host discovery and message passing! ❖ zfs - next-gen copy-on-write filesystem ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  74. 74. Containerize as much as possible roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  75. 75. Containerize as much as possible Run the platform on the platform! ❖ Services remain self-contained! ❖ Portable - simple to relocate to another system! ❖ Easily deploy new versions and rollback if needed ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  76. 76. Thanks! Let us know what you think: http://baremetal.io/scale roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio

×