SlideShare a Scribd company logo
Containerizing MongoDB with
Kubernetes
Dan Worth (fuboTV)
Brian McNamara (CloudyOps)
Who are we?
Dan Worth
● Software Engineer
● Currently at fuboTV
● @djworth on the Internet
Who are we?
Brian McNamara
● Ops Engineer
● @mcnamarabrian / @cloudyops
● Enjoys learning new things and quoting corny 80s comedies whenever possible
What are we going to talk about?
● In the beginning of fuboTV
● Fundamentals of Kubernetes (Dan)
● Fundamentals of MongoDB high availability (Brian)
● Challenges of running stateful services on Kubernetes (Brian)
Let’s Start with a Story...
fubo.tv Business Overview
● Sports first virtual multichannel video programming distributor (MVPD)
● Partnership with 21st Century Fox and Sky
● Create the best live events platform
● Subscription based
● Build communities around sports (teams, matches, players)
fubo.tv Started Taking Over Streaming World
● Needed scalable offering
● Bursty demand patterns around soccer / futbol matches
● Lots of in-house development experience
● Not a lot of in-house operational experience
● Didn’t want to maintain hardware
fubo.tv v1
● Node.js hosted with well-known PaaS provider
● MongoDB hosted with a separate provider
● Focus was on introducing application features, iterating quickly
Things Changed in Philly
Enter Kubernetes
● Presentation by Kelsey Hightower
● Sysadmin who can code
● 2015 PhillyETE: Managing
Containers at Scale with CoreOS
and Kubernetes
● Container cluster manager
● Don’t sweat the scheduling of
containers in your cluster
● Live demo of rolling application
updates
Minds = Blown
How Can We Do That?
● Google’s infrastructure for everyone else
● Loved demo
● Saw the possibilities of Kubernetes
● But….still didn’t want to maintain hardware
Enter Google Container Engine
● No need to run a Kubernetes cluster in-house
● Google provided service
● Fully managed
Fundamentals of Kubernetes
● Open Source container cluster manager by Google
● Run Anywhere (GKE, GCE, AWS, Bare metal)
● Self-healing when using the right primitives
● Service discovery and load balancing
● Secret and configuration management
● Key high level domain objects
○ Pods
○ Replication Controllers
○ Services
Fundamentals of Kubernetes (Pods)
● Pods
○ Unit of Scheduling
○ One or more containers
○ Define environment
○ Pods get their own IP addresses
spec:
containers:
- name: mongo
image: mongo:3.2
ports:
- containerPort: 27017
resources:
limits:
cpu: 4
Fundamentals of Kubernetes (RC)
● Replication Controller
● All the goodness of the Pod
● Additional benefit of defining count of pods
Replication Controller Example
apiVersion: v1
kind: ReplicationController
metadata:
name: mongo1
spec:
replicas: 1
selector:
name: mongo1
template:
metadata:
labels:
name: mongo1
spec:
containers:
- name: mongo1
image: mongo:3.2
volumeMounts:
- name: mongo1-data
mountPath: /data/db
resources:
Limits:
cpu: 4
memory: 4Gi
ports:
- name: "mongo"
containerPort: 27017
protocol: TCP
command:
- ...
Fundamentals of Kubernetes (Services)
● Provides stable endpoint to pods / replication controllers
● Uses metadata like ports and selectors to identify how to map endpoint to pod
Service Example
apiVersion: v1
kind: Service
metadata:
name: mongo1-service
labels:
name: mongo1-service
spec:
ports:
- port: 27017
targetPort: 27017
protocol: TCP
selector:
name: mongo1
type: LoadBalancer
Fundamentals of Kubernetes
Service
Replication Controller
Pod Pod Pod
Fundamentals of MongoDB High Availability
● Possible to scale reads and writes
○ Scaling reads: use replica sets
○ Scaling writes: use shards
● Clients can do things to take advantage of availability primitives
● We’ll focus on scaling reads using replica sets
Fundamentals of MongoDB High Availability (cont)
MongoDB Replica Set
Fundamentals of MongoDB High Availability (cont)
Heartbeat among replica set members
Fundamentals of MongoDB High Availability (cont)
Automated election of Primary in the event of failure
Fundamentals of MongoDB High Availability (cont)
> rs.config()
{
"_id" : "replica_set_name",
"version" : 105978,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "ip_or_hostname:port_number",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
…
}
}
Challenges of Running Stateful Services on Kubernetes
● Kubernetes is amazing at running and rescheduling containers with Pods,
Replication Controllers, and Services
● Stateless services are easiest to manage but...
● Sometimes we need things to maintain state
Challenges of Running Stateful Services MongoDB on
Kubernetes
● Kubernetes Replication Controller
○ Ensure requisite number of Pods are scheduled
○ Don’t guarantee consistent hostname or IP address
● MongoDB replica set configuration uses well defined endpoints
○ Remember that rs.conf() output?
○ Updating replica set configuration by hand feels dirty and you’re a bad person if you want to do
that.
● MongoDB data should persist
○ If not, when a new replica set member comes up there will be a full sync
○ Kubernetes manages the scheduling but who needs the full sync?
Containerizing MongoDB with kubernetes
Built-in Primitives to the Rescue
● Kubernetes
○ Replication Controller + Service
○ Label selector allows for consistent association between pod and service hostname / IP
○ Persistent volume can be defined
■ Allows GCE volumes to move with Pod
■ Result: No need to do expensive resync of data
● MongoDB
○ Take advantage of service endpoint when defining replica set
■ Service IP or DNS
Kubernetes - Code Samples
Replication Controller Code
Service Code
Parting Thoughts
● MongoDB has good resilience in the face of failure but be sure to test different
failure scenarios.
● Docker is great to work with, but make sure your development workflows, tools
and harnesses are adapted to build and run apps with it.
● Kubernetes is still relatively young, but maturing quickly. You need to carefully
evaluate whether you want to roll your own platform with it, or instead rely on a
hosted service like Google Container Engine
Questions?
… and thanks!
Dan Worth (@djworth)
Brian McNamara (@mcnamarabrian / @cloudyops)
References
Google Container Engine (GKE)
Kubernetes Docs
MongoDB Read Preference
MongoDB Replication Introduction
MongoDB Replica Set Tag Sets
MongoDB Leaf in the Wild Post
CloudyOps Deploying a 3-node MongoDB Replica Set with Kubernetes
2015 PhillyETE: Managing Containers at Scale with CoreOS and Kubernetes

