© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
From Terraform to SaltStack and beyondAlexandru Herișanu, Site Reliability Engineer
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Agenda
§ Case Study 1: Create MongoDB sharded cluster in AWS§ MongoDB 101§ The challenge!§ Case Study 2: Create N MongoDB sharded clusters in AWS§ The challenge! (2)§ Questions
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Case Study 1: Create MongoDB sharded cluster in AWS
“Create a MongoDB sharded cluster in an AWS environment. This cluster should be authenticated,should contain at least 2 replica sets and contain three given databases and a pre-defined user foreach.”
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How to build a MongoDB cluster in 3 easy steps …
Step 1 • Create the infrastructure
Step 2 • Bootstrap the cluster
Step 3 • Manage the cluster
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
MongoDB 101 – In 3 little steps
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
MongoDB 101
§ You need 3 roles:§ MongoDB Replica Set
§ MongoDB Configuration Replica Set
§ Mongos Routers
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
The challenge ! (1)
§ To me able to use a sharded, authentication-enabled MongoDB Cluster you need to:§ Enable authentication§ Initialize the replica set (times how many replica sets there are)§ Initialize the configuration server replica set§ Create the shard setup§ Manage users and databases
§ Before actually starting using it
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How to build a MongoDB cluster in 3 easy steps …
Step 1 • Create the infrastructure
Step 2 • Bootstrap the cluster
Step 3 • Manage the cluster
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Manage the cluster
Roles
• A host has only one role
Profiles
• A host may implement many profiles
Resources
• Configures one "thing"
Code Data
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Manage the cluster
Roles
• A host has only one role
Profiles
• A host may implement many profiles
Resources
• Configures one "thing"
Code Data
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Manage the cluster
Roles
• A host has only one role
Profiles
• A host may implement many profiles
Resources
• Configures one "thing"
Code Data
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How do I know which which is which?
§ How does a VM know it’s role?
§ In case of a MongoDB cluster, how do I know the cluster I’m part of?
ITIL -> CMDB
hostnames
AWS Tag
Static file
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How to build a MongoDB cluster in 3 easy steps …
Step 1 • Create the infrastructure
Step 2 • Bootstrap the cluster
Step 3 • Manage the cluster
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Bootstrap the cluster
§ How do you start a VM and bootstrap it?
§ Bash script – CSSH
§ Ansible playbook / Runbook
§ Central orchestration system: Saltstack
§ Cloudformation Magic (cloud-init)
Pros / Cons
S3New VM
bootstrap.sh
But, what about permissions boss?
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How to build a MongoDB cluster in 3 easy steps …
Step 1 • Create the infrastructure
Step 2 • Bootstrap the cluster
Step 3 • Manage the cluster
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Create the infrastructure
Cloudformation Terraform Other
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Yes, but … but ... but
§ What happens when you need ordering between actions?§ Say you use CloudFormation + cloud-init
§ Block until condition is met
§ How would you implement this?
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How it all looks from far, far away
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Case Study 2: Create N MongoDB sharded clusters in AWS
§ “In the previous setup, change your configuration around to be able to spin up N number of clusters. Re-create this setup in multiple AWS regions.”
§ Strong requirement: We want to be able to start and bootstrap the cluster without touching any key
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
The challenge ! (2)
§ How do you define different clusters now?
§ Where is the data regarding your infrastructure?§ Custom facters (puppet), grains (Saltstack)§ DynamoDB tables§ S3 buckets with files
§ How do you ensure the ordering in this case?
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
You need something new
§ Scratch space where you can read/write what data you need§ Saltstack SDB – Postgresql BJSON
§ Queueing system?§ HTTP API over Zookeeper§ Saltstack Queues – Postgres DB§ ETCD§ S3 files ending in .done
§ Event system?§ Saltstack ZeroMQ with Postgresql backend
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Top Related