SlideShare a Scribd company logo
1 of 20
NOVEMBER 6, 2019
Creating a stateful application with
K8S and AWS DB Services
Bahubali Shetti
@Shetti
Director of Cloud Developer Advocacy VMware
App
Cloud
Database
Kubernetes
? Self or Fully Manage
Stateless
Application Data
(Application State)
Not easy to move
Maximizing portability with Kubernetes – BUT what about the Data?
Self Managed vs Fully Managed….
?
Find it at cloudjourney.io (look for the github site)
Typical Microservice App - AcmeShop
Parameterizing the database end points in K8S
Code Instrumentation for App-DB connectivity
...
…
spec:
volumes:
- name: acmefit-order-data
emptyDir: {}
containers:
- image: order:latest
name: order
env:
- name: ORDER_DB_HOST
value: 'order-mongo'
- name: ORDER_DB_PASSWORD
valueFrom:
secretKeyRef:
name: order-mongo-pass
key: password
- name: ORDER_DB_PORT
value: '27017’
…
…
FROM bitnami/python:3.7
MAINTAINER Bill Shetti
"billshetti@gmail.com"
ENV ORDER_DB_HOST="localhost"
ENV ORDER_DB_PORT="27017"
ENV ORDER_DB_PASSWORD=""
ENV ORDER_DB_USERNAME=""
ENV PAYMENT_HOST="localhost"
ENV PAYMENT_PORT="9000"
# needed for mongo client
RUN install_packages mongodb-
clients
COPY ./requirements.txt
/app/requirements.txt
RUN pip3 install -r requirements.txt
…
…
…
…
from os import environ
if environ.get('ORDER_DB_USERNAME') is not
None:
if os.environ['ORDER_DB_USERNAME'] !=
"":
mongouser=os.environ['ORDER_DB_USERNA
ME']
else:
mongouser=''
else:
mongouser=''
if environ.get('ORDER_DB_HOST') is not None:
if os.environ['ORDER_DB_HOST'] != "":
mongohost=os.environ['ORDER_DB_HOST']
else:
mongohost='localhost'
else:
mongohost='localhost’
…
…
K8S Yaml Dockerfile Python order.py code
Libraries and connecting to the DB
Code Instrumentation for DB
import pymongo
from pymongo import MongoClient
from pymongo import errors as mongoerrors
client=MongoClient(mongouri)
#uri=username:password@host:port
Or
client=MongoClient(host=mongohost, port=int(mongoport),
username=mongouser, password=mongopassword)
import redis
rConn=redis.StrictRedis(host=redishost, port=redisport,
password=redispassword, db=0)
Lots of standard libraries (go, python, etc) with significant support
Installation and management – Several options
Setting up your own containerized DB
Initialization
kubectl create secret generic order-mongo-pass
--from-literal=password=<value>
Secrets
Create
kubectl apply -f order-db-total.yaml
kubectl apply -f config-map.yaml
Automates deployment of single node
or replica sets for mongodb
Enables set up of alerting, monitoring
Optional persistence and storage
configuration
Easy scale
(ISH)
OperatorsSimple K8S Create
Early Days
(Beta/Alpha)
(still adding features)
etc
(ISH)
Installation and management – Several options
Setting up your own containerized DB
HA Configured by default
So what’s hard? – Keeping state persistent
Setting up your own containerized DB
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast
provisioner: kubernetes.io/aws-ebs
parameters:
type: io1
containers:
- name: mongo
image: mongo
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
volumeClaimTemplates:
- metadata:
name: mongo-persistent-storage
annotations:
volume.beta.kubernetes.io/storage-class: "fast"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 100Gi
Storage Provisioning and Management
Infra and DB expertise or App and business focus?
What’s important to you?
Infra Skills App Skills
?
AWS Options
Fully Managed Databases
Simple to implement
Creating HA arch – operational overhead
No support for sharding
No encryption
Operationally Expensive
Simple to implement
Built in HA with read replicas, multiple primaries, failovers, etc
Easly scalable
Sharding support
Encryption at rest/intransit
K8S
Operator
VS
√
Redis and AWS Elasticache
Managed Databases
Built in sharding & replica sets for easy scaling
Still have to manually add nodes
Manage backup manually or with tools (OpsManager, CloudManager etc)
Manage Upgrades etc
K8S
Operator
Easy setup (only compatible with MongoDB 3.6)
Managed sharding, replicas
Managed scale (up to 64TB)
Easy backups - AWS
Handles 100ks reads/writes/sec
Easy setup – deploys on AWS/Azure/GCP
Managed sharding, replicas
Managed scale
Easy backups – AWS/Azure/GCP
Pure Mongo experience with latest and greatest features
VS
√
√
DocumentDB and MongoDB Atlas
Managed Databases
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast
provisioner: kubernetes.io/aws-ebs
parameters:
type: io1
containers:
- name: mongo
image: mongo
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
volumeClaimTemplates:
- metadata:
name: mongo-persistent-storage
annotations:
volume.beta.kubernetes.io/storage-class: "fast"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 100Gi
Storage Provisioning and Management
Keeping state persistent?
Using a managedDB
aws --region us-east-2 elasticache create-cache-cluster --cache-cluster-id my-cluster --cache-node-type cache.r4.large --
engine redis --engine-version 3.2.4 --num-cache-nodes 1 --cache-parameter-group default.redis3.2
aws --region us-east-2 docdb create-db-cluster --db-cluster-identifier mongoeq --engine docdb --master-username bill --
master-user-password password1
OR
https://github.com/awslabs/aws-service-operator
AWS CLI with automation
AWS service operator
(ISH)
Installation and management –
Using a managed DB
Parameterizing the database end points in K8S
Code Instrumentation for DB
...
…
spec:
volumes:
- name: acmefit-order-data
emptyDir: {}
containers:
- image: order:latest
name: order
env:
- name: ORDER_DB_HOST
value: 'order-mongo'
- name: ORDER_DB_PASSWORD
valueFrom:
secretKeyRef:
name: order-mongo-pass
key: password
- name: ORDER_DB_PORT
value: '27017’
…
…
FROM bitnami/python:3.7
MAINTAINER Bill Shetti
"billshetti@gmail.com"
ENV ORDER_DB_HOST="localhost"
ENV ORDER_DB_PORT="27017"
ENV ORDER_DB_PASSWORD=""
ENV ORDER_DB_USERNAME=""
ENV PAYMENT_HOST="localhost"
ENV PAYMENT_PORT="9000"
# needed for mongo client
RUN install_packages mongodb-
clients
COPY ./requirements.txt
/app/requirements.txt
RUN pip3 install -r requirements.txt
…
…
…
…
from os import environ
if environ.get('ORDER_DB_USERNAME') is not
None:
if os.environ['ORDER_DB_USERNAME'] !=
"":
mongouser=os.environ['ORDER_DB_USERNA
ME']
else:
mongouser=''
else:
mongouser=''
if environ.get('ORDER_DB_HOST') is not None:
if os.environ['ORDER_DB_HOST'] != "":
mongohost=os.environ['ORDER_DB_HOST']
else:
mongohost='localhost'
else:
mongohost='localhost’
…
…
K8S Yaml Dockerfile Python order.py code
Insert Document DB URL INFO HERE
import pymongo
from pymongo import MongoClient
from pymongo import errors as mongoerrors
client=MongoClient(mongouri)
#uri=username:password@host:port
Or
client=MongoClient(host=mongohost, port=int(mongoport),
username=mongouser, password=mongopassword)
import redis
rConn=redis.StrictRedis(host=redishost, port=redisport,
password=redispassword, db=0)
Steps and hurdles – code instrumentization
Using a Managed DB
URL FROM AWS Services
Self Managed vs Fully Managed….
?
19
www.cloudjourney.io
@cloudjourneyio
Bahubali Shetti - @Shetti
How to manage state with a Kubernetes Application

More Related Content

What's hot

Windows Azure HDInsight Service
Windows Azure HDInsight ServiceWindows Azure HDInsight Service
Windows Azure HDInsight ServiceNeil Mackenzie
 
Serverless Stream Processing with Bill Bejeck
Serverless Stream Processing with Bill BejeckServerless Stream Processing with Bill Bejeck
Serverless Stream Processing with Bill Bejeckconfluent
 
Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2Kornel Lugosi
 
storage on windows azure
storage on windows azurestorage on windows azure
storage on windows azureomkar2488
 
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...CodeOps Technologies LLP
 
A practical approach to provisioning resources in azure
A practical approach to provisioning resources in azureA practical approach to provisioning resources in azure
A practical approach to provisioning resources in azureMorten Christensen
 
Node.js on Windows Azure
Node.js on Windows AzureNode.js on Windows Azure
Node.js on Windows AzureNeil Mackenzie
 
Rich storytelling with Drupal, Paragraphs and Islandora DAMS
Rich storytelling with Drupal, Paragraphs and Islandora DAMSRich storytelling with Drupal, Paragraphs and Islandora DAMS
Rich storytelling with Drupal, Paragraphs and Islandora DAMSalxbrdg
 
Amazon Web Services Building Blocks for Drupal Applications and Hosting
Amazon Web Services Building Blocks for Drupal Applications and HostingAmazon Web Services Building Blocks for Drupal Applications and Hosting
Amazon Web Services Building Blocks for Drupal Applications and HostingAcquia
 
ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...
ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...
ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...DynamicInfraDays
 
Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017Hesham Amin
 
Scalable On-Demand Hadoop Clusters with Docker and Mesos
Scalable On-Demand Hadoop Clusters with Docker and MesosScalable On-Demand Hadoop Clusters with Docker and Mesos
Scalable On-Demand Hadoop Clusters with Docker and MesosDataWorks Summit
 
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and moreScaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and moreDropsolid
 
AWS Webcast - Explore the AWS Cloud
AWS Webcast - Explore the AWS CloudAWS Webcast - Explore the AWS Cloud
AWS Webcast - Explore the AWS CloudAmazon Web Services
 
Cloud Computing: AWS for Lean Startups
Cloud Computing: AWS for Lean StartupsCloud Computing: AWS for Lean Startups
Cloud Computing: AWS for Lean StartupsZvi Avraham
 
Global Windows Azure Bootcamp (GWAB) Auckland 2014 - Windows Azure Integrati...
Global Windows Azure Bootcamp (GWAB)  Auckland 2014 - Windows Azure Integrati...Global Windows Azure Bootcamp (GWAB)  Auckland 2014 - Windows Azure Integrati...
Global Windows Azure Bootcamp (GWAB) Auckland 2014 - Windows Azure Integrati...Nikolai Blackie
 
Create HDInsight Cluster in Azure Portal (February 2015)
Create HDInsight Cluster in Azure Portal (February 2015)Create HDInsight Cluster in Azure Portal (February 2015)
Create HDInsight Cluster in Azure Portal (February 2015)Cindy Gross
 
Binary Studio Academy 2016. MS Azure. Cloud hosting.
Binary Studio Academy 2016. MS Azure. Cloud hosting.Binary Studio Academy 2016. MS Azure. Cloud hosting.
Binary Studio Academy 2016. MS Azure. Cloud hosting.Binary Studio
 

What's hot (20)

Windows Azure HDInsight Service
Windows Azure HDInsight ServiceWindows Azure HDInsight Service
Windows Azure HDInsight Service
 
Serverless Stream Processing with Bill Bejeck
Serverless Stream Processing with Bill BejeckServerless Stream Processing with Bill Bejeck
Serverless Stream Processing with Bill Bejeck
 
Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2
 
storage on windows azure
storage on windows azurestorage on windows azure
storage on windows azure
 
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
 
A practical approach to provisioning resources in azure
A practical approach to provisioning resources in azureA practical approach to provisioning resources in azure
A practical approach to provisioning resources in azure
 
Node.js on Windows Azure
Node.js on Windows AzureNode.js on Windows Azure
Node.js on Windows Azure
 
Rich storytelling with Drupal, Paragraphs and Islandora DAMS
Rich storytelling with Drupal, Paragraphs and Islandora DAMSRich storytelling with Drupal, Paragraphs and Islandora DAMS
Rich storytelling with Drupal, Paragraphs and Islandora DAMS
 
Amazon Web Services Building Blocks for Drupal Applications and Hosting
Amazon Web Services Building Blocks for Drupal Applications and HostingAmazon Web Services Building Blocks for Drupal Applications and Hosting
Amazon Web Services Building Blocks for Drupal Applications and Hosting
 
ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...
ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...
ContainerDays NYC 2016: "Containers in Azure: Understanding the Microsoft Con...
 
Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017
 
Scalable On-Demand Hadoop Clusters with Docker and Mesos
Scalable On-Demand Hadoop Clusters with Docker and MesosScalable On-Demand Hadoop Clusters with Docker and Mesos
Scalable On-Demand Hadoop Clusters with Docker and Mesos
 
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and moreScaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
 
Webapp on AWS
Webapp on AWSWebapp on AWS
Webapp on AWS
 
AWS Webcast - Explore the AWS Cloud
AWS Webcast - Explore the AWS CloudAWS Webcast - Explore the AWS Cloud
AWS Webcast - Explore the AWS Cloud
 
Cloud Computing: AWS for Lean Startups
Cloud Computing: AWS for Lean StartupsCloud Computing: AWS for Lean Startups
Cloud Computing: AWS for Lean Startups
 
Global Windows Azure Bootcamp (GWAB) Auckland 2014 - Windows Azure Integrati...
Global Windows Azure Bootcamp (GWAB)  Auckland 2014 - Windows Azure Integrati...Global Windows Azure Bootcamp (GWAB)  Auckland 2014 - Windows Azure Integrati...
Global Windows Azure Bootcamp (GWAB) Auckland 2014 - Windows Azure Integrati...
 
Azure CosmosDB
Azure CosmosDBAzure CosmosDB
Azure CosmosDB
 
Create HDInsight Cluster in Azure Portal (February 2015)
Create HDInsight Cluster in Azure Portal (February 2015)Create HDInsight Cluster in Azure Portal (February 2015)
Create HDInsight Cluster in Azure Portal (February 2015)
 
Binary Studio Academy 2016. MS Azure. Cloud hosting.
Binary Studio Academy 2016. MS Azure. Cloud hosting.Binary Studio Academy 2016. MS Azure. Cloud hosting.
Binary Studio Academy 2016. MS Azure. Cloud hosting.
 

Similar to How to manage state with a Kubernetes Application

HPE Storage KubeCon US 2018 Workshop
HPE Storage KubeCon US 2018 WorkshopHPE Storage KubeCon US 2018 Workshop
HPE Storage KubeCon US 2018 WorkshopMichael Mattsson
 
Using MongoDB to Build a Fast and Scalable Content Repository
Using MongoDB to Build a Fast and Scalable Content RepositoryUsing MongoDB to Build a Fast and Scalable Content Repository
Using MongoDB to Build a Fast and Scalable Content RepositoryMongoDB
 
Options for running Kubernetes at scale across multiple cloud providers
Options for running Kubernetes at scale across multiple cloud providersOptions for running Kubernetes at scale across multiple cloud providers
Options for running Kubernetes at scale across multiple cloud providersSAP HANA Cloud Platform
 
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20..."AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...Vadym Kazulkin
 
Containerized Storage for Containers: Why, What and How OpenEBS Works
Containerized Storage for Containers:  Why, What and How OpenEBS WorksContainerized Storage for Containers:  Why, What and How OpenEBS Works
Containerized Storage for Containers: Why, What and How OpenEBS WorksMatt Baldwin
 
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...Codemotion
 
Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...
Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...
Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...Codemotion
 
Kubernetes on AWS 實作工作坊
Kubernetes on AWS 實作工作坊Kubernetes on AWS 實作工作坊
Kubernetes on AWS 實作工作坊Amazon Web Services
 
Architecting Cloud Apps
Architecting Cloud AppsArchitecting Cloud Apps
Architecting Cloud Appsjineshvaria
 
OpenEBS Technical Workshop - KubeCon San Diego 2019
OpenEBS Technical Workshop - KubeCon San Diego 2019OpenEBS Technical Workshop - KubeCon San Diego 2019
OpenEBS Technical Workshop - KubeCon San Diego 2019MayaData Inc
 
Building Cloud-Native Applications with Microsoft Windows Azure
Building Cloud-Native Applications with Microsoft Windows AzureBuilding Cloud-Native Applications with Microsoft Windows Azure
Building Cloud-Native Applications with Microsoft Windows AzureBill Wilder
 
DevOps vs. Site Reliability Engineering (SRE) in Age of Kubernetes
DevOps vs. Site Reliability Engineering (SRE) in Age of KubernetesDevOps vs. Site Reliability Engineering (SRE) in Age of Kubernetes
DevOps vs. Site Reliability Engineering (SRE) in Age of KubernetesDevOps.com
 
Ceph Day Tokyo - Bring Ceph to Enterprise
Ceph Day Tokyo - Bring Ceph to Enterprise Ceph Day Tokyo - Bring Ceph to Enterprise
Ceph Day Tokyo - Bring Ceph to Enterprise Ceph Community
 
AWS Webcast - Best Practices in Architecting for the Cloud
AWS Webcast - Best Practices in Architecting for the CloudAWS Webcast - Best Practices in Architecting for the Cloud
AWS Webcast - Best Practices in Architecting for the CloudAmazon Web Services
 
Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019
Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019
Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019Gerd König
 
Kubernetes Kops - Automation Night
Kubernetes Kops - Automation NightKubernetes Kops - Automation Night
Kubernetes Kops - Automation NightKasper Nissen
 
Docker Chennai Meetup - OpenEBS Overview
Docker Chennai Meetup - OpenEBS OverviewDocker Chennai Meetup - OpenEBS Overview
Docker Chennai Meetup - OpenEBS OverviewOpenEBS
 
DevOps in Age of Kubernetes
DevOps in Age of KubernetesDevOps in Age of Kubernetes
DevOps in Age of KubernetesMesosphere Inc.
 
Containerized Storage for Containers- Kubernetes LA Meetup , July 2017
Containerized Storage for Containers- Kubernetes LA Meetup , July 2017Containerized Storage for Containers- Kubernetes LA Meetup , July 2017
Containerized Storage for Containers- Kubernetes LA Meetup , July 2017OpenEBS
 
Save 60% of Kubernetes storage costs on AWS & others with OpenEBS
Save 60% of Kubernetes storage costs on AWS & others with OpenEBSSave 60% of Kubernetes storage costs on AWS & others with OpenEBS
Save 60% of Kubernetes storage costs on AWS & others with OpenEBSMayaData Inc
 

Similar to How to manage state with a Kubernetes Application (20)

HPE Storage KubeCon US 2018 Workshop
HPE Storage KubeCon US 2018 WorkshopHPE Storage KubeCon US 2018 Workshop
HPE Storage KubeCon US 2018 Workshop
 
Using MongoDB to Build a Fast and Scalable Content Repository
Using MongoDB to Build a Fast and Scalable Content RepositoryUsing MongoDB to Build a Fast and Scalable Content Repository
Using MongoDB to Build a Fast and Scalable Content Repository
 
Options for running Kubernetes at scale across multiple cloud providers
Options for running Kubernetes at scale across multiple cloud providersOptions for running Kubernetes at scale across multiple cloud providers
Options for running Kubernetes at scale across multiple cloud providers
 
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20..."AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
 
Containerized Storage for Containers: Why, What and How OpenEBS Works
Containerized Storage for Containers:  Why, What and How OpenEBS WorksContainerized Storage for Containers:  Why, What and How OpenEBS Works
Containerized Storage for Containers: Why, What and How OpenEBS Works
 
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
 
Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...
Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...
Max Körbächer - AWS EKS and beyond master your Kubernetes deployment on AWS -...
 
Kubernetes on AWS 實作工作坊
Kubernetes on AWS 實作工作坊Kubernetes on AWS 實作工作坊
Kubernetes on AWS 實作工作坊
 
Architecting Cloud Apps
Architecting Cloud AppsArchitecting Cloud Apps
Architecting Cloud Apps
 
OpenEBS Technical Workshop - KubeCon San Diego 2019
OpenEBS Technical Workshop - KubeCon San Diego 2019OpenEBS Technical Workshop - KubeCon San Diego 2019
OpenEBS Technical Workshop - KubeCon San Diego 2019
 
Building Cloud-Native Applications with Microsoft Windows Azure
Building Cloud-Native Applications with Microsoft Windows AzureBuilding Cloud-Native Applications with Microsoft Windows Azure
Building Cloud-Native Applications with Microsoft Windows Azure
 
DevOps vs. Site Reliability Engineering (SRE) in Age of Kubernetes
DevOps vs. Site Reliability Engineering (SRE) in Age of KubernetesDevOps vs. Site Reliability Engineering (SRE) in Age of Kubernetes
DevOps vs. Site Reliability Engineering (SRE) in Age of Kubernetes
 
Ceph Day Tokyo - Bring Ceph to Enterprise
Ceph Day Tokyo - Bring Ceph to Enterprise Ceph Day Tokyo - Bring Ceph to Enterprise
Ceph Day Tokyo - Bring Ceph to Enterprise
 
AWS Webcast - Best Practices in Architecting for the Cloud
AWS Webcast - Best Practices in Architecting for the CloudAWS Webcast - Best Practices in Architecting for the Cloud
AWS Webcast - Best Practices in Architecting for the Cloud
 
Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019
Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019
Kubernetes on AWS => EKS || CNCF Meetup Zurich, Feb 2019
 
Kubernetes Kops - Automation Night
Kubernetes Kops - Automation NightKubernetes Kops - Automation Night
Kubernetes Kops - Automation Night
 
Docker Chennai Meetup - OpenEBS Overview
Docker Chennai Meetup - OpenEBS OverviewDocker Chennai Meetup - OpenEBS Overview
Docker Chennai Meetup - OpenEBS Overview
 
DevOps in Age of Kubernetes
DevOps in Age of KubernetesDevOps in Age of Kubernetes
DevOps in Age of Kubernetes
 
Containerized Storage for Containers- Kubernetes LA Meetup , July 2017
Containerized Storage for Containers- Kubernetes LA Meetup , July 2017Containerized Storage for Containers- Kubernetes LA Meetup , July 2017
Containerized Storage for Containers- Kubernetes LA Meetup , July 2017
 
Save 60% of Kubernetes storage costs on AWS & others with OpenEBS
Save 60% of Kubernetes storage costs on AWS & others with OpenEBSSave 60% of Kubernetes storage costs on AWS & others with OpenEBS
Save 60% of Kubernetes storage costs on AWS & others with OpenEBS
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

How to manage state with a Kubernetes Application

  • 1. NOVEMBER 6, 2019 Creating a stateful application with K8S and AWS DB Services Bahubali Shetti @Shetti Director of Cloud Developer Advocacy VMware
  • 2. App Cloud Database Kubernetes ? Self or Fully Manage Stateless Application Data (Application State) Not easy to move Maximizing portability with Kubernetes – BUT what about the Data?
  • 3. Self Managed vs Fully Managed…. ?
  • 4. Find it at cloudjourney.io (look for the github site) Typical Microservice App - AcmeShop
  • 5. Parameterizing the database end points in K8S Code Instrumentation for App-DB connectivity ... … spec: volumes: - name: acmefit-order-data emptyDir: {} containers: - image: order:latest name: order env: - name: ORDER_DB_HOST value: 'order-mongo' - name: ORDER_DB_PASSWORD valueFrom: secretKeyRef: name: order-mongo-pass key: password - name: ORDER_DB_PORT value: '27017’ … … FROM bitnami/python:3.7 MAINTAINER Bill Shetti "billshetti@gmail.com" ENV ORDER_DB_HOST="localhost" ENV ORDER_DB_PORT="27017" ENV ORDER_DB_PASSWORD="" ENV ORDER_DB_USERNAME="" ENV PAYMENT_HOST="localhost" ENV PAYMENT_PORT="9000" # needed for mongo client RUN install_packages mongodb- clients COPY ./requirements.txt /app/requirements.txt RUN pip3 install -r requirements.txt … … … … from os import environ if environ.get('ORDER_DB_USERNAME') is not None: if os.environ['ORDER_DB_USERNAME'] != "": mongouser=os.environ['ORDER_DB_USERNA ME'] else: mongouser='' else: mongouser='' if environ.get('ORDER_DB_HOST') is not None: if os.environ['ORDER_DB_HOST'] != "": mongohost=os.environ['ORDER_DB_HOST'] else: mongohost='localhost' else: mongohost='localhost’ … … K8S Yaml Dockerfile Python order.py code
  • 6. Libraries and connecting to the DB Code Instrumentation for DB import pymongo from pymongo import MongoClient from pymongo import errors as mongoerrors client=MongoClient(mongouri) #uri=username:password@host:port Or client=MongoClient(host=mongohost, port=int(mongoport), username=mongouser, password=mongopassword) import redis rConn=redis.StrictRedis(host=redishost, port=redisport, password=redispassword, db=0) Lots of standard libraries (go, python, etc) with significant support
  • 7. Installation and management – Several options Setting up your own containerized DB Initialization kubectl create secret generic order-mongo-pass --from-literal=password=<value> Secrets Create kubectl apply -f order-db-total.yaml kubectl apply -f config-map.yaml Automates deployment of single node or replica sets for mongodb Enables set up of alerting, monitoring Optional persistence and storage configuration Easy scale (ISH) OperatorsSimple K8S Create Early Days (Beta/Alpha) (still adding features) etc (ISH)
  • 8. Installation and management – Several options Setting up your own containerized DB HA Configured by default
  • 9. So what’s hard? – Keeping state persistent Setting up your own containerized DB apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: fast provisioner: kubernetes.io/aws-ebs parameters: type: io1 containers: - name: mongo image: mongo ports: - containerPort: 27017 volumeMounts: - name: mongo-persistent-storage mountPath: /data/db volumeClaimTemplates: - metadata: name: mongo-persistent-storage annotations: volume.beta.kubernetes.io/storage-class: "fast" spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 100Gi Storage Provisioning and Management
  • 10. Infra and DB expertise or App and business focus? What’s important to you? Infra Skills App Skills ?
  • 12. Simple to implement Creating HA arch – operational overhead No support for sharding No encryption Operationally Expensive Simple to implement Built in HA with read replicas, multiple primaries, failovers, etc Easly scalable Sharding support Encryption at rest/intransit K8S Operator VS √ Redis and AWS Elasticache Managed Databases
  • 13. Built in sharding & replica sets for easy scaling Still have to manually add nodes Manage backup manually or with tools (OpsManager, CloudManager etc) Manage Upgrades etc K8S Operator Easy setup (only compatible with MongoDB 3.6) Managed sharding, replicas Managed scale (up to 64TB) Easy backups - AWS Handles 100ks reads/writes/sec Easy setup – deploys on AWS/Azure/GCP Managed sharding, replicas Managed scale Easy backups – AWS/Azure/GCP Pure Mongo experience with latest and greatest features VS √ √ DocumentDB and MongoDB Atlas Managed Databases
  • 14. apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: fast provisioner: kubernetes.io/aws-ebs parameters: type: io1 containers: - name: mongo image: mongo ports: - containerPort: 27017 volumeMounts: - name: mongo-persistent-storage mountPath: /data/db volumeClaimTemplates: - metadata: name: mongo-persistent-storage annotations: volume.beta.kubernetes.io/storage-class: "fast" spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 100Gi Storage Provisioning and Management Keeping state persistent? Using a managedDB
  • 15. aws --region us-east-2 elasticache create-cache-cluster --cache-cluster-id my-cluster --cache-node-type cache.r4.large -- engine redis --engine-version 3.2.4 --num-cache-nodes 1 --cache-parameter-group default.redis3.2 aws --region us-east-2 docdb create-db-cluster --db-cluster-identifier mongoeq --engine docdb --master-username bill -- master-user-password password1 OR https://github.com/awslabs/aws-service-operator AWS CLI with automation AWS service operator (ISH) Installation and management – Using a managed DB
  • 16. Parameterizing the database end points in K8S Code Instrumentation for DB ... … spec: volumes: - name: acmefit-order-data emptyDir: {} containers: - image: order:latest name: order env: - name: ORDER_DB_HOST value: 'order-mongo' - name: ORDER_DB_PASSWORD valueFrom: secretKeyRef: name: order-mongo-pass key: password - name: ORDER_DB_PORT value: '27017’ … … FROM bitnami/python:3.7 MAINTAINER Bill Shetti "billshetti@gmail.com" ENV ORDER_DB_HOST="localhost" ENV ORDER_DB_PORT="27017" ENV ORDER_DB_PASSWORD="" ENV ORDER_DB_USERNAME="" ENV PAYMENT_HOST="localhost" ENV PAYMENT_PORT="9000" # needed for mongo client RUN install_packages mongodb- clients COPY ./requirements.txt /app/requirements.txt RUN pip3 install -r requirements.txt … … … … from os import environ if environ.get('ORDER_DB_USERNAME') is not None: if os.environ['ORDER_DB_USERNAME'] != "": mongouser=os.environ['ORDER_DB_USERNA ME'] else: mongouser='' else: mongouser='' if environ.get('ORDER_DB_HOST') is not None: if os.environ['ORDER_DB_HOST'] != "": mongohost=os.environ['ORDER_DB_HOST'] else: mongohost='localhost' else: mongohost='localhost’ … … K8S Yaml Dockerfile Python order.py code Insert Document DB URL INFO HERE
  • 17. import pymongo from pymongo import MongoClient from pymongo import errors as mongoerrors client=MongoClient(mongouri) #uri=username:password@host:port Or client=MongoClient(host=mongohost, port=int(mongoport), username=mongouser, password=mongopassword) import redis rConn=redis.StrictRedis(host=redishost, port=redisport, password=redispassword, db=0) Steps and hurdles – code instrumentization Using a Managed DB URL FROM AWS Services
  • 18. Self Managed vs Fully Managed…. ?