Baremetal deployment

2,194 views

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,194
On SlideShare
0
From Embeds
0
Number of Embeds
359
Actions
Shares
0
Downloads
31
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Baremetal deployment

  1. 1. Dynamic, HA 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 rmq service django service cache Django needs to be told how to access the services it depends on, which is done by passing in the connection information via environment variables 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 registry (optional) 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 service roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  50. 50. Anatomy of an image name registry.local/baremetal/postgresql registry (optional) user (optional) service roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  51. 51. XII VII. Port-binding roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  52. 52. 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
  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 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
  58. 58. 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
  59. 59. XII III. Environment-based Config roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  60. 60. III. Environment-based Config pg po stg res :// u:p @1 .2. 3.4 :49 15 6/ db 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
  61. 61. 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 POSTGRES_URL=postgres://u:p@1.2.3.4:49156/db registry.local/app1/djangoapp roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  62. 62. 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
  63. 63. III. Environment-based Config settings.py - RabbitMQ setup import os ! BROKER_URL = os.environ['AMQP_URL'] roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  64. 64. 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
  65. 65. Orchestration roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  66. 66. Orchestration Configuration Repositories! ❖ tracks Docker image, git repo and branch! ❖ Services! ❖ repo, dependencies, failover, process type, node role! ❖ Applications! ❖ services, # instances, configuration ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  67. 67. Orchestration Daemon 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
  68. 68. Container Daemon Reacts to cluster events! ❖ Reacts to Docker events for container uptime! ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  69. 69. What about Salt Master in a container? roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  70. 70. Salt Master in a container Why? roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  71. 71. Salt Master in a container Self-contained! ❖ Portable - simple to relocate to another system! ❖ Easily test new salt version with ! ❖ Easy rollback if needed ❖ roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  72. 72. Salt Master in a container Issues roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  73. 73. Salt Master in a container ❖ Are there scaling issues with Salt in a container?! ❖ So far so good roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio
  74. 74. Thanks! Let us know what you think: http://baremetal.io/saltconf roberto@baremetal.io ⁃ ⁃ ⁃ ⁃ @baremetalio

×