This document provides an overview of how to deploy and manage MongoDB in Kubernetes using the MongoDB Enterprise Kubernetes Operator. It begins with introductions to Kubernetes, Operators, and MongoDB Ops Manager. It then demonstrates deploying a sharded MongoDB cluster with the Operator, including examples of operational tasks like version upgrades, horizontal and vertical scaling. The document also covers topics like fault tolerance, performance, and automation benefits of the Operator. It concludes by stating the current beta status of the Operator and encouraging questions.
3. Agenda (Intro Demo)
What are Kubernetes, Operators & Ops
Manager?
Introducing the MongoDB Enterprise Operator
Demo: Deploying a Sharded Cluster
Examples: Operational Tasks with the Operator
Demo: Resiliency after Failure
Download / Contact info
40 minutes
4. … but mainly these questions ...
There are many ways to
deploy apps and MongoDB on
Kubernetes...
5. There are many ways to
deploy apps and MongoDB
on Kubernetes
Why do I need an Operator?
… but mainly these questions ...
6. There are many ways to
deploy apps and MongoDB
on Kubernetes
Why do I need an Operator?
Why should I use the
MongoDB Enterprise Operator?
… but mainly these questions ...
7. As an Operations / DevOps engineer
The Operator will make your life easier
Fewer manual tasks, more automated failure recovery
Skip straight to the answers!
8. As an Operations / DevOps engineer
The Operator will make your life easier
Fewer manual tasks, more automated failure recovery
As a Developer
Your company can provide MongoDB as a Service
Easy access to production-ready MongoDB with a single click
or command
Skip straight to the answers!
10. Definition
Kubernetes is an open-source container-orchestration system for automating deployment, scaling
and management of containerized applications.
It was originally designed by Google and is now maintained by the Cloud Native Computing
Foundation
11. Definition
Kubernetes is an open-source container-orchestration system for automating deployment, scaling
and management of containerized applications.
It was originally designed by Google and is now maintained by the Cloud Native Computing
Foundation
12. Containers
Isolated environments in which you can run your software
• Apps ship with their dependencies and configuration bundled in a container Image
• Less overhead than Virtual Machines
• eg. Docker / rkt for Kubernetes
• but many alternatives
13. Definition
Kubernetes is an open-source container-orchestration system for automating deployment, scaling
and management of containerized applications.
It was originally designed by Google and is now maintained by the Cloud Native Computing
Foundation
14. Orchestration: Kubernetes primitives
• Pod - the smallest deployable unit of
computing in Kubernetes. Contains
1 or more containers. A pod models
an application-specific “logical host”
• (Kubernetes) ReplicaSet -
guarantees a certain number of pods
are running with a given
configuration
• Deployment - abstraction layer over
ReplicaSets
nginx-0 nginx-1
nginx-2
15. Orchestration: Features
• Replacement - pods which die get
rescheduled on a new node. It’s fast!
• Consistent, Predictable Hostnames -
if your pod gets rescheduled, Kube
dns will be updated, so your app can
reconnect (Statefulset)
• Affinity Rules - configure how close
together your instances are.
• Same host? Same rack? Same
Availability Zone?
nginx-0 nginx-1
nginx-2
24. Ops Manager - Monitoring, Automation
and Backup
MongoDB Ops Manager makes it fast and
easy for you to deploy, monitor, upgrade, back
up and scale your MongoDB deployment
31. Operators
• Deploying and scaling stateless apps like nginx is easy
• Deploying stateful applications - like databases - is more
complicated. We’ll need more Kubernetes objects to be created
and managed together, and there’s more to do to update
versions, scale or organise backups
32. Operators
• Deploying and scaling stateless apps like nginx is easy
• Deploying stateful applications - like databases - is more
complicated. We’ll need more Kubernetes objects to be created
and managed together, and there’s more to do to update
versions, scale or organise backups
• Operators are a way to add application-specific awareness to
Kubernetes, so you can automate these complex tasks while
taking advantage of Kubernetes Orchestration.
33. Operators
• Deploying and scaling stateless apps like nginx is easy
• Deploying stateful applications - like databases - is more
complicated. We’ll need more Kubernetes objects to be created
and managed together, and there’s more to do to update
versions, scale or organise backups
• Operators are a way to add application-specific awareness to
Kubernetes, so you can automate these complex tasks while
taking advantage of Kubernetes Orchestration.
⟶ You can teach Kubernetes about MongoDB!
35. MongoDB Enterprise Kubernetes
Operator
An application that allows you to create and manage MongoDB
deployments in Kubernetes cluster with the help of Ops Manager
or Cloud Manager
• Quick, declarative definition of what MongoDB services you
want
• Auto-healing, using Kubernetes reliability features
• Easy to scale up / scale down
46. Ways to deploy a Sharded Cluster?
Manually!
https://docs.mongodb.com/manual/tutorial/deploy-shard-cluster/
➔ Time-consuming
➔ Manual management is risky and unreliable
➔ Not reproducible - would need to write your own
automation code
◆ Puppet / Chef / Ansible
48. Using Ops Manager
● Automation! … but
○ Have to configure hardware each time,
and install and configure Automation
Agents (chef / puppet)
○ Need to trigger failure-recovery in Ops
Manager
○ Repeatability - must use APIs
Ways to deploy a Sharded Cluster?
49. What if there was a way that …
• Could provision hardware from a pool whenever needed
• Could recover from failure by requesting new hardware
resources
• Could easily scale your clusters horizontally or vertically
Ways to deploy a Sharded Cluster?
50. What if there was a way that …
• Could provision hardware from a pool whenever needed
• Could recover from failure by requesting new hardware
resources
• Could easily scale your clusters horizontally or vertically
• Declaratively defined deployment config
• Easy to deploy similar configurations / topologies
Ways to deploy a Sharded Cluster?
59. Scaling / Performance: Storage Hardware
Control PersistentVolumeClaims
...
spec:
...
configSrvPodSpec:
storage: 5Gi
storageClass: standard
shardPodSpec:
storage: 25Gi
storageClass: fast
60. Scaling / Performance: Storage Hardware
Control PersistentVolumeClaims
...
spec:
...
configSrvPodSpec:
storage: 5Gi
storageClass: standard
shardPodSpec:
storage: 25Gi
storageClass: fast
...
spec:
...
shardPodSpec:
storage: 25Gi
storageClass: fast
labelSelector:
matchExpressions:
- {key: diskGroup,
operator: In,
values: [shardDisks]}
61. Fault Tolerance: Distributing replicas
By default Operator ensures that all members of one replica set are
distributed to different nodes
It’s possible to change this and spread them to different availability
zones:
configSrvPodSpec:
podAntiAffinityTopologyKey: failure-domain.beta.kubernetes.io/zone
62. A common deployment is to co-locate the mongos process on application
servers, which allows for local communication between the application and
the mongos process.
https://www.mongodb.com/collateral/mongodb-performance-best-practices
Performance: Co-locate mongos pods
with App
65. High availability - Replacement
• Kubernetes will do its best to match the real state with desired state
• If one pod fails, Kubernetes will start another one
• The Kubernetes Statefulset primitive will preserve the hostname of the pod, even if
scheduled to a different machine
• So your MongoDB Driver will be able to connect easily
• MongoDB replication will make sure that the new replica catches up
• The same PersistentVolume will be mounted, so recovery should be fast
67. As an Operations / DevOps engineer
The Operator will make your life easier
Fewer manual tasks, more automated failure recovery
As a Developer
Your company can provide MongoDB as a Service
Easy access to production-ready MongoDB with a single click
or command
So – why use the Operator?
68. Current state
• The Operator is in beta now – v.0.4
github.com/mongodb/mongodb-enterprise-kubernetes
• We are actively collecting customer and community
feedback and building features
community-slack.mongodb.com #enterprise-
kubernetes
• If you have a Kubernetes environment, it’s
available for download & pre-production use now.