More Related Content

PPTX
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
PPTX
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDB
PPTX
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
PPTX
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
PPTX
Securing Your Enterprise Web Apps with MongoDB Enterprise
PPTX
Practical Design Patterns for Building Applications Resilient to Infrastructu...
PPTX
Powering Microservices with Docker, Kubernetes, Kafka, & MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDB
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Securing Your Enterprise Web Apps with MongoDB Enterprise
Practical Design Patterns for Building Applications Resilient to Infrastructu...
Powering Microservices with Docker, Kubernetes, Kafka, & MongoDB

What's hot (20)

PDF
An Elastic Metadata Store for eBay’s Media Platform
PPTX
Introducing Stitch
PDF
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
PPTX
MongoDB Internals
PDF
Mongo DB Monitoring - Become a MongoDB DBA
PPTX
Sizing MongoDB on AWS with Wired Tiger-Patrick and Vigyan-Final
PPTX
Scaling MongoDB to a Million Collections
PDF
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
PPTX
Sizing MongoDB Clusters
PPTX
Using Aggregation for Analytics
PPTX
It's a Dangerous World
PDF
Where is my cache architectural patterns for caching microservices by example
PDF
5 Levels of High Availability: From Multi-instance to Hybrid Cloud
PPTX
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
PPTX
Building the Real-Time Performance Panel
PPTX
Conceptos Avanzados 1: Motores de Almacenamiento
PDF
Automating and Managing MongoDB: An Analysis of Ops Manager vs. ClusterControl
PDF
MongoDB World 2016: From the Polls to the Trolls: Seeing What the World Think...
PDF
Engineering an Encrypted Storage Engine
PDF
MongoDB WiredTiger Internals
An Elastic Metadata Store for eBay’s Media Platform
Introducing Stitch
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB Internals
Mongo DB Monitoring - Become a MongoDB DBA
Sizing MongoDB on AWS with Wired Tiger-Patrick and Vigyan-Final
Scaling MongoDB to a Million Collections
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Sizing MongoDB Clusters
Using Aggregation for Analytics
It's a Dangerous World
Where is my cache architectural patterns for caching microservices by example
5 Levels of High Availability: From Multi-instance to Hybrid Cloud
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
Building the Real-Time Performance Panel
Conceptos Avanzados 1: Motores de Almacenamiento
Automating and Managing MongoDB: An Analysis of Ops Manager vs. ClusterControl
MongoDB World 2016: From the Polls to the Trolls: Seeing What the World Think...
Engineering an Encrypted Storage Engine
MongoDB WiredTiger Internals
Ad

