SlideShare a Scribd company logo
Putting the
in
Docker Swarm
What I do: am a human phone assistant
What I do: assist phones.
Who am I
+
• Lightweight and distributable containers
• Containers should be single-process, no durable storage, ephemeral little
creatures
• Scalability due to built in resilience and orchestration layers
• Higher packing density than virtual machines due to shared libs
What is Docker
Docker Swarm mode
• Orchestration layer (Swarm) is built into Docker Engine
• Easily scale containers across multiple nodes
• Easy, multi-hostVXLAN routing
• Built in state reconciliation, health checks, and designed for resilient deployments
• Mesh networking allows ingress from any node to reach any other node
• Auto-load balancing of inbound requests utilizes in-kernel Linux IPVS
• Built-in DNS-based service discovery
• Rolling Updates
• Ease of Scaling
• A free basket of puppies (Docker EE only)
Deploying Your First Swarm
• Spin up a few machines with your favorite OS
• We’ll be using Debian 9
Install Docker CE
Deploying Your First Swarm
sudo apt-get update
sudo apt-get install 
apt-transport-https 
ca-certificates 
curl 
gnupg2 
software-properties-common
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
sudo add-apt-repository 
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") 
$(lsb_release -cs) 
stable"
sudo apt-get update
sudo apt-get install docker-ce
Voila!
root@astricon-sfo-1:~# docker -v
Docker version 17.09.0-ce, build afdb6d4
Initialize the Swarm
• TCP 2377 for cluster management communications
• TCP & UDP port 7946 for communication among nodes
• UDP port 4789 for overlay network traffic
Deploying Your First Swarm
root@astricon-sfo-1:~# docker swarm init —advertise-addr 107.170.205.26
Now run that join line on each worker
root@astricon-london-1:~# docker swarm join --token
SWMTKN-1-4n2nbpa5lntnbpomq8h412xliz9orjcxlrdjwhrg2v756nzfg0-0q4061v448gvcnqckd8t1z75k 107.170.205.26:2377
This node joined a swarm as a worker.
Swarm initialized: current node (uri5s1oes546txryvdv5hyu69) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token
SWMTKN-1-4n2nbpa5lntnbpomq8h412xliz9orjcxlrdjwhrg2v756nzfg0-0q4061v448gvcnqckd8t1z75k 107.170.205.26:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
Success
Your Swarm Is Ready!
root@astricon-sfo-1:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
zaecqxqlgj5n1jtxwi34r08cg astricon-london-1 Ready Active
gq45t7og425dmanur0b4fz0p6 astricon-nyc-1 Ready Active
uri5s1oes546txryvdv5hyu69 * astricon-sfo-1 Ready Active Leader
• Only a single Manager
• Managers are also workers with a little more overhead
• All nodes report ready
Let’s Get Our Asterisk
Swarm On
Swarm mode
• Build your own Asterisk or utilize an existing image from Docker Hub
• Docker Hub is built into all engines:
• We’ll be using:
• Now we need to define our services
• We need to build a Stack file
• A stack file is simply aYAML file in Compose format that lists the various
services run by the swarm
docker pull <IMAGE>
respoke/asterisk:14
Let’s Break For
version: "3.4"
services:
### To demonstrate mesh networking, let’s use Nginx
nginx:
image: nginx
ports:
- 80:80
networks:
- astricon-is-radical
networks:
astricon-is-radical:
attachable: true
Stack file for Nginx
root@astricon-sfo-1:~# docker stack deploy -c nginx.yml astricon_swarm
Creating network astricon_swarm_astricon-is-radical
Creating service astricon_swarm_nginx
• Deploy the Stack!
• Check the Stack!
root@astricon-sfo-1:~# docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
7a1292n9v49n astricon_swarm_nginx replicated 1/1 nginx:latest *:80->80/tcp
• Scale the Stack!
root@astricon-sfo-1:~# docker service scale —-detach=true astricon_swarm_nginx=2
astricon_swarm_nginx scaled to 2
ID NAME MODE REPLICAS IMAGE PORTS
7a1292n9v49n astricon_swarm_nginx replicated 2/2 nginx:latest *:80->80/tcp
NYC-1 SFO-1 LONDON-1
NYC-1 SFO-1 LONDON-1
astriconswarm.io
• All requests pointed at IP addresses
associated with the swarm will be load-
balanced to machines with that exposed port
• Even machines that aren’t running anything!
Every node becomes and ingress node and
will automatically address the correct service.
• You can ping by
service name!
Overlay Network
172.18.0.2/16
Back to
version: "3.4"
services:
### The Big Kahuna!
asterisk:
image: respoke/asterisk:14
networks:
- host_mode
deploy:
placement:
constraints: [node.labels.service == asterisk]
networks:
host_mode:
external:
name: 'host'
Asterisk Stack File
The Paralysis of Choice
version: "3.4"
services:
### The Big Kahuna!
asterisk:
image: respoke/asterisk:14
networks:
- astricon-is-radical
deploy:
placement:
constraints: [node.labels.service == asterisk]
networks:
astricon-is-radical:
attachable: true
Host Mode Overlay Network
Choosing a Network Mode
• The issue: opening ports in Docker uses iptables
• Opening many ports (*caugh RTP caugh*) results in a severe memory crunch
• Each UDP port = ~1MB in RAM (Debian 9.1, DO)
• Overlay Mode
• Has full access to service discovery and mesh networking
• Can’t run many open ports — perhaps a few hundred at most.
• Host Mode
• No access to overlay or service discovery network
• Has full access to the underlying networking subsystems
• Unlimited ports
SECRET TRICK
CIP=$(sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $CID)
sudo iptables -A DOCKER -t nat -p udp -m udp ! -i docker0 --dport 10000:65535 -j DNAT --to-destination $CIP:10000-65535
sudo iptables -A DOCKER -p udp -m udp -d $CIP/32 ! -i docker0 -o docker0 --dport 10000:65535 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -p udp -m udp -s $CIP/32 -d $CIP/32 --dport 10000:65535 -j MASQUERADE
Shout out to BetterVoice
• Allows for a large port range to be opened with a single iptables rule
• Must be run on any machine that is running Asterisk and can’t be run from
inside the container (Swarm doesn’t allow privilege escalation)
version: "3.4"
services:
### The Big Kahuna!
asterisk:
image: respoke/asterisk:14
networks:
- host_mode
deploy:
placement:
constraints: [node.labels.service == asterisk]
networks:
host_mode:
external:
name: 'host'
Asterisk Stack File
version: "3.4"
services:
### The Big Kahuna!
asterisk:
image: respoke/asterisk:14
networks:
- astricon-is-radical
deploy:
placement:
constraints: [node.labels.service == asterisk]
networks:
astricon-is-radical:
attachable: true
Revisited
• Better for small business deployments
• Simpler to manage, requires no extra
DevOps (with small port ranges)
• One at a time
• Works more like a traditional Asterisk
installation
• Still functions with built-in HA / health
checks / swarm deployment options
• Many at a time
Additional Pieces
DNS - Route 53
• Setup Geolocation to route
to closest server
• SRV records point to multiple
datacenters
• Health checks or API calls to
verify uptime/downtime
NYC-1 SFO-1
LONDON-1
External
DNS
Docker
DNS
Docker Healthchecks
version: "3.4"
services:
### The Big Kahuna!
asterisk:
image: respoke/asterisk:14
networks:
- host_mode
deploy:
placement:
constraints: [node.labels.service == asterisk]
healthcheck:
test: ["CMD", "sipsak", "-s", "sip:foo@astricon.swarm"]
interval: 30s
timeout: 15s
retries: 3
networks:
host_mode:
external:
name: 'host'
Docker Healthcheck
• Send an OPTIONS ping every 30s
• If failure occurs, retry 3 times with a wait
period of 15 seconds
Data Persistence
Secrets Management docker secrets create
Node labels docker node update --label-add
Private Registry docker service update --with-registry-auth
Final Tips
• Make your images generic
• E.G. RingPlus abstracted away all business logic to API calls.This made our
B2BUAs functionally interchangeable.
• Cows, not kittens.
• Leverage all the pieces of Swarm that you can.
• It can replace a bunch of auxiliary tools and cron scripts
• It forces you to think of things as components in a larger system and how
they all fit together.
• No singleVM running 15 different components installed by a consultant
or someone who left the company a year ago.
• Your deployments become far less brittle and are easier to test.
• Development / Production Parity
Evan McGee
@startledmarmot 

