SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
Building and
deploying a
distributed
application with
Docker, Mesos and
Marathon
Julia MateoMADRID · NOV 27-28 · 2015
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
WHO AM I
- Java developer consultant and tech lead at Hortis GRC
(Geneva, Switzerland)
- Team jDuchess Swiss
@juliamateodc
@duchessswiss
http://jduchess.ch/
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
GOALS (1st part of the workshop)
• Present cm-voting, a distributed web application
• Run cm-voting with docker links
• Run cm-voting with docker compose
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
GOALS (2nd part of the workshop)
• Create a Mesos cluster
• Mesos DNS
• Deploy cm-voting on mesos cluster
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
IN THE MEANTIME....
- 2 ways of doing this
workshop :
Mode A :
- RECOMMENDED : install
virtualbox (available USB) and
copy workshop virtual box image
Mode B :
- You will need a browser and a Client HTTP
(like Postman Rest client for Chrome)
- Install docker 1.9.1 (Linux) or Docker
toolbox (Windows and Mac). Copy and load
the docker images we will use from the USB
keys
- Then, load them on your host :
docker load -i <path_image_tar_file>
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
CODE MOTION VOTING
- Go webapp build on Revel
- Voting app for Code Motion
conference
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
CODE MOTION VOTING
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
CODE MOTION VOTING
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
DEPLOY APP ON DOCKER
Friday, November 27, 15
From https://www.docker.com/whatisdocker/
• Docker is an open platform for developers and
sysadmins to build, ship, and run distributed
applications.
DOCKER
Friday, November 27, 15
DOCKER
Server
Host OS
Hypervisor
Guest
OS
Guest
OS
Guest
OS
Guest
OS
Libs/ Libs/ Libs/
App 1 App 2 App 3 App 4
Libs/
Server
Host OS
Docker Engine
Libs/Bins Libs/
App 1 App 2 App 3 App 4
c1 c2 c3 c4
VM1 VM2 VM3 VM4
Friday, November 27, 15
Docker
Images
Docker
Images
libcontainer, Union Filesystem
Centos Ubuntu
Jetty
add App.war
Container 1
OracleDB
Container 2
Read
only
Writable
Writable
Read
only
CONTAINERS AND IMAGES
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
DEPLOY CODE MOTION VOTING WITH DOCKER
- Let’s start !
- See webapp doc https://github.com/karesti/cm-voting
- Git clone https://github.com/karesti/cm-voting
- If using virtual box image, go to :
/home/codemotion/cm-voting
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
DEPLOY CODE MOTION VOTING WITH DOCKER
- Follow the instructions in https://github.com/karesti/cm-voting :
- Open your terminal and run the mongo container :
> sudo docker run -i -t -d --name mongo_cmvoting -p 27017:27017 mongo
> cd cm-voting
- Build and run cm-voting:
> sudo docker build -t cm-voting .
> sudo docker run -i -t -p 9000:9000 --link mongo_cmvoting:mongo cm-voting
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
DOCKER COMPOSE
- Instead of using docker links :
> sudo docker run -i -t -p 9000:9000 --link mongo_cmvoting:mongo cm-voting
- You can use docker compose
> sudo docker-compose up
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
DEPLOY WEB APP ON MESOS
Friday, November 27, 15
• Abstraction of cluster resources
• Share resources across multiple frameworks (versions of the same fwk)
• Resource fair sharing : alternative to static partitioning
• Data locality
MESOS
Friday, November 27, 15
ZK
Master Master
Executor Executor Executor
Executor ExecutorExecutor
Executor Executor Executor
Slaves
MESOS
Friday, November 27, 15
http://mesos.apache.org/documentation/latest/mesos-architecture/
MESOS
Friday, November 27, 15
• Marathon is a Mesos framework written in Scala
• Provides easy deployment of Docker containers
• Manages of long running apps
• Rest API for developers
MESOS
Friday, November 27, 15
ZK
Master Master
Executor Executor Executor
Executor ExecutorExecutor
Executor Executor Executor
Slaves
MESOS
Friday, November 27, 15
ZK
Master Master
Executor Executor Executor
Executor ExecutorExecutor
Executor Executor Executor
Slaves
Marathon
MESOS
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
LET’S CREATE A MESOS CLUSTER !
- Create a mesos cluster in localhost
- Docker binding
- Using different ports
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
DOCKER VOLUMES AND DOCKER BINDING
Host
/home/codemotion/mongo/data
Docker container
/data/db
Host
Docker container
/var/run/docker.sock
/var/run/docker.sock
Docker volume : directory Docker volume : file
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
CREATE MESOS CLUSTER
- If you are using Docker toolkit : set HOST_IP env variable with your Docker host (in
my case, 10.0.2.15)
export HOST_IP=10.0.2.15
- Launch zookeeper container
sudo docker run -d -e SERVER_ID=1 -p 2181:2181 zookeeper
- Launch mesos master container
sudo docker run -d -p 5050:5050 -e "MESOS_HOSTNAME=${HOST_IP}" -e "MESOS_IP=${HOST_IP}" -e
"MESOS_QUORUM=1" -e "MESOS_ZK=zk://${HOST_IP}:2181/mesos" --name mesos-master -e
"MESOS_LOG_DIR=/var/log/mesos" --net host --restart always mesoscloud/mesos-master:0.23.0-centos-7
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
CREATE MESOS CLUSTER
- Launch marathon
sudo docker run -d -e "MARATHON_HOSTNAME=${HOST_IP}" -e "MARATHON_HTTPS_ADDRESS=$
{HOST_IP}" -e "MARATHON_HTTP_ADDRESS=${HOST_IP}" -e "MARATHON_MASTER=zk://${HOST_IP}:
2181/mesos" -e "MARATHON_ZK=zk://${HOST_IP}:2181/marathon" --name marathon --net host --restart
always mesoscloud/marathon:0.10.0-centos-7
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
CREATE MESOS CLUSTER
- Launch mesos slave 1
sudo docker run -p 5051:5051 -d -e "MESOS_HOSTNAME=${HOST_IP}" -e "MESOS_IP=${HOST_IP}" -e
"MESOS_MASTER=zk://${HOST_IP}:2181/mesos" -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/docker.sock:/var/run/
docker.sock --name slave1 --net host --privileged --restart always mesoscloud/mesos-slave:0.23.0-centos-7
- Launch mesos slave 2
sudo docker run -p 5052:5052 -d -e "MESOS_HOSTNAME=${HOST_IP}" -e MESOS_PORT=5052 -e "MESOS_IP=$
{HOST_IP}" -e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/
docker.sock:/var/run/docker.sock --name slave2 --net host --privileged --restart always mesoscloud/mesos-slave:
0.23.0-centos-7
- Launch mesos slave 3
sudo docker run -p 5053:5053 -d -e "MESOS_HOSTNAME=${HOST_IP}" -e MESOS_PORT=5053 -e "MESOS_IP=$
{HOST_IP}" -e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/
docker.sock:/var/run/docker.sock --name slave3 --net host --privileged --restart always mesoscloud/mesos-slave:
0.23.0-centos-7
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
TEST THAT EVERYTHING WORKS OK
- Portal Mesos : http://<HOST_IP>:5050
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
TEST THAT EVERYTHING WORKS OK
- Portal Marathon : http://<HOST_IP>:8080
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY
cm-voting
Node 1 Node 2
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY
cm-voting
Node 1 Node 2
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY
cm-voting
Node 1 Node 2
IP ?
PORT ?
CREDENTIALS
??
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY
cm-voting
Mesos
slave 1
Mesos
slave 2
REPLICATION,
LOAD BALANCING...
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY
cm-voting
Node 1 Node 2
... AND FAILOVER
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY : MESOS DNS
https://github.com/mesosphere/mesos-dns
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
Build Mesos DNS Image
- Git clone : https://github.com/jmateo/mesosdns
- cd mesosdns
- Edit config.json :
sed -i -e “s/HOST_IP/$HOST_IP/g” config.json
- Build the image :
docker build -t mesosdns .
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY WITH MESOS DNS
1. Launch Mesos DNS container with Marathon
2. Launch Mongo container
3. Connect to one of the Mesos slaves and look for the
mongo service (you can use dig command for doing this)
4. Modify the class connection.go to connect dynamically
cm-voting to mongo using service discovery (see
MesosDNS REST API)
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
LAUNCH MESOS DNS WITH MARATHON
HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
LAUNCH MESOS DNS WITH MARATHON
{
"id": "mesos-dns",
"cmd": "/mesos-dns",
"cpus": 0.5,
"mem": 500,
"container": {
"type": "DOCKER",
"docker": {
"image": "mesosdns",
"network": "HOST"
}
}
}
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
LAUNCH MONGO CONTAINER WITH MARATHON
HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
LAUNCH MONGO CONTAINER WITH MARATHON
{
"id": "mongo",
"cmd": "cat /etc/resolv.conf > /tmp/temp && echo "nameserver 10.0.2.15" > /etc/resolv.conf && cat /tmp/temp >> /etc/resolv.conf && mongod",
"cpus": 0.5,
"mem": 500.0,
"container": {
"type": "DOCKER",
"docker": {
"image": "mongo",
"privileged": true,
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 27017, "hostPort": 0 }
]
}
}
}
HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
LAUNCH CMVOTING WITH MARATHON
{
"id": "cmvoting",
"cmd": "cat /etc/resolv.conf > /tmp/temp && echo "nameserver 10.0.2.15" > /etc/resolv.conf && cat /tmp/temp
>> /etc/resolv.conf && revel run github.com/karesti/cm-voting prod 9000",
"cpus": 0.5,
"mem": 500.0,
"container": {
"type": "DOCKER",
"docker": {
"image": "cm-voting",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 9000, "hostPort": 0 }
]
}
},
"env": {
! "SERVICE_NAME": "mongo"
}
}
HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true
Friday, November 27, 15
MADRID · NOV 27-28 · 2015
SERVICE DISCOVERY WITH MESOS DNS
4. Test it :
Friday, November 27, 15

