as code infrastructure - qcon new york · infrastructure as code “applying software engineering...

39
INFRASTRUCTURE AS CODE

Upload: others

Post on 22-May-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

INFRASTRUCTURE AS CODE

Page 2: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

[email protected] Practice Lead (UK)

DevOps, Continuous Delivery, Agile Ops

Twitter: @kiefBook: http://oreil.ly/1JKIBVeSite: http://infrastructure-as-code.com

June 2016

Page 3: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

AGENDA CONTEXT● Motivations● Challenges

INFRASTRUCTURE AS CODE● Key Practices● Simple Pipeline● Scaling Pipelines

Page 4: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SPEEDGet something to market quickly

Iterate it

Continuously improve it

Page 5: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

TECHNOLOGYCloud, automation, etc. lowers barriers for making changes

Page 6: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

DANGERSecurity

Performance

Stability

Compliance

Maintainability

Page 7: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SECRETHigh quality services rely on the ability to make changes quickly

Page 8: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

GOALBe able to make changes

Rapidly,

Frequently,

and Responsibly

Page 9: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

CHALLENGES

Page 10: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SERVER SPRAWLCreating new servers is the easy part

Page 11: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

CONFIGURATION DRIFT

Servers start out identical

But changes accumulate over time

Page 12: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

AUTOMATION FEAR CYCLE

Page 13: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

INFRASTRUCTURE AS CODE“Applying software engineering tools and practices to infrastructure”

Page 14: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

UNATTENDED AUTOMATION

Tools run on a schedule to apply, re-apply, and update configuration

BENEFITS OF UNATTENDED:● Discover problems quickly● Force yourself to fix those

problems● Force yourself to improve

your tools and processes● Discourages “out of band”

changes

Page 15: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

AUTOMATE SERVER UPDATES

Automation isn’t just for new servers!

Configuration synchronization

Run Chef, Puppet, Ansible, etc. on a schedule

Immutable servers Apply changes by rebuilding servers

Containerized servers

Apply changes by deploying new container instances

Page 16: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

RE-USE & PROMOTE DEFINITIONS

Re-use the same definition files across environments for a given application or service

DEV STAGE PRODPlaybooks, Cookbooks, Manifests,

templates, etc.

Page 17: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

TEST INFRASTRUCTURE CHANGES

Preventing DevOops

INFRATEST

DEV TEST

PROD

Page 18: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

PIPELINESUsing Continuous Delivery pipelines to manage infrastructure

Page 19: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

WHAT?

Terraform, Puppet, etc.

Changes are made and committed to VCS

Tools are run on agents to apply changes to environments

Changes are only promoted after passing tests & authorization

Page 20: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

WHY?Validates changes to infrastructure before applying them to production

Confidence for frequent, small improvements to infrastructure

Limit direct changes to infrastructure

Page 21: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

TESTINGCorrectness

Security policies

PerformanceStability

Page 22: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

GOVERNANCEThe process for applying changes is auditable

Changes can be traced back to commits

Automation ensures processes are followed

Authorization can be required as needed

Page 23: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SIMPLEAn example with a fairly simple environment

Page 24: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

VPC

Subnet10.0.0.0/16

Security Group1.1.1.0/16 -> :443

DEFINING A SIMPLE ENVIRONMENT

ANSIBLE PLAYBOOKServer configuration

TERRAFORM FILEEnvironment structure

APPLICATION SOURCEDeployable application

Page 25: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SIMPLE PIPELINE DESIGN

BUILD STAGE

TEST STAGE QA STAGE PROD

STAGE

Application Ansible Terraform

Deploy application, configuration, and infrastructure

Page 26: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SCALINGHandling more complex infrastructure

Page 27: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

ALIGN INFRASTRUCTURE DESIGN TO TEAMS

Ensure teams can make the changes they need easily and safely

Page 28: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

COMPLEX ENVIRONMENTSInfrastructure involving multiple teams

Page 29: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

FAN-IN PIPELINEServiceA

ServiceB

ServiceC

SYSTEM TEST QA PROD

BUILD

BUILD

BUILD

SERVICE TEST

SERVICE TEST

SERVICE TEST

Page 30: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

DECOUPLED PIPELINESServiceA

TESTBUILD

ServiceB

TESTBUILD

ServiceC

TESTBUILD

QA PROD

QA PROD

QA PROD

Page 31: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

DEPENDENCIESServiceA

TESTBUILD

ServiceB

QA PROD

TESTBUILD QA PROD

Create test instance of

provider

Implement Consumer

Driven Contract (CDC) Tests

Use mocks and stubs

Page 32: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

ISSUE: DUPLICATIONMultiple teams using similar systems, e.g. database clusters

Page 33: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

RE-USE BY FORKING DEFINITIONS

Disadvantages:- Divergence and

Inconsistency

Advantages:- Avoid tight coupling- Handles diverse requirements

Page 34: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

RE-USE WITH DEFINITION LIBRARIES

Challenges:

- Avoid tight coupling, so teams aren’t blocked when making changes

- Ownership of code shared by multiple teams

Guidance:

- Use separate pipelines for each

- Use CDC & other dependency testing strategies

Page 35: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

LIBRARY PIPELINE

Server AMI

BUILD

Service

TEST

BUILD TEST

Test shared definitions before pulling them into dependent pipelines

Page 36: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

ISSUE: SHARED ELEMENTS

LOAD BALANCER

ServiceAVIP

ServiceBVIP

Shared infrastructure

definitions

Service-specific infrastructure

definitions

Page 37: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

SHARING ELEMENTSAvoid monoliths - optimize to simplify making changes

Page 38: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

OUTCOMES ● Quickly provision and evolve infrastructure

● Effortlessly roll out fixes

● Keep systems consistent and up to date

● Spend time on high value work

Page 39: AS CODE INFRASTRUCTURE - QCon New York · INFRASTRUCTURE AS CODE “Applying software engineering tools and practices to infrastructure”

Book: http://oreil.ly/1JKIBVeSite: http://infrastructure-as-code.comTwitter: @kief

[email protected] Practice Lead (UK)

DevOps, Continuous Delivery, Agile Ops