evan@hifelix.io

More Related Content

What's hot

오픈스택 기반 클라우드 서비스 구축 방안 및 사례
오픈스택 기반 클라우드 서비스 구축 방안 및 사례오픈스택 기반 클라우드 서비스 구축 방안 및 사례
오픈스택 기반 클라우드 서비스 구축 방안 및 사례
SONG INSEOB
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
Mamun Rashid, CCDH
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
Docker, Inc.
 
Fortinet UTM - les Fonctionnalités avancéese
Fortinet UTM - les Fonctionnalités avancéeseFortinet UTM - les Fonctionnalités avancéese
Fortinet UTM - les Fonctionnalités avancéese
Alphorm
 
Container Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyondContainer Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyond
KubeAcademy
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
Brendan Gregg
 
EBPF and Linux Networking
EBPF and Linux NetworkingEBPF and Linux Networking
EBPF and Linux Networking
PLUMgrid
 
Scaling FastAGI Applications with Go
Scaling FastAGI Applications with GoScaling FastAGI Applications with Go
Scaling FastAGI Applications with Go
Digium
 
Container security
Container securityContainer security
Container security
Anthony Chow
 
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
OpenStack Korea Community
 
Overview of Distributed Virtual Router (DVR) in Openstack/Neutron
Overview of Distributed Virtual Router (DVR) in Openstack/NeutronOverview of Distributed Virtual Router (DVR) in Openstack/Neutron
Overview of Distributed Virtual Router (DVR) in Openstack/Neutron
vivekkonnect
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
Thomas Graf
 
SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)
Fred Posner
 
Hearts Of Darkness - a Spring DevOps Apocalypse
Hearts Of Darkness - a Spring DevOps ApocalypseHearts Of Darkness - a Spring DevOps Apocalypse
Hearts Of Darkness - a Spring DevOps Apocalypse
Joris Kuipers
 
Faster Container Image Distribution on a Variety of Tools with Lazy Pulling
Faster Container Image Distribution on a Variety of Tools with Lazy PullingFaster Container Image Distribution on a Variety of Tools with Lazy Pulling
Faster Container Image Distribution on a Variety of Tools with Lazy Pulling
Kohei Tokunaga
 
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
Linaro
 
[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode
Akihiro Suda
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+
Aananth C N
 
Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)
Weaveworks
 

What's hot (20)

오픈스택 기반 클라우드 서비스 구축 방안 및 사례
오픈스택 기반 클라우드 서비스 구축 방안 및 사례오픈스택 기반 클라우드 서비스 구축 방안 및 사례
오픈스택 기반 클라우드 서비스 구축 방안 및 사례
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 
Fortinet UTM - les Fonctionnalités avancéese
Fortinet UTM - les Fonctionnalités avancéeseFortinet UTM - les Fonctionnalités avancéese
Fortinet UTM - les Fonctionnalités avancéese
 
Container Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyondContainer Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyond
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
 
EBPF and Linux Networking
EBPF and Linux NetworkingEBPF and Linux Networking
EBPF and Linux Networking
 
