an introduction to container organization with docker swarm, kubernetes, mesos, and neo4j

33
A Gentle (Hands-on) Introduction to Container Orchestration with Docker Swarm, Kubernetes, Mesos Dippy Aggarwal Ph.D. Candidate, University of Cincinnati, Ohio

Upload: neo4j-the-fastest-and-most-scalable-native-graph-database

Post on 16-Apr-2017

374 views

Category:

Software


3 download

TRANSCRIPT

Page 1: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

A Gentle (Hands-on) Introductionto Container Orchestration withDocker Swarm, Kubernetes, Mesos

Dippy AggarwalPh.D. Candidate, University of Cincinnati, Ohio

Page 2: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Dippy Aggarwal Dissertation focus: Graph databases (Neo4j), data warehouses, schema evolution and provenance

Summer Intern 2016 at Cincinnati Children’s Hospital, Biomedical Informatics, High Performance Computing Team

Page 3: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

High Performance Computing Team, Biomedical Informatics,

Cincinnati Children’s Hospital

Carmen De VitoPrakash Velayuthum

Roberto Perea

Kevin Sandy

Mark Cunningham Jason Curtis

Page 4: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

OutlineMotivation: To present a conceptual and hands-on introduction for deploying Neo4j containers across a cluster using the three popular container orchestration tools –

Docker Swarm, Kubernetes and Mesos.

Orchestration 101

Overview of three orchestration tools: Kubernetes, Docker Swarm and Mesos

Demos – Automated cluster deployment of neo4j with the three orchestration approaches

Page 5: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

What is Docker/Containerization all about?

Ships goods Ships software

Stackable, portable, isolated

What purpose does containers solve in general?

[1] http://www.computerweekly.com/feature/Demystifying-Kubernetes-the-tool-to-manage-Google-scale-workloads-in-the-cloud[2] The Docker Book: Containerization is the new virtualization, James Turnbull, https://www.docker.com/what-docker

• Avoid “Runs on my machine” issues• Package your application as a standardized unit

Page 6: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Docker Progression (contd.)

Docker Adoption Is Up 30% in One Year 2/3 of Companies That Try Docker Adopt It

Adopters 5x Their container Count within 9 Months Docker Now Runs on 10% of the Hosts We Monitor

Source: https://www.datadoghq.com/docker-adoption/

Page 7: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

https://github.com/neo4j/docker-neo4j/blob/master/2.3.5/Dockerfile

Environment variables

Download and install Neo4j

Exposing ports

Running neo4j on start

Neo4j dockerfile

docker build –t neo4j:2.3 .docker run –publish 7474:7474 –publish 7473:7473 neo4j:2.3

Page 8: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

The Challenge• Containers by themselves are difficult to scale, achieve fault-tolerance• How to handle replication?• How to make multiple containers communicate?

How to deploy and manage multiple containers across a cluster of machines?

Orchestration is this idea of going from launching a container on one machine to multi-containers spread across a fleet of machines.

Page 9: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Orchestration Tools Survey

Kubernetes, Docker Swarm and Mesos – among the

leading products

http://thenewstack.io/tns-research-present-state-container-orchestration/

Page 10: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Last year@GraphConnect SF 2015

GraphConnect 2015 David Makogon, Microsoft and Patrick Chenzon, Docker - Containerized Neo4j: Automating Deployments with Docker

https://neo4j.com/blog/neo4j-containers-docker-azure/

Page 11: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Docker Swarm

Single Docker Engine Docker Swarm

- Native tool by Docker- Serves the standard Docker API 

Swarm-manager• Add additional nodes to the cluster seamlessly• Support single pool of resources• Maintains state of all the containers running on different docker engines• Make scheduling decisions

Page 12: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Image credits: http://www.slideshare.net/rajdeep/docker-swarm-introduction

Page 13: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Scheduling in Docker Swarm

Spread strategy: Swarm optimizes for the node with the least number of containers. Binpack strategy: Swarm optimize for the node which is most packed.

Swarm scheduler strategies

Running two containers on the same hostRunning containers on nodes meeting certain constraints: health checks, storage etc.docker tcp://<manager_ip:manager_port> run -d --name logger -e affinity:container==frontend logger