Contenu connexe

Tendances

Tendances (20)

Musings on Mesos: Docker, Kubernetes, and Beyond.
Musings on Mesos: Docker, Kubernetes, and Beyond.Musings on Mesos: Docker, Kubernetes, and Beyond.
Musings on Mesos: Docker, Kubernetes, and Beyond.
 
Mesos and Kubernetes ecosystem overview
Mesos and Kubernetes ecosystem overviewMesos and Kubernetes ecosystem overview
Mesos and Kubernetes ecosystem overview
 
Containers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. KubernetesContainers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. Kubernetes
 
HA Kubernetes on Mesos / Marathon
HA Kubernetes on Mesos / MarathonHA Kubernetes on Mesos / Marathon
HA Kubernetes on Mesos / Marathon
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
 
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
 
Kubernetes on Top of Mesos on Top of DCOS
Kubernetes on Top of Mesos on Top of DCOSKubernetes on Top of Mesos on Top of DCOS
Kubernetes on Top of Mesos on Top of DCOS
 
Docker on mesos
Docker on mesosDocker on mesos
Docker on mesos
 
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconfContinuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
 
Introduction to mesos bay
Introduction to mesos bayIntroduction to mesos bay
Introduction to mesos bay
 
Platform as a Service with Kubernetes and Mesos
Platform as a Service with Kubernetes and Mesos Platform as a Service with Kubernetes and Mesos
Platform as a Service with Kubernetes and Mesos
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
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...
 
