20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... ·...
Transcript of 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... ·...
![Page 1: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/1.jpg)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
From Terraform to SaltStack and beyondAlexandru Herișanu, Site Reliability Engineer
![Page 2: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/2.jpg)
© 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
![Page 3: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/3.jpg)
© 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.”
![Page 4: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/4.jpg)
© 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
![Page 5: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/5.jpg)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
MongoDB 101 – In 3 little steps
![Page 6: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/6.jpg)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
MongoDB 101
§ You need 3 roles:§ MongoDB Replica Set
§ MongoDB Configuration Replica Set
§ Mongos Routers
![Page 7: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/7.jpg)
© 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
![Page 8: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/8.jpg)
© 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
![Page 9: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/9.jpg)
© 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
![Page 10: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/10.jpg)
© 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
![Page 11: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/11.jpg)
© 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
![Page 12: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/12.jpg)
© 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
![Page 13: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/13.jpg)
© 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
![Page 14: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/14.jpg)
© 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?
![Page 15: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/15.jpg)
© 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
![Page 16: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/16.jpg)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Create the infrastructure
Cloudformation Terraform Other
![Page 17: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/17.jpg)
© 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?
![Page 18: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/18.jpg)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How it all looks from far, far away
![Page 19: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/19.jpg)
© 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
![Page 20: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/20.jpg)
© 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?
![Page 21: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/21.jpg)
© 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
![Page 22: 20161122 From Terraform to SaltStack and beyondfiles.meetup.com/18628440/From Terraform to... · “Create a MongoDB sharded cluster in an AWS environment. This cluster should be](https://reader035.fdocuments.in/reader035/viewer/2022062916/5ec7ec2cb0586619b6106cd6/html5/thumbnails/22.jpg)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.