Viewers also liked (17)

PPTX
MongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
PDF
Scaling and Orchestrating Microservices with OSGi - N Bartlett
PPTX
The rise of microservices - containers and orchestration
PDF
OSGi ecosystems compared on Apache Karaf - Christian Schneider
PDF
MongoDB World 2016: Get MEAN and Lean with MongoDB and Kubernetes
PDF
MongoDB memory management demystified
PDF
KubeCon EU 2016: Full Automatic Database: PostgreSQL HA with Kubernetes
PDF
Highly scalable caching service on cloud - Redis
PDF
DBaaS- Database as a Service in a DBAs World
PDF
Managing Redis with Kubernetes - Kelsey Hightower, Google
PDF
Intro to OpenShift, MongoDB Atlas & Live Demo
PPTX
Data Streaming with Apache Kafka & MongoDB - EMEA
PDF
kubernetes, pourquoi et comment
PPTX
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
PPTX
Stateful set in kubernetes implementation & usecases
PPTX
Back to Basics Webinar 1: Introduction to NoSQL
PDF
Deploying deep learning models with Docker and Kubernetes
MongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
Scaling and Orchestrating Microservices with OSGi - N Bartlett
The rise of microservices - containers and orchestration
OSGi ecosystems compared on Apache Karaf - Christian Schneider
MongoDB World 2016: Get MEAN and Lean with MongoDB and Kubernetes
MongoDB memory management demystified
KubeCon EU 2016: Full Automatic Database: PostgreSQL HA with Kubernetes
Highly scalable caching service on cloud - Redis
DBaaS- Database as a Service in a DBAs World
Managing Redis with Kubernetes - Kelsey Hightower, Google
Intro to OpenShift, MongoDB Atlas & Live Demo
Data Streaming with Apache Kafka & MongoDB - EMEA
kubernetes, pourquoi et comment
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
Stateful set in kubernetes implementation & usecases
Back to Basics Webinar 1: Introduction to NoSQL
Deploying deep learning models with Docker and Kubernetes
Ad

Similar to Containerizing MongoDB with kubernetes (20)

