SlideShare a Scribd company logo
@
#MDBlocal
Using MongoDB Services in
Kubernetes:
any platform, development or production
johndohoney
Agenda
MongoDB Kubernetes Support
Kubernetes Overview and
Supporting Toolchain
#MDBLocal
Kubernetes Control Plane
#MDBLocal
Kubernetes Overview
eksctl create cluster 
--name myKubeCluster 
--version 1.14 
--nodegroup-name standard-workers 
--node-type t3.xlarge 
--nodes 3
https://eksctl.io/
HA in one command !
#MDBLocal
Helm Architecture
Helm 2 - Package Manager for Kubernetes
(Helm 3 is in Beta – “No Tiller”)
● https://helm.sh/ Do not use Helm charts with MongoDB Kubernetes Operator as
upgrades are more complicated with the Helm client
Package Manager for Kubernetes - A useful tool
#MDBLocal
Kubernetes Service Catalog
It’s Really this easy….
1. Create resources that define
your application
2. Define the MongoDB Atlas
persistence service it relies
on
3. (Done by MongoDB and
contained in Github repo:
https://github.com/mongodb/
mongodb-atlas-service-
broker )
4. Seamlessly Connect the two
The elegance of simplicity
#MDBLocal
Open Service Broker API
#MDBLocal
The service catalog translates CRD into requests to the Atlas Service
Broker, Provisions resources on your behalf, and injects the
credentials for access back into your containers
Kubernetes Service catalog
Easy Mode
#MDBLocal
• Kubernetes Operator are nothing more than a set of application-
specific custom controllers. Controllers have direct access to
Kubernetes API, which means they can monitor the cluster,
change pods/services, scale up/down and call endpoints of the
running applications, all according to custom rules written inside
those controllers.
• MongoDB’s Operator was created as an effort to make databases
easy to manage without locking you to a specific cloud vendor.
The operator, supports automated cluster provisioning, elastic
scalability, auto recovery, logging, monitoring, shard operations,
backup and restore through Ops/Cloud Manager.
• MongoDB Cloud Manger and Kubernetes Operators provides a
cloud-agnostic application deployment and management. The
power of both tools allow us to treat cloud providers like a
commodity, allowing seamless migration between them.
Kubernetes Operators
ü OperatorHub.io – Online
resource to Kubernetes
Operators
ü https://operatorhub.io/operator/
mongodb-enterprise
#MDBLocal
• A custom resource is an object that
extends the Kubernetes API or
allows you to introduce your own API
into a project or a cluster.
• A custom resource definition (CRD)
file defines your own object kinds
and lets the API Server handle the
entire lifecycle. Deploying a CRD
into the cluster causes the
Kubernetes API server to begin
serving the specified custom
resource.
CRD’s – Kubernetes Custom Resources and Custom Resource Definitions
API Definition from CDR
• /apis/<spec:group>/<spec:version>/<scope>/*/<names-plural>/...
API Proxy Stub
• /apis/mongodb.com/v1/namespaces/mongodb/mongodb/studentcluster
Repo: https://github.com/mongodb/mongodb-enterprise-kubernetes
Reference: crds.yaml
MongoDB Kubernetes Options
#MDBLocal
MongoDB Kubernetes Architectural Alternatives
Hybrid Cloud or Cloud
● MongoDb Open
Service Broker
● Cloud Manager
Best Practice -- depends on requirements
On-Premise - Air gapped
● MongoDB Kubernetes
Operator
#MDBLocal
MongoDB Cloud Manager
Intelligent Agents are the Key
● MongoDB Agents using
Automation on each
MongoDB host can maintain
your MongoDB deployments.
Cloud Manager
● Automation Agents can
add hosts, deploy and
upgrade new and existing
clusters.
● Same look and feel as
On-Premise MongoDB
Ops Manager
Works Anywhere – Used with MongoDB Operator
#MDBLocal
MongoDB Ops Manager
• Deploy and upgrade your
system. Reliably perform the tasks
that you have performed manually
in the past.
• Scale your MongoDB
application. Dynamically resize
capacity by adding shards and
replica set members
• Deliver point-in-time recovery and
scheduled backups. Restore to
any point in time.
• Monitor and get performance
alerts. Track over 100 key metrics.
• Improve Query Performance for
slow queries, recommends new
indexing strategy
For your data center - Used with
MongoDB Operator
#MDBLocal
MongoDB Open
Service Broker
MongoDB
Operator
On-
Premise
Or
Cloud
Hybrid
Or
Public-
Cloud
MongoDB Ops
Manager and MDB
Kubernetes
Operator
Atlas Cloud
Manager and MDB
Kubernetes
Operator
Atlas and
Kubernetes Open
Server Broker
100% Self
Manage
Y
E
S
N
O
Y
E
S
C
L
O
U
D
O
N
P
R
E
M
#MDBLocal
MongoDB Open Service Broker or MongoDB Operator
Considerations
● Where is the database hosted? In Kubernetes Cluster or outside of Kubernetes cluster?
● Is there time/budget for maintenance tasks, like backups, patching and scaling (up and
down)
● Pods are transient, so the likelihood of database application restarts or failovers is higher
● Databases that are storing more transient and caching layers are better fits for
Kubernetes
● Enterprise Ops Manager – You do it all, set up Automation and Backup MongoDB
Clusters, Set all configuration options, Load Balance Ops Manager GUI
● Cloud Manager – We do it, point and click “Hosted Ops Manager” – Mongo Clusters in
Kubernetes
Containerization Data layer -- finally getting traction
#MDBLocal
But, I can set up MongoDB Myself
● Who should own the technical debt?
● The people that wrote the database, and know the internals …
● Or, My company that has an expertise in the area of <Fill in your application Domain>
● What is businesses biggest complaint of IT/Project Management/Development
● We want it now, we want it faster (Plus we want you to read our minds – right!!!!)
● We all like to be good stewards of our companies money, but are we?
● MongoDB handles all the system maintenance, both Atlas and Cloud Manager
● Help is a support ticket call away – seriously, these people are REALLY good!
● Free is not free, Yes, it is perfect for Dev Clusters, great for experiments, great for
learning, then there are those wonderful people that love us, that we are taking time
away from, perhaps unnecessarily.
Considerations
Installation Walkthrough
#MDBLocal
#! /usr/bin/env bash
eksctl create cluster 
--name service-cluster 
--version 1.13 
--nodegroup-name standard-workers 
--node-type t3.xlarge 
--nodes 3
# Get External IP – Atlas and Cloud Manager are Secure by Default
kubectl get nodes -o jsonpath='{$.items[*].status.addresses[?(@.type=="ExternalIP")].address }'
echo "Be sure to add external IPs to API Whitelist..."
#MDBLocal
API Secrets
● Both Open Service
Broker and Operator
Uses API Public and
Private Key
● Both Use Organization
ID
● However, format and
locations of data are
different
But they are different …
#MDBLocal
Open Service Broker
Installation Specific
#MDBLocal
#! /usr/bin/env bash
#
echo
echo "Load Tiller and Initialize helm"
echo "Load Service Catalog Repos and then load"
echo "Service Catalog into the cluster"
echo
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-admin 
--clusterrole=cluster-admin 
--serviceaccount=kube-system:default
helm init
helm repo add svc-cat https://svc-catalog-charts.storage.googleapis.com
echo "Sleeping to wait for Tiller to start..."
sleep 20
helm install svc-cat/catalog 
--name catalog --namespace catalog
#MDBLocal
#! /usr/bin/env bash
kubectl create namespace atlas
#
# Sanity check
kubectl get namespace
#
# Install the Atlas Open Service Broker
#
kubectl apply -f deployment-and-service.yaml -n atlas
#MDBLocal
#! /usr/bin/env bash
kubectl apply -f secret.yaml -n atlas
kubectl describe secrets/atlas-service-broker-auth -n atlas
apiVersion: v1
kind: Secret
metadata:
name: atlas-service-broker-auth
type: Opaque
stringData:
username: fdeadoen@5d656831c56c98173cf5dead
password: d7ef8f25-ac31-dead-9723-93463d39dead
#MDBLocal
#! /usr/bin/env bash
#
# Register the Atlas Open Service Broker with the Kubernetes Service Catalog
#
kubectl apply -f service-broker.yaml -n atlas
svcat get brokers -n atlas
##
# Check our Work
##
svcat describe broker atlas-service-broker -n atlas
# Deploy ReplicaSet
#
kubectl apply -f replica-set.yaml
# How is the deployment going
svcat describe instance my-atlas-cluster -n atlas
#MDBLocal
Service Options
ClusterServiceBroker
● An Atlas Open Service Broker instance that is registered as a ClusterServiceBroker is available to the
entire Kubernetes cluster. When you deploy a Atlas replica set or sharded cluster, you must use the
associated clusterServiceClass and clusterServicePlan resources.
ServiceBroker
● An Atlas Open Service Broker instance that is registered as a ServiceBroker is available to only a single
namespace within the Kubernetes cluster. When you deploy a Atlas replica set or sharded cluster, you
must use the serviceClass and servicePlan resources scoped to the same namespace.
#MDBLocal
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
name: my-atlas-cluster
namespace: atlas
spec:
serviceClassExternalName: mongodb-atlas-aws
servicePlanExternalName: M30
parameters:
cluster:
providerSettings:
regionName: US_WEST_2
autoscaling:
diskGBEnabled: false
backupEnabled: true
#MDBLocal
#! /usr/bin/env bash
echo "Make sure your Mongo Atlas ReplicaSet has deployed"
kubectl apply -f atlas-user-test.yaml
svcat describe binding jdohoney -n atlas
#MDBLocal
#! /usr/bin/env bash
svcat describe instance my-atlas-cluster -n atlas
#
echo "Get User Name"
USERNAME=`kubectl get secret jdohoney -n atlas -o json | jq .data.username`
echo $USERNAME | sed 's/"//g' | base64 --decode
LUSERNAME=`echo $USERNAME | sed 's/"//g' | base64 --decode`
echo
echo "Get User Password"
PASSWORD=`kubectl get secret jdohoney -n atlas -o json | jq .data.password`
echo $PASSWORD | sed 's/"//g' | base64 --decode
echo
echo "Get mongo connection URI"
URI=`kubectl get secret jdohoney -n atlas -o json | jq .data.uri`
echo $URI | sed 's/"//g' | base64 --decode
LURI=`echo $URI | sed 's/"//g' | base64 --decode`
echo "mongo $LURI --username $LUSERNAME" | sed 's/"//g'
echo
echo "use the decoded password when prompted"
echo
echo "Connect to Compass"
#MDBLocal
#! /usr/bin/env bash
kubectl delete servicebindings jdohoney -n atlas
svcat describe instance jdohoney -n atlas
#MDBLocal
MongoDB Operator
Installation Specific
#MDBLocal
#! /bin/bash
# Create the namespace for your Kubernetes deployment.
kubectl create namespace mongodb
# Sanity check
kubectl get namespace
# Install the Custom Resource Definitions
kubectl apply -f ./mongodb-enterprise-kubernetes/crds.yaml
# Deploy the operator
kubectl apply -f ./mongodb-enterprise-kubernetes/mongodb-enterprise.yaml
#MDBLocal
#! /bin/bash
# Create Secret for OpsManager API
kubectl -n mongodb 
create secret generic mongo-cloud-mgr 
--from-literal="user=cdxrnetm" 
--from-literal="publicApiKey=5b21f87d-5c19-4295-b87a-13569610ea06"
# Sanity Check
kubectl describe secrets/mongo-cloud-mgr -n mongodb
#MDBLocal
#! /bin/bash
# Tell Ops Manager your configuration
kubectl apply -f opsMgr.yaml
# Deploy the ReplicaSet Cluster
kubectl apply -f replicaset.yaml
# Track Status of ReplicaSet Deployment
kubectl get mdb studentcluster -n mongodb -o yaml -w
##
# (OPTIONAL) Create a AWS LB and a public IP to connect
kubectl expose svc studentcluster-svc --port=27017 --target-port=27017 --name=external-connect-mongo --type=LoadBalancer -n
mongodb
kubectl get svc -n mongodb
#MDBLocal
---
apiVersion: v1
kind: ConfigMap
metadata:
name: opsmanager-config
namespace: mongodb
data:
projectName: AWS-EKS
orgId: 5d656337f2a30db182dc3f0a
baseUrl: https://cloud.mongodb.com
---
apiVersion: mongodb.com/v1
kind: MongoDB
metadata:
name: studentcluster
namespace: mongodb
spec:
members: 3
version: 4.2.1
opsManager:
configMapRef:
name: opsmanager-config
credentials: mongo-cloud-mgr
type: ReplicaSet
persistent: true
Ops Manager ConfigMap ReplicaSet ConfigMap
#MDBLocal
# Connect to the Cluster
kubectl port-forward studentcluster-0 27017:27017 -n mongodb
#Import some data
mongoimport --host 127.0.0.1 --db clients --collection cases <
sampleData/client_cases.json
#MDBLocal
• Open Service Broker Configuration
• https://github.com/johndohoneyjr/MongoDB-DOT-Local-Open-Service-Broker
• MongoDB Operator Configuration
• https://github.com/johndohoneyjr/AWS-MongoDB-Kubernetes-Operator-Demo
• Atlas Service Broker - Documentation Pages
• https://docs.mongodb.com/atlas-open-service-broker/current/
• MongoDB Enterprise Kubernetes Operator
• https://docs.mongodb.com/kubernetes-operator/stable/
Resources
#MDBlocal
Every session you rate enters you into a drawing for a
$200 gift card and TWO passes to MongoDB World 2020!
Using MongoDB Services in
Kubernetes: Any Platform
https://www.surveymonkey.com/r/QRCJHVP
THANK YOU

More Related Content

PDF
Getting Started with Kubernetes
PDF
Docker Compose by Aanand Prasad
PDF
Kubernetes
PDF
Understanding InfluxDB Basics: Tags, Fields and Measurements
PDF
Kubernetes Basics
PDF
Kubernetes - introduction
PDF
Evolution of containers to kubernetes
PDF
An Introduction to Kubernetes
Getting Started with Kubernetes
Docker Compose by Aanand Prasad
Kubernetes
Understanding InfluxDB Basics: Tags, Fields and Measurements
Kubernetes Basics
Kubernetes - introduction
Evolution of containers to kubernetes
An Introduction to Kubernetes

What's hot (20)

PPTX
Docker introduction &amp; benefits
PDF
Kubernetes in Docker
PDF
Introduction to kubernetes
PDF
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
PPTX
Kubernetes for Beginners: An Introductory Guide
PDF
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
PDF
Kubernetes Introduction
PDF
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
PDF
Role based access control - RBAC - Kubernetes
PDF
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
PPTX
Red Hat Openshift Fundamentals.pptx
PDF
PUBG: Battlegrounds 라이브 서비스 EKS 전환 사례 공유 [크래프톤 - 레벨 300] - 발표자: 김정헌, PUBG Dev...
PDF
IT Automation with Ansible
PDF
Kubernetes: A Short Introduction (2019)
PDF
Docker Networking Deep Dive
PDF
[2018] 오픈스택 5년 운영의 경험
PDF
Amazon EKS로 간단한 웹 애플리케이션 구축하기 - 김주영 (AWS) :: AWS Community Day Online 2021
PDF
Quick introduction to Kubernetes
PDF
Introduction to Kubernetes RBAC
Docker introduction &amp; benefits
Kubernetes in Docker
Introduction to kubernetes
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes for Beginners: An Introductory Guide
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
Kubernetes Introduction
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Role based access control - RBAC - Kubernetes
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
Red Hat Openshift Fundamentals.pptx
PUBG: Battlegrounds 라이브 서비스 EKS 전환 사례 공유 [크래프톤 - 레벨 300] - 발표자: 김정헌, PUBG Dev...
IT Automation with Ansible
Kubernetes: A Short Introduction (2019)
Docker Networking Deep Dive
[2018] 오픈스택 5년 운영의 경험
Amazon EKS로 간단한 웹 애플리케이션 구축하기 - 김주영 (AWS) :: AWS Community Day Online 2021
Quick introduction to Kubernetes
Introduction to Kubernetes RBAC
Ad

Similar to MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Development or Production (20)

PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
PDF
Federated Kubernetes: As a Platform for Distributed Scientific Computing
PDF
DevEx | there’s no place like k3s
PPTX
Kubernetes #1 intro
PPTX
Introduction to Kubernetes
PDF
Operator Lifecycle Management
PDF
Operator Lifecycle Management
PDF
Clocker - How to Train your Docker Cloud
PDF
Kubernetes intro
PDF
Kubernetes - how to orchestrate containers
PPTX
Containers kuberenetes
PPTX
Containers kuberenetes
PPTX
Kubernetes @ meetic
PDF
Kubernetes basics and hands on exercise
PPTX
K8s in 3h - Kubernetes Fundamentals Training
PPTX
Introduction to Kubernetes
PDF
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
PDF
Containers kuberenetes
PPTX
Container Orchestration with Docker Swarm and Kubernetes
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
Federated Kubernetes: As a Platform for Distributed Scientific Computing
DevEx | there’s no place like k3s
Kubernetes #1 intro
Introduction to Kubernetes
Operator Lifecycle Management
Operator Lifecycle Management
Clocker - How to Train your Docker Cloud
Kubernetes intro
Kubernetes - how to orchestrate containers
Containers kuberenetes
Containers kuberenetes
Kubernetes @ meetic
Kubernetes basics and hands on exercise
K8s in 3h - Kubernetes Fundamentals Training
Introduction to Kubernetes
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
Containers kuberenetes
Container Orchestration with Docker Swarm and Kubernetes
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
PDF
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
PDF
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Artificial Intelligence
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
sap open course for s4hana steps from ECC to s4
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Encapsulation_ Review paper, used for researhc scholars
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Artificial Intelligence
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Review of recent advances in non-invasive hemoglobin estimation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Development or Production

  • 1. @ #MDBlocal Using MongoDB Services in Kubernetes: any platform, development or production johndohoney
  • 5. #MDBLocal Kubernetes Overview eksctl create cluster --name myKubeCluster --version 1.14 --nodegroup-name standard-workers --node-type t3.xlarge --nodes 3 https://eksctl.io/ HA in one command !
  • 6. #MDBLocal Helm Architecture Helm 2 - Package Manager for Kubernetes (Helm 3 is in Beta – “No Tiller”) ● https://helm.sh/ Do not use Helm charts with MongoDB Kubernetes Operator as upgrades are more complicated with the Helm client Package Manager for Kubernetes - A useful tool
  • 7. #MDBLocal Kubernetes Service Catalog It’s Really this easy…. 1. Create resources that define your application 2. Define the MongoDB Atlas persistence service it relies on 3. (Done by MongoDB and contained in Github repo: https://github.com/mongodb/ mongodb-atlas-service- broker ) 4. Seamlessly Connect the two The elegance of simplicity
  • 9. #MDBLocal The service catalog translates CRD into requests to the Atlas Service Broker, Provisions resources on your behalf, and injects the credentials for access back into your containers Kubernetes Service catalog Easy Mode
  • 10. #MDBLocal • Kubernetes Operator are nothing more than a set of application- specific custom controllers. Controllers have direct access to Kubernetes API, which means they can monitor the cluster, change pods/services, scale up/down and call endpoints of the running applications, all according to custom rules written inside those controllers. • MongoDB’s Operator was created as an effort to make databases easy to manage without locking you to a specific cloud vendor. The operator, supports automated cluster provisioning, elastic scalability, auto recovery, logging, monitoring, shard operations, backup and restore through Ops/Cloud Manager. • MongoDB Cloud Manger and Kubernetes Operators provides a cloud-agnostic application deployment and management. The power of both tools allow us to treat cloud providers like a commodity, allowing seamless migration between them. Kubernetes Operators ü OperatorHub.io – Online resource to Kubernetes Operators ü https://operatorhub.io/operator/ mongodb-enterprise
  • 11. #MDBLocal • A custom resource is an object that extends the Kubernetes API or allows you to introduce your own API into a project or a cluster. • A custom resource definition (CRD) file defines your own object kinds and lets the API Server handle the entire lifecycle. Deploying a CRD into the cluster causes the Kubernetes API server to begin serving the specified custom resource. CRD’s – Kubernetes Custom Resources and Custom Resource Definitions API Definition from CDR • /apis/<spec:group>/<spec:version>/<scope>/*/<names-plural>/... API Proxy Stub • /apis/mongodb.com/v1/namespaces/mongodb/mongodb/studentcluster Repo: https://github.com/mongodb/mongodb-enterprise-kubernetes Reference: crds.yaml
  • 13. #MDBLocal MongoDB Kubernetes Architectural Alternatives Hybrid Cloud or Cloud ● MongoDb Open Service Broker ● Cloud Manager Best Practice -- depends on requirements On-Premise - Air gapped ● MongoDB Kubernetes Operator
  • 14. #MDBLocal MongoDB Cloud Manager Intelligent Agents are the Key ● MongoDB Agents using Automation on each MongoDB host can maintain your MongoDB deployments. Cloud Manager ● Automation Agents can add hosts, deploy and upgrade new and existing clusters. ● Same look and feel as On-Premise MongoDB Ops Manager Works Anywhere – Used with MongoDB Operator
  • 15. #MDBLocal MongoDB Ops Manager • Deploy and upgrade your system. Reliably perform the tasks that you have performed manually in the past. • Scale your MongoDB application. Dynamically resize capacity by adding shards and replica set members • Deliver point-in-time recovery and scheduled backups. Restore to any point in time. • Monitor and get performance alerts. Track over 100 key metrics. • Improve Query Performance for slow queries, recommends new indexing strategy For your data center - Used with MongoDB Operator
  • 16. #MDBLocal MongoDB Open Service Broker MongoDB Operator On- Premise Or Cloud Hybrid Or Public- Cloud MongoDB Ops Manager and MDB Kubernetes Operator Atlas Cloud Manager and MDB Kubernetes Operator Atlas and Kubernetes Open Server Broker 100% Self Manage Y E S N O Y E S C L O U D O N P R E M
  • 17. #MDBLocal MongoDB Open Service Broker or MongoDB Operator Considerations ● Where is the database hosted? In Kubernetes Cluster or outside of Kubernetes cluster? ● Is there time/budget for maintenance tasks, like backups, patching and scaling (up and down) ● Pods are transient, so the likelihood of database application restarts or failovers is higher ● Databases that are storing more transient and caching layers are better fits for Kubernetes ● Enterprise Ops Manager – You do it all, set up Automation and Backup MongoDB Clusters, Set all configuration options, Load Balance Ops Manager GUI ● Cloud Manager – We do it, point and click “Hosted Ops Manager” – Mongo Clusters in Kubernetes Containerization Data layer -- finally getting traction
  • 18. #MDBLocal But, I can set up MongoDB Myself ● Who should own the technical debt? ● The people that wrote the database, and know the internals … ● Or, My company that has an expertise in the area of <Fill in your application Domain> ● What is businesses biggest complaint of IT/Project Management/Development ● We want it now, we want it faster (Plus we want you to read our minds – right!!!!) ● We all like to be good stewards of our companies money, but are we? ● MongoDB handles all the system maintenance, both Atlas and Cloud Manager ● Help is a support ticket call away – seriously, these people are REALLY good! ● Free is not free, Yes, it is perfect for Dev Clusters, great for experiments, great for learning, then there are those wonderful people that love us, that we are taking time away from, perhaps unnecessarily. Considerations
  • 20. #MDBLocal #! /usr/bin/env bash eksctl create cluster --name service-cluster --version 1.13 --nodegroup-name standard-workers --node-type t3.xlarge --nodes 3 # Get External IP – Atlas and Cloud Manager are Secure by Default kubectl get nodes -o jsonpath='{$.items[*].status.addresses[?(@.type=="ExternalIP")].address }' echo "Be sure to add external IPs to API Whitelist..."
  • 21. #MDBLocal API Secrets ● Both Open Service Broker and Operator Uses API Public and Private Key ● Both Use Organization ID ● However, format and locations of data are different But they are different …
  • 23. #MDBLocal #! /usr/bin/env bash # echo echo "Load Tiller and Initialize helm" echo "Load Service Catalog Repos and then load" echo "Service Catalog into the cluster" echo kubectl create serviceaccount --namespace kube-system tiller kubectl create clusterrolebinding tiller-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default helm init helm repo add svc-cat https://svc-catalog-charts.storage.googleapis.com echo "Sleeping to wait for Tiller to start..." sleep 20 helm install svc-cat/catalog --name catalog --namespace catalog
  • 24. #MDBLocal #! /usr/bin/env bash kubectl create namespace atlas # # Sanity check kubectl get namespace # # Install the Atlas Open Service Broker # kubectl apply -f deployment-and-service.yaml -n atlas
  • 25. #MDBLocal #! /usr/bin/env bash kubectl apply -f secret.yaml -n atlas kubectl describe secrets/atlas-service-broker-auth -n atlas apiVersion: v1 kind: Secret metadata: name: atlas-service-broker-auth type: Opaque stringData: username: fdeadoen@5d656831c56c98173cf5dead password: d7ef8f25-ac31-dead-9723-93463d39dead
  • 26. #MDBLocal #! /usr/bin/env bash # # Register the Atlas Open Service Broker with the Kubernetes Service Catalog # kubectl apply -f service-broker.yaml -n atlas svcat get brokers -n atlas ## # Check our Work ## svcat describe broker atlas-service-broker -n atlas # Deploy ReplicaSet # kubectl apply -f replica-set.yaml # How is the deployment going svcat describe instance my-atlas-cluster -n atlas
  • 27. #MDBLocal Service Options ClusterServiceBroker ● An Atlas Open Service Broker instance that is registered as a ClusterServiceBroker is available to the entire Kubernetes cluster. When you deploy a Atlas replica set or sharded cluster, you must use the associated clusterServiceClass and clusterServicePlan resources. ServiceBroker ● An Atlas Open Service Broker instance that is registered as a ServiceBroker is available to only a single namespace within the Kubernetes cluster. When you deploy a Atlas replica set or sharded cluster, you must use the serviceClass and servicePlan resources scoped to the same namespace.
  • 28. #MDBLocal apiVersion: servicecatalog.k8s.io/v1beta1 kind: ServiceInstance metadata: name: my-atlas-cluster namespace: atlas spec: serviceClassExternalName: mongodb-atlas-aws servicePlanExternalName: M30 parameters: cluster: providerSettings: regionName: US_WEST_2 autoscaling: diskGBEnabled: false backupEnabled: true
  • 29. #MDBLocal #! /usr/bin/env bash echo "Make sure your Mongo Atlas ReplicaSet has deployed" kubectl apply -f atlas-user-test.yaml svcat describe binding jdohoney -n atlas
  • 30. #MDBLocal #! /usr/bin/env bash svcat describe instance my-atlas-cluster -n atlas # echo "Get User Name" USERNAME=`kubectl get secret jdohoney -n atlas -o json | jq .data.username` echo $USERNAME | sed 's/"//g' | base64 --decode LUSERNAME=`echo $USERNAME | sed 's/"//g' | base64 --decode` echo echo "Get User Password" PASSWORD=`kubectl get secret jdohoney -n atlas -o json | jq .data.password` echo $PASSWORD | sed 's/"//g' | base64 --decode echo echo "Get mongo connection URI" URI=`kubectl get secret jdohoney -n atlas -o json | jq .data.uri` echo $URI | sed 's/"//g' | base64 --decode LURI=`echo $URI | sed 's/"//g' | base64 --decode` echo "mongo $LURI --username $LUSERNAME" | sed 's/"//g' echo echo "use the decoded password when prompted" echo echo "Connect to Compass"
  • 31. #MDBLocal #! /usr/bin/env bash kubectl delete servicebindings jdohoney -n atlas svcat describe instance jdohoney -n atlas
  • 33. #MDBLocal #! /bin/bash # Create the namespace for your Kubernetes deployment. kubectl create namespace mongodb # Sanity check kubectl get namespace # Install the Custom Resource Definitions kubectl apply -f ./mongodb-enterprise-kubernetes/crds.yaml # Deploy the operator kubectl apply -f ./mongodb-enterprise-kubernetes/mongodb-enterprise.yaml
  • 34. #MDBLocal #! /bin/bash # Create Secret for OpsManager API kubectl -n mongodb create secret generic mongo-cloud-mgr --from-literal="user=cdxrnetm" --from-literal="publicApiKey=5b21f87d-5c19-4295-b87a-13569610ea06" # Sanity Check kubectl describe secrets/mongo-cloud-mgr -n mongodb
  • 35. #MDBLocal #! /bin/bash # Tell Ops Manager your configuration kubectl apply -f opsMgr.yaml # Deploy the ReplicaSet Cluster kubectl apply -f replicaset.yaml # Track Status of ReplicaSet Deployment kubectl get mdb studentcluster -n mongodb -o yaml -w ## # (OPTIONAL) Create a AWS LB and a public IP to connect kubectl expose svc studentcluster-svc --port=27017 --target-port=27017 --name=external-connect-mongo --type=LoadBalancer -n mongodb kubectl get svc -n mongodb
  • 36. #MDBLocal --- apiVersion: v1 kind: ConfigMap metadata: name: opsmanager-config namespace: mongodb data: projectName: AWS-EKS orgId: 5d656337f2a30db182dc3f0a baseUrl: https://cloud.mongodb.com --- apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: studentcluster namespace: mongodb spec: members: 3 version: 4.2.1 opsManager: configMapRef: name: opsmanager-config credentials: mongo-cloud-mgr type: ReplicaSet persistent: true Ops Manager ConfigMap ReplicaSet ConfigMap
  • 37. #MDBLocal # Connect to the Cluster kubectl port-forward studentcluster-0 27017:27017 -n mongodb #Import some data mongoimport --host 127.0.0.1 --db clients --collection cases < sampleData/client_cases.json
  • 38. #MDBLocal • Open Service Broker Configuration • https://github.com/johndohoneyjr/MongoDB-DOT-Local-Open-Service-Broker • MongoDB Operator Configuration • https://github.com/johndohoneyjr/AWS-MongoDB-Kubernetes-Operator-Demo • Atlas Service Broker - Documentation Pages • https://docs.mongodb.com/atlas-open-service-broker/current/ • MongoDB Enterprise Kubernetes Operator • https://docs.mongodb.com/kubernetes-operator/stable/ Resources
  • 39. #MDBlocal Every session you rate enters you into a drawing for a $200 gift card and TWO passes to MongoDB World 2020! Using MongoDB Services in Kubernetes: Any Platform https://www.surveymonkey.com/r/QRCJHVP