Introduction to Vagrant
Introduction to VagrantIntroduction to Vagrant
Introduction to Vagrant
 
Scaling FastAGI Applications with Go
Scaling FastAGI Applications with GoScaling FastAGI Applications with Go
Scaling FastAGI Applications with Go
 
Container security
Container securityContainer security
Container security
 
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
 
Overview of Distributed Virtual Router (DVR) in Openstack/Neutron
Overview of Distributed Virtual Router (DVR) in Openstack/NeutronOverview of Distributed Virtual Router (DVR) in Openstack/Neutron
Overview of Distributed Virtual Router (DVR) in Openstack/Neutron
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
 
SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)
 
Hearts Of Darkness - a Spring DevOps Apocalypse
Hearts Of Darkness - a Spring DevOps ApocalypseHearts Of Darkness - a Spring DevOps Apocalypse
Hearts Of Darkness - a Spring DevOps Apocalypse
 
Faster Container Image Distribution on a Variety of Tools with Lazy Pulling
Faster Container Image Distribution on a Variety of Tools with Lazy PullingFaster Container Image Distribution on a Variety of Tools with Lazy Pulling
Faster Container Image Distribution on a Variety of Tools with Lazy Pulling
 
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
 
[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+
 
Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)
 

Similar to AstriCon 2017 - Docker Swarm & Asterisk

Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
Sreenivas Makam
 
Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Nova
clayton_oneill
 
Paolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestrationPaolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestration
Grzegorz Duda
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
Sreenivas Makam
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
Docker, Inc.
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster management
Nicola Paolucci
 
Demystfying container-networking
Demystfying container-networkingDemystfying container-networking
Demystfying container-networking
Balasundaram Natarajan
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
Chris Tankersley
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep Dive
Docker, Inc.
 
Docker 1.12 networking deep dive
Docker 1.12 networking deep diveDocker 1.12 networking deep dive
Docker 1.12 networking deep dive
Madhu Venugopal
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Jeffrey Ellin
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
Atlassian
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
Docker, Inc.
 
Introction to docker swarm
Introction to docker swarmIntroction to docker swarm
Introction to docker swarm
Hsi-Kai Wang
 
Dockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarmDockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarm
Wei-Ting Kuo
 
What’s new in Swarm 1.1
What’s new in Swarm 1.1What’s new in Swarm 1.1
What’s new in Swarm 1.1
k z
 
What's New in Docker 1.12?
What's New in Docker 1.12?What's New in Docker 1.12?
What's New in Docker 1.12?
Ajeet Singh Raina
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707
Clarence Ho
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarm
Walid Ashraf
 
Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECS
Amazon Web Services
 

Similar to AstriCon 2017 - Docker Swarm & Asterisk (20)

Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Nova
 
Paolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestrationPaolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestration
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster management
 
Demystfying container-networking
Demystfying container-networkingDemystfying container-networking
Demystfying container-networking
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep Dive
 
Docker 1.12 networking deep dive
Docker 1.12 networking deep diveDocker 1.12 networking deep dive
Docker 1.12 networking deep dive
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Introction to docker swarm
Introction to docker swarmIntroction to docker swarm
Introction to docker swarm
 
Dockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarmDockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarm
 
What’s new in Swarm 1.1
What’s new in Swarm 1.1What’s new in Swarm 1.1
What’s new in Swarm 1.1
 
What's New in Docker 1.12?
What's New in Docker 1.12?What's New in Docker 1.12?
What's New in Docker 1.12?
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarm
 
Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECS
 

Recently uploaded

Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 

Recently uploaded (20)

Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 