Federated mesos clusters for global data center designs
Federated mesos clusters for global data center designsFederated mesos clusters for global data center designs
Federated mesos clusters for global data center designs
 
Crossing the Streams Mesos &lt;> Kubernetes
Crossing the Streams Mesos &lt;> KubernetesCrossing the Streams Mesos &lt;> Kubernetes
Crossing the Streams Mesos &lt;> Kubernetes
 
Apache Mesos
Apache MesosApache Mesos
Apache Mesos
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5
 
Scaling Development Environments with Docker
Scaling Development Environments with DockerScaling Development Environments with Docker
Scaling Development Environments with Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
runC: The little engine that could (run Docker containers) by Docker Captain ...
runC: The little engine that could (run Docker containers) by Docker Captain ...runC: The little engine that could (run Docker containers) by Docker Captain ...
runC: The little engine that could (run Docker containers) by Docker Captain ...
 

En vedette

Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Carlos Sanchez
 

En vedette (20)

Deploying Docker Containers at Scale with Mesos and Marathon
Deploying Docker Containers at Scale with Mesos and MarathonDeploying Docker Containers at Scale with Mesos and Marathon
Deploying Docker Containers at Scale with Mesos and Marathon
 
Continuous delivery with jenkins, docker and exoscale
Continuous delivery with jenkins, docker and exoscaleContinuous delivery with jenkins, docker and exoscale
Continuous delivery with jenkins, docker and exoscale
 