PDF
Kubernetes: My BFF
PPTX
Introduction to Kubernetes
PDF
Kubernetes deep dive - - Huawei 2015-10
PDF
Using kubernetes to lose your fear of using containers
PDF
Containerize! Between Docker and Jube.
PDF
Intro to Kubernetes
PPTX
Introduction to Kubernetes
PPTX
Kubernetes Introduction
PDF
MongoDB Ops Manager + Kubernetes
PDF
99cloud Docker Training module 2
PDF
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
PPTX
A Primer on Kubernetes and Google Container Engine
PDF
Openstack days sv building highly available services using kubernetes (preso)
PPTX
Powering Microservices with Docker, Kubernetes, Kafka, & MongoDB
PDF
Cluster management with Kubernetes
PDF
From Docker To Kubernetes: A Developer's Guide To Containers - Mandy White - ...
PDF
Why kubernetes for Serverless (FaaS)
PDF
Kubernetes for Serverless - Serverless Summit 2017 - Krishna Kumar
PPTX
Containers and Kubernetes -Notes Leo
PDF
Orchestrating Linux Containers
Kubernetes: My BFF
Introduction to Kubernetes
Kubernetes deep dive - - Huawei 2015-10
Using kubernetes to lose your fear of using containers
Containerize! Between Docker and Jube.
Intro to Kubernetes
Introduction to Kubernetes
Kubernetes Introduction
MongoDB Ops Manager + Kubernetes
99cloud Docker Training module 2
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
A Primer on Kubernetes and Google Container Engine
Openstack days sv building highly available services using kubernetes (preso)
Powering Microservices with Docker, Kubernetes, Kafka, & MongoDB
Cluster management with Kubernetes
From Docker To Kubernetes: A Developer's Guide To Containers - Mandy White - ...
Why kubernetes for Serverless (FaaS)
Kubernetes for Serverless - Serverless Summit 2017 - Krishna Kumar
Containers and Kubernetes -Notes Leo
Orchestrating Linux Containers

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
KodekX | Application Modernization Development
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Teaching material agriculture food technology
sap open course for s4hana steps from ECC to s4
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
KodekX | Application Modernization Development
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
Understanding_Digital_Forensics_Presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm

