20161122 from terraform to saltstack and beyondfiles.meetup.com/18628440/from terraform to... ·...

22
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. From Terraform to SaltStack and beyond Alexandru Heri ș anu, Site Reliability Engineer

Upload: others

Post on 21-May-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.