MongoDB Ops Manager is an enterprise-grade end-to-end database management, monitoring, and backup solution. Kubernetes has clearly won the orchestration-platform "wars". In this session we'll take a deep dive on how you can leverage both these technologies to host your MongoDB deployments within your Kubernetes infrastructure whether that's OpenShift, PKS, Azure AKS, or just upstream. This talk will review the core technologies, such as containers, Kubernetes, and MongoDB Ops Manager. You'll also have a chance to see real-live demos of MongoDB running on Kubernetes and managed with MongoDB Ops Manager with the MongoDB Enterprise Kubernetes Operator.
1. opsmanager-kubernetes
December 8, 2018
1 MongoDB Enterprise Kubernetes Operator
1.1 Agenda
• High level overview of Kubernetes
• Kubernetes Cluster vs MongoDB Cluster
• Statefull vs Stateless Replication
• Kubernetes Operators
• Ops Manager Kubernetes Operator
• Build a local cluster along the way
1.2 > whoami
{
"name": "Norberto Leite",
"position": "Lead Engineer",
"team": "Curriculum, Engineering"
}
Norberto Leite
1
2. mflix front page
1.2.1 [@nleite](https://twitter.com/nleite)
1.2.2 Disclaimer
This is a buzzword intensive presentation but by no means intended to trick you into
thinking I’m a very smart person! Buzzwords just sound nice when put together...
1.2.3 But before we get started ....
replace this image
1.2.4 MongoDB Developer Courses
https://university.mongodb.com/
2
3. M220 MongoDB University Courses
Kubernetes Logo
1.3 Kubernetes
1.3.1 Kubernetes Vendor Ecosystem
https://blog.spotinst.com/2018/05/20/kubernetes-ecosystem/
1.3.2 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
Kubernetes Objects
• pods
• replicasets
• persistentvolumeclaims
• persistentvolumes
• nodes
• storageclasses
• clusters
• ...
https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/
1.3.3 Kubernetes is for Containers => Virginia is for Lovers
Kubernetes is an open-source container-orchestration system for automating deployment, scal-
ing and management of containerized applications. It was originally designed by Google and
3
5. is now maintained by the Cloud Native Computing Foundation
Kubernetes uses containers. Well, we can say that kubernetes loves containers. Deploys and
manages containers and containerized applications
Kubernetes has standardized the container definition on the Docker format.
1.3.4 Container Definition
cat mflix/Dockerfile
# base image of mflix container
FROM java:8
# port number the container exposes
EXPOSE 90000
# make the jar file available in the container image
COPY mflix-1.0-SNAPSHOT.jar ./mflix-1.0-SNAPSHOT.jar
# application run command
CMD ["java", "-jar", "./mflix-1.0-SNAPSHOT.jar"]
In this file we can see an example of a Docker image file. Sets the instructions to load, expose
and execute containarized applications or instances.
The Docker images are hiearchical, this means that we can compose images uppon each other,
inheriting the configuration and image setup
In this example we are creating a container image using as baseline a Java image.
1.3.5 Image vs Container
An image determines what and how to run, using/inherinting which requierements and the de-
fault configuration of a containerized application
A container is the the runtime execution of a built Docker image.
5
7. kubernetes_definition
1.3.6 Image vs Container Diagram
https://stackoverflow.com/questions/23735149/what-is-the-difference-between-a-
docker-image-and-a-container
1.3.7 Kubernetes Manages Containers
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
Aside from running containers, Kubernetes is also capable of defining the rules of when to
start/stop containers, how containers communicate with one another, how we scale deployments,
how to upgrade versions of containers, how to provide HA and fault-tolerance and where to place
different containers into different nodes / machines.
1.4 Kubernetes Architecture
On a high level, kubernetes can be represented by something similar to this diagram.
For each Kubernetes cluster, we will have master node, which holds a set of important compo-
nents of the architecture:
• kube-scheduler
• kube-control-manager
• kube-apiserver
• etcd
• kubelet
• kube-proxy
Each of these I’ll provide the relevant links for the exact function within a k8s cluster, however
the names of these components are pretty self explanatory. The unusual one, that might be a bit
more criptic in terms of meaning, given that the name might mean very different things, is etcd,
7
8. Kubernetes Architecture
which is an HA key value store, that Kubernetes uses for all cluster data. You can think of etcd as
the config server in a MongoDB sharded cluster, which may or may not be set to run within the
master node at all. It can run on it’s own separate node.
You will find all the relevant links at the end of this presentation.
But in essence, the master node runs a fair amount of different processes.
https://github.com/kubernetes/community/blob/master/contributors/design-
proposals/architecture/architecture.md#the-kubernetes-node
1.4.1 Multi-master Kubernetes with kubeadm
Given the previous diagram, you might been thinking
this Kubernetes cluster thing does not seem to be too scalable, how in this day an age
does a cluster have only one master.
Well, fear not, kubernetes does have a way to avoid single points of failure using kubeadm.
This is out-of-scope for this talk, but keep in mind that this alone can be setup in several different
architectures.
Bottom line is that kubernetes can be set to run in an HA mode.
1.4.2 Kubernetes Node
Kubernetes is a cluster, therefore > there will be dragons!
Not really, but there will be nodes. Aside from the previously aluded Master node, or several
of these master nodes, k8s also has worker nodes, previously known as minions
K8s nodes can have serveral different specs. We can compose a k8s cluster with physical,
virtual and cloud server nodes. Although, like in any systems archicture, consistency tends to be
benefitial on the long term, a k8s cluster can be composed by a very diverse set of server instance
specs. | Each node is composed with the necessary processes to run pods. Each has a container
runtime, generally docker, to allow the nodes to deploy and run containers.
8
10. POD Diagram
1.4.3 Kubernetes POD
https://kubernetes.io/docs/concepts/workloads/pods/pod/
A POD is the smallest deployable unit of computing in Kubernetes.
Can be composed of one or several different containers, a group of containers, and allows the
definition of shared network and storage, and how to run the set of containers that compose the
POD.
1.4.4 Kubernetes ReplicaSet - Across Nodes
https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
Kubernetes allows for pods to be fault tolerant and highly available. This managed via Repli-
caSes (familiar name!)
We can define PODs replica sets across nodes
10
11. replica set single node
1.4.5 Kubernetes ReplicaSet - Single Node
Or within a single node. This is model that we are going to setup today.
1.4.6 Kubernetes Service
https://kubernetes.io/docs/concepts/services-networking/service/
Services are a speciall type of POD that that other PODs relly on to operate. Now, by default
PODs are mortal and get resurected dynamically, and they subject to constant change in terms of
their deployment composition, number of replica nodes etc. This can cause issues to other PODs
if those rely in some guarantees and pre-defined configuration.
A Kubernetes Service is an abstraction which defines a logical set of PODs and a policy by
which to access them. You find Services as relliable and consistent PODs to support other PODs.
11
12. ops manager diagram
1.5 Ops Manager / Cloud Manager
MongoDB Ops Manager is a MongoDB on-prem solution for managing MongoDB Cluster deploy-
ments. Allows for an holistic management of all things related with MongoDB
• updates
• scaling up and down
• user management and integration
• node deployment
• role management
Across you datacenter.
And there are several particular aspects of a MongoDB Cluster that need care and attention,
something that ops manager takes care of in a very efficient way.
1.5.1 Cloud / Ops Manager - Monitoring
1.5.2 Cloud / Ops Manager - Automation
1.5.3 Cloud / Ops Manager - Backup
1.5.4 Cloud / Ops Manager Agents
1.6 Kubernetes Cluster vs MongoDB Cluster
There are several similar notions and definitions between a Kubernetes cluster and a MongoDB
cluster.
But the devil is in the details and in the functionality of each of these clusters.
1.6.1 Cluster Concepts
• MongoDB Replica Set
• Kubernetes Replica Set
• MongoDB Node
• Kubernetes Node
12
17. Kubernetes Nodes vs MongoDB Nodes
1.6.2 Kubernetes Node vs MongoDB Node
1.6.3 MongoDB Nodes in a Kubernetes Node
1.6.4 Kubernetes ReplicaSet vs MongoDB ReplicaSet
While there purpose for each of the replica set notions is to provide fault tollerance, these are
pretty distinct.
In a POD replication, the definition of the containers is replicate has defined, either to a differ-
ent pod running in the same node or accross different nodes.
In a MongoDB Replica Set, the fault tollerance and HA is also associated with a dynamic intra
replica set rules and options. All nodes of a MongoDB Replica set share the exact same data, they
follow a replication protocol and respond to workloads as a single shared state. This is generally
not the case in a Kubernetes Replica Set.
A nice way to distinguish these two different replica sets is to think in terms of Kubernetes
replica sets as redundancy of application instances/containers, while a MongoDB replica set as-
sures redundancy and HA of data, regardless of the specification of the instance that supports that
service, although all nodes only run a mongodb binary.
1.7 Stateless vs Statefull
One important aspect to keep in mind around cluster management, in particular scalability of
clusters, concernes state and state management.
In generall, container technology is extremely efficient scalling out stateless applications and
systems. This as to do with the fact that state, data, adds density to the scalability. It tends to be
more complicated to manage data then intances.
And this where Kubernetes, via persistent volumes, allows containers scallability to be better
aligned, not perfect with the notion of scaling systems that rely and manage state.
17
20. All Together Now
Getting a system that excels at data management, like mongodb , combined with the scalabilty
offered by kubernetes is a very appealing solution for ops professionals.
1.8 Kubernetes Operator
An Operator is a method of packaging, deploying and managing a Kubernetes appli-
cation. A Kubernetes application is an application that is both deployed on Kubernetes
and managed using the Kubernetes APIs and kubectl tooling.
https://coreos.com/operators/
1.9 MongoDB Enterprise Kubernetes Operator (beta)
The Operator enables easy deploys of MongoDB into Kubernetes clusters, using our
management, monitoring and backup platforms, Ops Manager and Cloud Manager.
By installing this integration, you will be able to deploy MongoDB instances with a
single simple command.
https://github.com/mongodb/mongodb-enterprise-kubernetes
1.9.1 MongoDB Enterprise Kubernetes - Main Benefits
• Quick, declarative definition of what MongoDB services you want
• Auto-healing, using Kubernetes reliability features
• Easy to scale up / scale down
1.10 All Together Now!
https://upload.wikimedia.org/wikipedia/en/c/cd/All_Together_Now_cover.jpg
1.11 Kubernetes + Cloud/Ops Manager
Step 1 - Create Kubernetes Cluster and Cloud/Ops Manager Instance
Step 2 - Install Enterprise Kubernetes Operator
Step 3 - Apply Deployment
Step 4 - Setup Deployment PODs and Agents
Step 5 - Cluster Up and Running Managed by Cloud/Ops Manager
20
24. typical kubernetes cluster image
1.12 Let’s do it!
1.12.1 Typical Image of a Kubernetes Cluster
http://johnmclaughlin.info/learn-kubernetes-using-minikube-docker-macos/
In many different presentations and content out there, in the interwebs, you will see this typical
image of big container ship and lots of containers in it.
Which is nice.
1.12.2 This is what we are going to do today ;)
http://www.simplyorganized.me/2017/05/video-professional-organizers-
organized-fridge-freezer.html
However, in the majority of cases, what you end up setting up is a small set of fridge contain-
ers. That’s exactly what we are going to do today.
1.13 Recap
• Basic overview of Kubernetes components and architecture
• How to locally install a Kubernetes cluster
• How to deploy containarized applications in Kubernetes
• How to deploy and manage a MongoDB Cluster in Kubernetes
• How to integrate Ops Manager | Cloud Manager with Kubernetes
1.13.1 References and Glossory
• kubectl documentation
• kubernetes node
• kubeadm documentation
24