Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
BLOGLOVIN’
Using SaltStack to orchestrate
microservices in application
containers
Love Nyberg
Site reliability & Automatio...
BLOGLOVIN’
#SaltConf15
tens of millions of monthly unique visitors
hundred of millions requests per day
couple of million ...
All those buzz words!
• Configuration management
• Continues Integartion
• Containers
• Orchestration
• Micro services
#Sa...
Why containers?
Build
#SaltConf15
Ship Run
#SaltConf15
#SaltConf15
All those tools!
Legacy!
#SaltConf15
#SaltConf15
Evolution of container
management at bloglovin?
Phase 1
Rolling deploys with static amount
Phase 2
Green/Blue deploy with ...
Build
#SaltConf15
Ship Run
Architecture
#SaltConf15
LB/Cache
Ship - applications
DB/Queues
Salt master
Jenkins
Registry
Phase 1: Rolling deploys with static amount
Static amount of containers on each ship
Rolling deployes on each ship
Drawbac...
Building images
#SaltConf15
Dockerfile Jenkins Registry
Building images
#SaltConf15
base image
application image
application code
Ship images
#SaltConf15
Run containers
#SaltConf15
Run containers
#SaltConf15
{% set name = 'node-demo' %}
{% set registryname = 'jacksoncage' %}
{% set tag = salt['pillar.g...
Run containers
#SaltConf15
{{ name }}-image:
docker.pulled:
- name: {{ registryname }}/{{ name }}
- tag: {{ tag }}
- force...
Run containers
#SaltConf15
{{ name }}-stop-if-old-{{ no }}:
cmd.run:
- name: docker stop {{ containerid }}-{{ name }}-{{ n...
Run containers
#SaltConf15
{{ name }}-remove-if-old-{{ no }}:
cmd.run:
- name: docker rm {{ containerid }}-{{ name }}-{{ n...
Run containers
#SaltConf15
{{ name }}-container-{{ no }}:
docker.installed:
- name: {{ containerid }}-{{ name }}-{{ no }}
...
Run containers
#SaltConf15
{{ name }}-{{ no }}:
docker.running:
- container: {{ containerid }}-{{ name }}-{{ no }}
- port_...
Run containers
#SaltConf15
salt minion1 state.sls containers.applications.node-demo 'pillar={ containers: { imagetag: 1.0....
Run containers
#SaltConf15
curl -H 'X-Salt-Deploy-Key: QmpaDa8T3UdFVBUHWo@T' 
-H 'Content-Type: application/json' 
-d '{"a...
Phase 2: Green/Blue deploy with dynamic pillar
• Deploy a new containers before killing the old once
• Use healtchecks
• U...
Run containers
#SaltConf15
Run containers
#SaltConf15
Reactor sls
1. Sync states
2. Update etcd with tags, amount etc
3. Pull docker image
4. Deploy ...
Demo
#SaltConf15
Phase 1:
https://github.com/jacksoncage/docker-node-demo
Phase 2:
https://github.com/jacksoncage/saltconf...
Container madness!
Images
Logging
Monitoring
#SaltConf15
Questions?
Love Nyberg
love@bloglovin.com
@jacksoncage
#SaltConf15
Thanks!
#SaltConf15
Love Nyberg
love@bloglovin.com
@jacksoncage
We’re hiring!
Prochain SlideShare
Chargement dans…5
×

Using SaltStack to orchestrate microservices in application containers at SaltConf15

3 300 vues

Publié le

More and more applications are being built or re-built with a micro-service architecture. Application containers are great working blocks to quickly and easily get a micro-service system up and running. Saltstack is then a perfect match to scale such a system. This talk will dive into how Saltstack can be used to scale a micro-service system like Docker.

Publié dans : Technologie

Using SaltStack to orchestrate microservices in application containers at SaltConf15

  1. 1. BLOGLOVIN’ Using SaltStack to orchestrate microservices in application containers Love Nyberg Site reliability & Automation Engineer #SaltConf15
  2. 2. BLOGLOVIN’ #SaltConf15 tens of millions of monthly unique visitors hundred of millions requests per day couple of million stories parsed per day Hybrid DC/Cloud - Bare metal servers - Cloud VM’s
  3. 3. All those buzz words! • Configuration management • Continues Integartion • Containers • Orchestration • Micro services #SaltConf15
  4. 4. Why containers? Build #SaltConf15 Ship Run
  5. 5. #SaltConf15
  6. 6. #SaltConf15 All those tools!
  7. 7. Legacy! #SaltConf15
  8. 8. #SaltConf15
  9. 9. Evolution of container management at bloglovin? Phase 1 Rolling deploys with static amount Phase 2 Green/Blue deploy with dynamic pillar #SaltConf15
  10. 10. Build #SaltConf15 Ship Run
  11. 11. Architecture #SaltConf15 LB/Cache Ship - applications DB/Queues Salt master Jenkins Registry
  12. 12. Phase 1: Rolling deploys with static amount Static amount of containers on each ship Rolling deployes on each ship Drawbacks no healtchecks serving diffrent version of code during deploy #SaltConf15
  13. 13. Building images #SaltConf15 Dockerfile Jenkins Registry
  14. 14. Building images #SaltConf15 base image application image application code
  15. 15. Ship images #SaltConf15
  16. 16. Run containers #SaltConf15
  17. 17. Run containers #SaltConf15 {% set name = 'node-demo' %} {% set registryname = 'jacksoncage' %} {% set tag = salt['pillar.get']('imagetag', "latest") %} {% set containerid = salt['grains.get']('id') %} {% set hostport = '808' %} {% set hostip = grains['ip_interfaces']['eth0'][0] %} {% set tag = salt[‘pillar.get']('containers:imagetag', "latest") %} {% set noofcontainers = range(10) ‰} State file: 1. Setting variables
  18. 18. Run containers #SaltConf15 {{ name }}-image: docker.pulled: - name: {{ registryname }}/{{ name }} - tag: {{ tag }} - force: True State file: 2. Pulling docker image
  19. 19. Run containers #SaltConf15 {{ name }}-stop-if-old-{{ no }}: cmd.run: - name: docker stop {{ containerid }}-{{ name }}-{{ no }} - unless: docker inspect --format '{{ .Image }}' {{ containerid }}-{{ name }}-{{ nr }} | grep $(docker images --no-trunc | grep "{{ registryname }}/{{ name }}" | awk '{ print $3 }') - require: - docker: {{ name }}-image State file: 3. Stop container if newer image exists
  20. 20. Run containers #SaltConf15 {{ name }}-remove-if-old-{{ no }}: cmd.run: - name: docker rm {{ containerid }}-{{ name }}-{{ no }} - unless: docker inspect --format '{{ .Image }}' {{ containerid }}-{{ name }}-{{ nr }} | grep $(docker images --no-trunc | grep "{{ registryname }}/{{ name }}" | awk '{ print $3 }') - require: - cmd: {{ name }}-stop-if-old-{{ no }} State file: 4. Removing container if newer image exists
  21. 21. Run containers #SaltConf15 {{ name }}-container-{{ no }}: docker.installed: - name: {{ containerid }}-{{ name }}-{{ no }} - hostname: {{ containerid }}-{{ name }}-{{ no }} - image: {{ registryname }}/{{ name }}:{{ tag }} - ports: - "8080/tcp" - environment: - EXECUTER: "forever -f start" - APP: "index.js" - require_in: {{ name }}-{{ no }} - require: - docker: {{ name }}-image State file: 5. Installing container
  22. 22. Run containers #SaltConf15 {{ name }}-{{ no }}: docker.running: - container: {{ containerid }}-{{ name }}-{{ no }} - port_bindings: "8080/tcp": HostIp: "{{ hostip }}" HostPort: "{{ hostport }}{{ no }}" State file: 6. Start container
  23. 23. Run containers #SaltConf15 salt minion1 state.sls containers.applications.node-demo 'pillar={ containers: { imagetag: 1.0.0 } }' Run: command line
  24. 24. Run containers #SaltConf15 curl -H 'X-Salt-Deploy-Key: QmpaDa8T3UdFVBUHWo@T' -H 'Content-Type: application/json' -d '{"application":"api","container":"api-phase1","node":"ship01","tag":"1.0","amount":"2"}' http://127.0.0.1:8000/hook/api/deploy/phase2/success salt-call event.fire_master '{"salt-node": "ship01", "application": "api", “container": "api-phase1", "tag": "1.0"}' deploy/containers Run: via api/reactor
  25. 25. Phase 2: Green/Blue deploy with dynamic pillar • Deploy a new containers before killing the old once • Use healtchecks • Use dynamic updated pillar data with etcd #SaltConf15
  26. 26. Run containers #SaltConf15
  27. 27. Run containers #SaltConf15 Reactor sls 1. Sync states 2. Update etcd with tags, amount etc 3. Pull docker image 4. Deploy unactive containers to cluster 5. Test unactive containers and add to etcd 6. Update haproxy using etcd 7. Close down unactive containers
  28. 28. Demo #SaltConf15 Phase 1: https://github.com/jacksoncage/docker-node-demo Phase 2: https://github.com/jacksoncage/saltconf-container-demo
  29. 29. Container madness! Images Logging Monitoring #SaltConf15
  30. 30. Questions? Love Nyberg love@bloglovin.com @jacksoncage #SaltConf15
  31. 31. Thanks! #SaltConf15 Love Nyberg love@bloglovin.com @jacksoncage We’re hiring!

×