Swarm filters

Page 14: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Docker swarm cluster-setup

Page 15: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Commands to set up a Swarm cluster

Create discovery tokensdocker-machine create –d virtualbox localdocker run swarm createexport TOKEN=<token obtained from the last command>

Launching master and two agent nodes forming a cluster

Master: docker-machine create –d virtualbox --swarm --swarm-strategy=binpack --swarm-master --swarm-discovery token://${TOKEN} swarm-master Agent: docker-machine create –d virtualbox –swarm --swarm-discovery token://${TOKEN} swarm-agent1

Optional. Default strategy is spread

Page 16: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Demo: Deploy Neo4j Docker Container locally (VirtualBox) using Docker Swarm

Page 17: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Docker SwarmPros and Cons

+ Simplicity+ With Docker 1.12, several advanced features such as filters, auto-scaling made simpler

- Limited by Docker API functionality

docker service create –name frontend –replicas 5 -p 80:80/tcp nginx:latestScaling: docker service scale frontend=100

Page 18: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j
Page 19: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

What is Kubernetes• Container Orchestration tool developed by Google but

many participants• Container cluster manager

Image credit: http://www.webopedia.com/TERM/G/google-container-engine.html

Page 20: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Kubernetes- core concepts• Pod• Service• Replication Controller• Deployment

• Etcd• API server• Scheduler• Kubelet daemon• Kube-proxy

Page 21: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Service

Replication Controller

Understanding Kubernetes Primitives

Page 22: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Image credits: https://keithtenzer.com/2015/06/01/application-containers-kubernetes-and-docker-from-scratch/

Page 23: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Hands-On: Deploy Neo4j Docker Container on Google Cluster using Kubernetes

Page 24: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Kubernetes - Pros and Cons+ Driven by Google+ Provides more concepts than Swarm+ Docker 1.12 leveraging Kubernetes idea of abstraction using pods and services

Page 25: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Cluster Manager

Page 26: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

How Mesos help

Image Credits: http://www.slideshare.net/charmalloc/introductionapachemesosjstein20140714?next_slideshow=2

Page 27: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

How does Mesos help?

No static cluster partitioning required

Mesos offers a level of abstraction

Interleaved workloads

Page 28: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Another stack variation for Mesos

Use Kubernetes as container management tool

Can even have heterogeneous cluster : private and cloud

Page 29: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Mesos – core components• Master: Mediator between the underlying resources and the different

frameworks.-- Makes offers to frameworks about available resources and launches tasks on slaves for accepted offers. • Slaves: actual workhorses of the cluster.-- Execute tasks submitted by frameworks. • Frameworks: applications that run on Mesos and solve a specific use-case.-- Two components: Scheduler and Executor.

Page 30: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Hands-On: Deploy Neo4j Docker Container using Mesos/Marathon

Page 31: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Which one to choose?• Use Docker Swarm if:

You want to use the familiar Docker API to build Docker containers• Use Kubernetes if: - You want to launch pods, which are groups of containers co-scheduled and co-located together, sharing resources.

- You are a google fan!• Use Marathon if: You want to launch Docker or non-Docker long-running apps/services.

Choose your own adventure!

Page 32: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

References• http://talkincloud.com/cloud-computing-and-open-source/081914/mesosphere-launches-clusters-

google-compute-engine• http://events.linuxfoundation.org/sites/events/files/slides/CloudOpen14MesosKubGCE%20(1).pdf• "Mesos: The Operating System for your Cluster“, David Greenberg, https://www.youtube.com/watch?

v=gVGZHzRjvo0, Published: 09-21-2014• Building Web Scale Apps with Docker and Mesos, Alex Rukletsov, https://www.youtube.com/watch?

v=UdHG170jBxs, Published: 01-07-2015• http://stackoverflow.com/questions/29198840/marathon-vs-kubernetes-vs-docker-swarm-on-

mesosphere-with-docker-containers• https://open.mesosphere.com/advanced-course/installing-software/• Comparison Guide: https://apprenda.com/thank-you/gaw-container-orchestration-comparison-guide/

Page 33: An Introduction to Container Organization with Docker Swarm, Kubernetes, Mesos, and Neo4j

Thank you!

Questions/Feedback?