Mesos & Marathon - Piloter les services de votre système
Mesos & Marathon - Piloter les services de votre systèmeMesos & Marathon - Piloter les services de votre système
Mesos & Marathon - Piloter les services de votre système
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Integrating Docker with Mesos and Marathon
Integrating Docker with Mesos and MarathonIntegrating Docker with Mesos and Marathon
Integrating Docker with Mesos and Marathon
 
Workshop mesos docker devoxx fr 2016
Workshop mesos docker devoxx fr 2016Workshop mesos docker devoxx fr 2016
Workshop mesos docker devoxx fr 2016
 
Jenkins + Pipeline Plugin + Docker
Jenkins + Pipeline Plugin + DockerJenkins + Pipeline Plugin + Docker
Jenkins + Pipeline Plugin + Docker
 
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm ModeContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
Distcp
DistcpDistcp
Distcp
 
Enterprise Docker Requires a Private Registry
Enterprise Docker Requires a Private RegistryEnterprise Docker Requires a Private Registry
Enterprise Docker Requires a Private Registry
 
ContainerDayVietnam2016: Containers with OpenStack
ContainerDayVietnam2016: Containers with OpenStackContainerDayVietnam2016: Containers with OpenStack
ContainerDayVietnam2016: Containers with OpenStack
 
Hero's Tookit: Start Your Rugged DevOps Journey with Nexus, Jenkins and Docker
Hero's Tookit: Start Your Rugged DevOps Journey with Nexus, Jenkins and DockerHero's Tookit: Start Your Rugged DevOps Journey with Nexus, Jenkins and Docker
Hero's Tookit: Start Your Rugged DevOps Journey with Nexus, Jenkins and Docker
 
Easy Docker Deployments with Mesosphere DCOS on Azure
Easy Docker Deployments with Mesosphere DCOS on AzureEasy Docker Deployments with Mesosphere DCOS on Azure
Easy Docker Deployments with Mesosphere DCOS on Azure
 
ContainerDayVietnam2016: Docker at scale with Mesos
ContainerDayVietnam2016: Docker at scale with MesosContainerDayVietnam2016: Docker at scale with Mesos
ContainerDayVietnam2016: Docker at scale with Mesos
 
Locally it worked! virtualizing docker
Locally it worked! virtualizing dockerLocally it worked! virtualizing docker
Locally it worked! virtualizing docker
 
Culture Hacker: How to Herd CATTs and Inspire Rebels to Change the World! - S...
Culture Hacker: How to Herd CATTs and Inspire Rebels to Change the World! - S...Culture Hacker: How to Herd CATTs and Inspire Rebels to Change the World! - S...
Culture Hacker: How to Herd CATTs and Inspire Rebels to Change the World! - S...
 
DCOS Presentation
DCOS PresentationDCOS Presentation
DCOS Presentation
 
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
 
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
 

Similaire à Building and deploying a distributed application with Docker, Mesos and Marathon

Similaire à Building and deploying a distributed application with Docker, Mesos and Marathon (20)

Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
 
Orchestrating Docker containers at scale
Orchestrating Docker containers at scaleOrchestrating Docker containers at scale
Orchestrating Docker containers at scale
 
Containerization: The DevOps Revolution
Containerization: The DevOps Revolution Containerization: The DevOps Revolution
Containerization: The DevOps Revolution
 
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on AzureDocker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
 
Containers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific TrioContainers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific Trio
 
Dev with Docker WCPHX 2019
Dev with Docker WCPHX 2019Dev with Docker WCPHX 2019
Dev with Docker WCPHX 2019
 
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
 
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDBPowering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
 
Docker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesDocker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notes
 
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed ApplicationsFrom Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
 
CCCEU15 run cloudstack in docker
CCCEU15 run cloudstack in dockerCCCEU15 run cloudstack in docker
CCCEU15 run cloudstack in docker
 