AstriCon 2017 - Docker Swarm & Asterisk

  • 2. What I do: am a human phone assistant What I do: assist phones. Who am I
  • 3. +
  • 4. • Lightweight and distributable containers • Containers should be single-process, no durable storage, ephemeral little creatures • Scalability due to built in resilience and orchestration layers • Higher packing density than virtual machines due to shared libs What is Docker
  • 5. Docker Swarm mode • Orchestration layer (Swarm) is built into Docker Engine • Easily scale containers across multiple nodes • Easy, multi-hostVXLAN routing • Built in state reconciliation, health checks, and designed for resilient deployments • Mesh networking allows ingress from any node to reach any other node • Auto-load balancing of inbound requests utilizes in-kernel Linux IPVS • Built-in DNS-based service discovery • Rolling Updates • Ease of Scaling • A free basket of puppies (Docker EE only)
  • 7. • Spin up a few machines with your favorite OS • We’ll be using Debian 9 Install Docker CE Deploying Your First Swarm sudo apt-get update sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" sudo apt-get update sudo apt-get install docker-ce Voila! root@astricon-sfo-1:~# docker -v Docker version 17.09.0-ce, build afdb6d4
  • 8. Initialize the Swarm • TCP 2377 for cluster management communications • TCP & UDP port 7946 for communication among nodes • UDP port 4789 for overlay network traffic Deploying Your First Swarm root@astricon-sfo-1:~# docker swarm init —advertise-addr 107.170.205.26 Now run that join line on each worker root@astricon-london-1:~# docker swarm join --token SWMTKN-1-4n2nbpa5lntnbpomq8h412xliz9orjcxlrdjwhrg2v756nzfg0-0q4061v448gvcnqckd8t1z75k 107.170.205.26:2377 This node joined a swarm as a worker. Swarm initialized: current node (uri5s1oes546txryvdv5hyu69) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-4n2nbpa5lntnbpomq8h412xliz9orjcxlrdjwhrg2v756nzfg0-0q4061v448gvcnqckd8t1z75k 107.170.205.26:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. Success
  • 9. Your Swarm Is Ready! root@astricon-sfo-1:~# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS zaecqxqlgj5n1jtxwi34r08cg astricon-london-1 Ready Active gq45t7og425dmanur0b4fz0p6 astricon-nyc-1 Ready Active uri5s1oes546txryvdv5hyu69 * astricon-sfo-1 Ready Active Leader • Only a single Manager • Managers are also workers with a little more overhead • All nodes report ready
  • 10. Let’s Get Our Asterisk Swarm On
  • 11. Swarm mode • Build your own Asterisk or utilize an existing image from Docker Hub • Docker Hub is built into all engines: • We’ll be using: • Now we need to define our services • We need to build a Stack file • A stack file is simply aYAML file in Compose format that lists the various services run by the swarm docker pull <IMAGE> respoke/asterisk:14
  • 13. version: "3.4" services: ### To demonstrate mesh networking, let’s use Nginx nginx: image: nginx ports: - 80:80 networks: - astricon-is-radical networks: astricon-is-radical: attachable: true Stack file for Nginx
  • 14. root@astricon-sfo-1:~# docker stack deploy -c nginx.yml astricon_swarm Creating network astricon_swarm_astricon-is-radical Creating service astricon_swarm_nginx • Deploy the Stack! • Check the Stack! root@astricon-sfo-1:~# docker service ls ID NAME MODE REPLICAS IMAGE PORTS 7a1292n9v49n astricon_swarm_nginx replicated 1/1 nginx:latest *:80->80/tcp • Scale the Stack! root@astricon-sfo-1:~# docker service scale —-detach=true astricon_swarm_nginx=2 astricon_swarm_nginx scaled to 2 ID NAME MODE REPLICAS IMAGE PORTS 7a1292n9v49n astricon_swarm_nginx replicated 2/2 nginx:latest *:80->80/tcp NYC-1 SFO-1 LONDON-1
  • 15. NYC-1 SFO-1 LONDON-1 astriconswarm.io • All requests pointed at IP addresses associated with the swarm will be load- balanced to machines with that exposed port • Even machines that aren’t running anything! Every node becomes and ingress node and will automatically address the correct service. • You can ping by service name! Overlay Network 172.18.0.2/16
  • 17. version: "3.4" services: ### The Big Kahuna! asterisk: image: respoke/asterisk:14 networks: - host_mode deploy: placement: constraints: [node.labels.service == asterisk] networks: host_mode: external: name: 'host' Asterisk Stack File The Paralysis of Choice version: "3.4" services: ### The Big Kahuna! asterisk: image: respoke/asterisk:14 networks: - astricon-is-radical deploy: placement: constraints: [node.labels.service == asterisk] networks: astricon-is-radical: attachable: true Host Mode Overlay Network
  • 18. Choosing a Network Mode • The issue: opening ports in Docker uses iptables • Opening many ports (*caugh RTP caugh*) results in a severe memory crunch • Each UDP port = ~1MB in RAM (Debian 9.1, DO) • Overlay Mode • Has full access to service discovery and mesh networking • Can’t run many open ports — perhaps a few hundred at most. • Host Mode • No access to overlay or service discovery network • Has full access to the underlying networking subsystems • Unlimited ports
  • 19. SECRET TRICK CIP=$(sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $CID) sudo iptables -A DOCKER -t nat -p udp -m udp ! -i docker0 --dport 10000:65535 -j DNAT --to-destination $CIP:10000-65535 sudo iptables -A DOCKER -p udp -m udp -d $CIP/32 ! -i docker0 -o docker0 --dport 10000:65535 -j ACCEPT sudo iptables -A POSTROUTING -t nat -p udp -m udp -s $CIP/32 -d $CIP/32 --dport 10000:65535 -j MASQUERADE Shout out to BetterVoice • Allows for a large port range to be opened with a single iptables rule • Must be run on any machine that is running Asterisk and can’t be run from inside the container (Swarm doesn’t allow privilege escalation)
  • 20. version: "3.4" services: ### The Big Kahuna! asterisk: image: respoke/asterisk:14 networks: - host_mode deploy: placement: constraints: [node.labels.service == asterisk] networks: host_mode: external: name: 'host' Asterisk Stack File version: "3.4" services: ### The Big Kahuna! asterisk: image: respoke/asterisk:14 networks: - astricon-is-radical deploy: placement: constraints: [node.labels.service == asterisk] networks: astricon-is-radical: attachable: true Revisited • Better for small business deployments • Simpler to manage, requires no extra DevOps (with small port ranges) • One at a time • Works more like a traditional Asterisk installation • Still functions with built-in HA / health checks / swarm deployment options • Many at a time
  • 22. DNS - Route 53 • Setup Geolocation to route to closest server • SRV records point to multiple datacenters • Health checks or API calls to verify uptime/downtime
  • 25. version: "3.4" services: ### The Big Kahuna! asterisk: image: respoke/asterisk:14 networks: - host_mode deploy: placement: constraints: [node.labels.service == asterisk] healthcheck: test: ["CMD", "sipsak", "-s", "sip:foo@astricon.swarm"] interval: 30s timeout: 15s retries: 3 networks: host_mode: external: name: 'host' Docker Healthcheck • Send an OPTIONS ping every 30s • If failure occurs, retry 3 times with a wait period of 15 seconds
  • 26. Data Persistence Secrets Management docker secrets create Node labels docker node update --label-add Private Registry docker service update --with-registry-auth
  • 27. Final Tips • Make your images generic • E.G. RingPlus abstracted away all business logic to API calls.This made our B2BUAs functionally interchangeable. • Cows, not kittens. • Leverage all the pieces of Swarm that you can. • It can replace a bunch of auxiliary tools and cron scripts • It forces you to think of things as components in a larger system and how they all fit together. • No singleVM running 15 different components installed by a consultant or someone who left the company a year ago. • Your deployments become far less brittle and are easier to test. • Development / Production Parity