Containerizing MongoDB with kubernetes

  • 1. Containerizing MongoDB with Kubernetes Dan Worth (fuboTV) Brian McNamara (CloudyOps)
  • 2. Who are we? Dan Worth ● Software Engineer ● Currently at fuboTV ● @djworth on the Internet
  • 3. Who are we? Brian McNamara ● Ops Engineer ● @mcnamarabrian / @cloudyops ● Enjoys learning new things and quoting corny 80s comedies whenever possible
  • 4. What are we going to talk about? ● In the beginning of fuboTV ● Fundamentals of Kubernetes (Dan) ● Fundamentals of MongoDB high availability (Brian) ● Challenges of running stateful services on Kubernetes (Brian)
  • 5. Let’s Start with a Story...
  • 6. fubo.tv Business Overview ● Sports first virtual multichannel video programming distributor (MVPD) ● Partnership with 21st Century Fox and Sky ● Create the best live events platform ● Subscription based ● Build communities around sports (teams, matches, players)
  • 7. fubo.tv Started Taking Over Streaming World ● Needed scalable offering ● Bursty demand patterns around soccer / futbol matches ● Lots of in-house development experience ● Not a lot of in-house operational experience ● Didn’t want to maintain hardware
  • 8. fubo.tv v1 ● Node.js hosted with well-known PaaS provider ● MongoDB hosted with a separate provider ● Focus was on introducing application features, iterating quickly
  • 10. Enter Kubernetes ● Presentation by Kelsey Hightower ● Sysadmin who can code ● 2015 PhillyETE: Managing Containers at Scale with CoreOS and Kubernetes ● Container cluster manager ● Don’t sweat the scheduling of containers in your cluster ● Live demo of rolling application updates
  • 12. How Can We Do That? ● Google’s infrastructure for everyone else ● Loved demo ● Saw the possibilities of Kubernetes ● But….still didn’t want to maintain hardware
  • 13. Enter Google Container Engine ● No need to run a Kubernetes cluster in-house ● Google provided service ● Fully managed
  • 14. Fundamentals of Kubernetes ● Open Source container cluster manager by Google ● Run Anywhere (GKE, GCE, AWS, Bare metal) ● Self-healing when using the right primitives ● Service discovery and load balancing ● Secret and configuration management ● Key high level domain objects ○ Pods ○ Replication Controllers ○ Services
  • 15. Fundamentals of Kubernetes (Pods) ● Pods ○ Unit of Scheduling ○ One or more containers ○ Define environment ○ Pods get their own IP addresses spec: containers: - name: mongo image: mongo:3.2 ports: - containerPort: 27017 resources: limits: cpu: 4
  • 16. Fundamentals of Kubernetes (RC) ● Replication Controller ● All the goodness of the Pod ● Additional benefit of defining count of pods
  • 17. Replication Controller Example apiVersion: v1 kind: ReplicationController metadata: name: mongo1 spec: replicas: 1 selector: name: mongo1 template: metadata: labels: name: mongo1 spec: containers: - name: mongo1 image: mongo:3.2 volumeMounts: - name: mongo1-data mountPath: /data/db resources: Limits: cpu: 4 memory: 4Gi ports: - name: "mongo" containerPort: 27017 protocol: TCP command: - ...
  • 18. Fundamentals of Kubernetes (Services) ● Provides stable endpoint to pods / replication controllers ● Uses metadata like ports and selectors to identify how to map endpoint to pod
  • 19. Service Example apiVersion: v1 kind: Service metadata: name: mongo1-service labels: name: mongo1-service spec: ports: - port: 27017 targetPort: 27017 protocol: TCP selector: name: mongo1 type: LoadBalancer
  • 21. Fundamentals of MongoDB High Availability ● Possible to scale reads and writes ○ Scaling reads: use replica sets ○ Scaling writes: use shards ● Clients can do things to take advantage of availability primitives ● We’ll focus on scaling reads using replica sets
  • 22. Fundamentals of MongoDB High Availability (cont) MongoDB Replica Set
  • 23. Fundamentals of MongoDB High Availability (cont) Heartbeat among replica set members
  • 24. Fundamentals of MongoDB High Availability (cont) Automated election of Primary in the event of failure
  • 25. Fundamentals of MongoDB High Availability (cont) > rs.config() { "_id" : "replica_set_name", "version" : 105978, "protocolVersion" : NumberLong(1), "members" : [ { "_id" : 0, "host" : "ip_or_hostname:port_number", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : {}, "slaveDelay" : NumberLong(0), "votes" : 1 }, { … } }
  • 26. Challenges of Running Stateful Services on Kubernetes ● Kubernetes is amazing at running and rescheduling containers with Pods, Replication Controllers, and Services ● Stateless services are easiest to manage but... ● Sometimes we need things to maintain state
  • 27. Challenges of Running Stateful Services MongoDB on Kubernetes ● Kubernetes Replication Controller ○ Ensure requisite number of Pods are scheduled ○ Don’t guarantee consistent hostname or IP address ● MongoDB replica set configuration uses well defined endpoints ○ Remember that rs.conf() output? ○ Updating replica set configuration by hand feels dirty and you’re a bad person if you want to do that. ● MongoDB data should persist ○ If not, when a new replica set member comes up there will be a full sync ○ Kubernetes manages the scheduling but who needs the full sync?
  • 29. Built-in Primitives to the Rescue ● Kubernetes ○ Replication Controller + Service ○ Label selector allows for consistent association between pod and service hostname / IP ○ Persistent volume can be defined ■ Allows GCE volumes to move with Pod ■ Result: No need to do expensive resync of data ● MongoDB ○ Take advantage of service endpoint when defining replica set ■ Service IP or DNS
  • 30. Kubernetes - Code Samples Replication Controller Code Service Code
  • 31. Parting Thoughts ● MongoDB has good resilience in the face of failure but be sure to test different failure scenarios. ● Docker is great to work with, but make sure your development workflows, tools and harnesses are adapted to build and run apps with it. ● Kubernetes is still relatively young, but maturing quickly. You need to carefully evaluate whether you want to roll your own platform with it, or instead rely on a hosted service like Google Container Engine
  • 32. Questions? … and thanks! Dan Worth (@djworth) Brian McNamara (@mcnamarabrian / @cloudyops)
  • 33. References Google Container Engine (GKE) Kubernetes Docs MongoDB Read Preference MongoDB Replication Introduction MongoDB Replica Set Tag Sets MongoDB Leaf in the Wild Post CloudyOps Deploying a 3-node MongoDB Replica Set with Kubernetes 2015 PhillyETE: Managing Containers at Scale with CoreOS and Kubernetes