CloudStack Collab Conference 2015 Run CloudStack in Docker
CloudStack Collab Conference 2015 Run CloudStack in DockerCloudStack Collab Conference 2015 Run CloudStack in Docker
CloudStack Collab Conference 2015 Run CloudStack in Docker
 
Orchestrating docker containers at scale (#DockerKRK edition)
Orchestrating docker containers at scale (#DockerKRK edition)Orchestrating docker containers at scale (#DockerKRK edition)
Orchestrating docker containers at scale (#DockerKRK edition)
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 
Docker Dhahran November 2017 meetup
Docker Dhahran November 2017 meetupDocker Dhahran November 2017 meetup
Docker Dhahran November 2017 meetup
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
 
Cloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit KubernetesCloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit Kubernetes
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Building and deploying a distributed application with Docker, Mesos and Marathon

  • 1. Building and deploying a distributed application with Docker, Mesos and Marathon Julia MateoMADRID · NOV 27-28 · 2015 Friday, November 27, 15
  • 2. MADRID · NOV 27-28 · 2015 WHO AM I - Java developer consultant and tech lead at Hortis GRC (Geneva, Switzerland) - Team jDuchess Swiss @juliamateodc @duchessswiss http://jduchess.ch/ Friday, November 27, 15
  • 3. MADRID · NOV 27-28 · 2015 GOALS (1st part of the workshop) • Present cm-voting, a distributed web application • Run cm-voting with docker links • Run cm-voting with docker compose Friday, November 27, 15
  • 4. MADRID · NOV 27-28 · 2015 GOALS (2nd part of the workshop) • Create a Mesos cluster • Mesos DNS • Deploy cm-voting on mesos cluster Friday, November 27, 15
  • 5. MADRID · NOV 27-28 · 2015 IN THE MEANTIME.... - 2 ways of doing this workshop : Mode A : - RECOMMENDED : install virtualbox (available USB) and copy workshop virtual box image Mode B : - You will need a browser and a Client HTTP (like Postman Rest client for Chrome) - Install docker 1.9.1 (Linux) or Docker toolbox (Windows and Mac). Copy and load the docker images we will use from the USB keys - Then, load them on your host : docker load -i <path_image_tar_file> Friday, November 27, 15
  • 6. MADRID · NOV 27-28 · 2015 CODE MOTION VOTING - Go webapp build on Revel - Voting app for Code Motion conference Friday, November 27, 15
  • 7. MADRID · NOV 27-28 · 2015 CODE MOTION VOTING Friday, November 27, 15
  • 8. MADRID · NOV 27-28 · 2015 CODE MOTION VOTING Friday, November 27, 15
  • 9. MADRID · NOV 27-28 · 2015 DEPLOY APP ON DOCKER Friday, November 27, 15
  • 10. From https://www.docker.com/whatisdocker/ • Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. DOCKER Friday, November 27, 15
  • 11. DOCKER Server Host OS Hypervisor Guest OS Guest OS Guest OS Guest OS Libs/ Libs/ Libs/ App 1 App 2 App 3 App 4 Libs/ Server Host OS Docker Engine Libs/Bins Libs/ App 1 App 2 App 3 App 4 c1 c2 c3 c4 VM1 VM2 VM3 VM4 Friday, November 27, 15
  • 12. Docker Images Docker Images libcontainer, Union Filesystem Centos Ubuntu Jetty add App.war Container 1 OracleDB Container 2 Read only Writable Writable Read only CONTAINERS AND IMAGES Friday, November 27, 15
  • 13. MADRID · NOV 27-28 · 2015 DEPLOY CODE MOTION VOTING WITH DOCKER - Let’s start ! - See webapp doc https://github.com/karesti/cm-voting - Git clone https://github.com/karesti/cm-voting - If using virtual box image, go to : /home/codemotion/cm-voting Friday, November 27, 15
  • 14. MADRID · NOV 27-28 · 2015 DEPLOY CODE MOTION VOTING WITH DOCKER - Follow the instructions in https://github.com/karesti/cm-voting : - Open your terminal and run the mongo container : > sudo docker run -i -t -d --name mongo_cmvoting -p 27017:27017 mongo > cd cm-voting - Build and run cm-voting: > sudo docker build -t cm-voting . > sudo docker run -i -t -p 9000:9000 --link mongo_cmvoting:mongo cm-voting Friday, November 27, 15
  • 15. MADRID · NOV 27-28 · 2015 DOCKER COMPOSE - Instead of using docker links : > sudo docker run -i -t -p 9000:9000 --link mongo_cmvoting:mongo cm-voting - You can use docker compose > sudo docker-compose up Friday, November 27, 15
  • 16. MADRID · NOV 27-28 · 2015 DEPLOY WEB APP ON MESOS Friday, November 27, 15
  • 17. • Abstraction of cluster resources • Share resources across multiple frameworks (versions of the same fwk) • Resource fair sharing : alternative to static partitioning • Data locality MESOS Friday, November 27, 15
  • 18. ZK Master Master Executor Executor Executor Executor ExecutorExecutor Executor Executor Executor Slaves MESOS Friday, November 27, 15
  • 20. • Marathon is a Mesos framework written in Scala • Provides easy deployment of Docker containers • Manages of long running apps • Rest API for developers MESOS Friday, November 27, 15
  • 21. ZK Master Master Executor Executor Executor Executor ExecutorExecutor Executor Executor Executor Slaves MESOS Friday, November 27, 15
  • 22. ZK Master Master Executor Executor Executor Executor ExecutorExecutor Executor Executor Executor Slaves Marathon MESOS Friday, November 27, 15
  • 23. MADRID · NOV 27-28 · 2015 LET’S CREATE A MESOS CLUSTER ! - Create a mesos cluster in localhost - Docker binding - Using different ports Friday, November 27, 15
  • 24. MADRID · NOV 27-28 · 2015 DOCKER VOLUMES AND DOCKER BINDING Host /home/codemotion/mongo/data Docker container /data/db Host Docker container /var/run/docker.sock /var/run/docker.sock Docker volume : directory Docker volume : file Friday, November 27, 15
  • 25. MADRID · NOV 27-28 · 2015 CREATE MESOS CLUSTER - If you are using Docker toolkit : set HOST_IP env variable with your Docker host (in my case, 10.0.2.15) export HOST_IP=10.0.2.15 - Launch zookeeper container sudo docker run -d -e SERVER_ID=1 -p 2181:2181 zookeeper - Launch mesos master container sudo docker run -d -p 5050:5050 -e "MESOS_HOSTNAME=${HOST_IP}" -e "MESOS_IP=${HOST_IP}" -e "MESOS_QUORUM=1" -e "MESOS_ZK=zk://${HOST_IP}:2181/mesos" --name mesos-master -e "MESOS_LOG_DIR=/var/log/mesos" --net host --restart always mesoscloud/mesos-master:0.23.0-centos-7 Friday, November 27, 15
  • 26. MADRID · NOV 27-28 · 2015 CREATE MESOS CLUSTER - Launch marathon sudo docker run -d -e "MARATHON_HOSTNAME=${HOST_IP}" -e "MARATHON_HTTPS_ADDRESS=$ {HOST_IP}" -e "MARATHON_HTTP_ADDRESS=${HOST_IP}" -e "MARATHON_MASTER=zk://${HOST_IP}: 2181/mesos" -e "MARATHON_ZK=zk://${HOST_IP}:2181/marathon" --name marathon --net host --restart always mesoscloud/marathon:0.10.0-centos-7 Friday, November 27, 15
  • 27. MADRID · NOV 27-28 · 2015 CREATE MESOS CLUSTER - Launch mesos slave 1 sudo docker run -p 5051:5051 -d -e "MESOS_HOSTNAME=${HOST_IP}" -e "MESOS_IP=${HOST_IP}" -e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/docker.sock:/var/run/ docker.sock --name slave1 --net host --privileged --restart always mesoscloud/mesos-slave:0.23.0-centos-7 - Launch mesos slave 2 sudo docker run -p 5052:5052 -d -e "MESOS_HOSTNAME=${HOST_IP}" -e MESOS_PORT=5052 -e "MESOS_IP=$ {HOST_IP}" -e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/ docker.sock:/var/run/docker.sock --name slave2 --net host --privileged --restart always mesoscloud/mesos-slave: 0.23.0-centos-7 - Launch mesos slave 3 sudo docker run -p 5053:5053 -d -e "MESOS_HOSTNAME=${HOST_IP}" -e MESOS_PORT=5053 -e "MESOS_IP=$ {HOST_IP}" -e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/ docker.sock:/var/run/docker.sock --name slave3 --net host --privileged --restart always mesoscloud/mesos-slave: 0.23.0-centos-7 Friday, November 27, 15
  • 28. MADRID · NOV 27-28 · 2015 TEST THAT EVERYTHING WORKS OK - Portal Mesos : http://<HOST_IP>:5050 Friday, November 27, 15
  • 29. MADRID · NOV 27-28 · 2015 TEST THAT EVERYTHING WORKS OK - Portal Marathon : http://<HOST_IP>:8080 Friday, November 27, 15
  • 30. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY cm-voting Node 1 Node 2 Friday, November 27, 15
  • 31. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY cm-voting Node 1 Node 2 Friday, November 27, 15
  • 32. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY cm-voting Node 1 Node 2 IP ? PORT ? CREDENTIALS ?? Friday, November 27, 15
  • 33. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY cm-voting Mesos slave 1 Mesos slave 2 REPLICATION, LOAD BALANCING... Friday, November 27, 15
  • 34. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY cm-voting Node 1 Node 2 ... AND FAILOVER Friday, November 27, 15
  • 35. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY : MESOS DNS https://github.com/mesosphere/mesos-dns Friday, November 27, 15
  • 36. MADRID · NOV 27-28 · 2015 Build Mesos DNS Image - Git clone : https://github.com/jmateo/mesosdns - cd mesosdns - Edit config.json : sed -i -e “s/HOST_IP/$HOST_IP/g” config.json - Build the image : docker build -t mesosdns . Friday, November 27, 15
  • 37. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY WITH MESOS DNS 1. Launch Mesos DNS container with Marathon 2. Launch Mongo container 3. Connect to one of the Mesos slaves and look for the mongo service (you can use dig command for doing this) 4. Modify the class connection.go to connect dynamically cm-voting to mongo using service discovery (see MesosDNS REST API) Friday, November 27, 15
  • 38. MADRID · NOV 27-28 · 2015 LAUNCH MESOS DNS WITH MARATHON HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true Friday, November 27, 15
  • 39. MADRID · NOV 27-28 · 2015 LAUNCH MESOS DNS WITH MARATHON { "id": "mesos-dns", "cmd": "/mesos-dns", "cpus": 0.5, "mem": 500, "container": { "type": "DOCKER", "docker": { "image": "mesosdns", "network": "HOST" } } } Friday, November 27, 15
  • 40. MADRID · NOV 27-28 · 2015 LAUNCH MONGO CONTAINER WITH MARATHON HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true Friday, November 27, 15
  • 41. MADRID · NOV 27-28 · 2015 LAUNCH MONGO CONTAINER WITH MARATHON { "id": "mongo", "cmd": "cat /etc/resolv.conf > /tmp/temp && echo "nameserver 10.0.2.15" > /etc/resolv.conf && cat /tmp/temp >> /etc/resolv.conf && mongod", "cpus": 0.5, "mem": 500.0, "container": { "type": "DOCKER", "docker": { "image": "mongo", "privileged": true, "network": "BRIDGE", "portMappings": [ { "containerPort": 27017, "hostPort": 0 } ] } } } HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true Friday, November 27, 15
  • 42. MADRID · NOV 27-28 · 2015 LAUNCH CMVOTING WITH MARATHON { "id": "cmvoting", "cmd": "cat /etc/resolv.conf > /tmp/temp && echo "nameserver 10.0.2.15" > /etc/resolv.conf && cat /tmp/temp >> /etc/resolv.conf && revel run github.com/karesti/cm-voting prod 9000", "cpus": 0.5, "mem": 500.0, "container": { "type": "DOCKER", "docker": { "image": "cm-voting", "network": "BRIDGE", "portMappings": [ { "containerPort": 9000, "hostPort": 0 } ] } }, "env": { ! "SERVICE_NAME": "mongo" } } HTTP POST : http://<HOST_IP>:8080/v2/apps?force=true Friday, November 27, 15
  • 43. MADRID · NOV 27-28 · 2015 SERVICE DISCOVERY WITH MESOS DNS 4. Test it : Friday, November 27, 15