Top Banner
Rise of the Machine Images Immutable Infrastructure @axelfontaine
92

Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Jul 05, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Rise of the Machine Images

ImmutableInfrastructure

@axelfontaine

Page 2: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

About Axel Fontaine

• Founder and CEO of Boxfuse

• Over 15 years industry experience

• Continuous Delivery expert

• Regular speaker at tech conferences

• JavaOne RockStar

@axelfontaine

Page 3: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

flywaydb.org

Page 4: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

boxfuse.com

Page 5: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

about

questions

Page 6: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

sometime in the 20th century …

Page 7: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle
Page 8: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

http://en.wikipedia.org/wiki/File:Tdkc60cassette.jpg

Page 9: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle
Page 10: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

+=ONPREM

+

Challenges

Power Network Cooling Phys. Security Phys. Space

OS Install OS Patching App Install App Updates

Procurement Vendor Mgmt Capacity Plan. Financing

Page 11: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

+=ONPREM

+

Challenges

Power Network Cooling Phys. Security Phys. Space

OS Install OS Patching App Install App Updates

Procurement Vendor Mgmt Capacity Plan. Financing

Page 12: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle
Page 13: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

+=ONPREM

+

Challenges

Power Network Cooling Phys. Security Phys. Space

OS Install OS Patching App Install App Updates

Procurement Vendor Mgmt Capacity Plan. Financing

MonthsHours Days or Weeks

Page 14: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

+= +

Challenges

Power Network Cooling Phys. Security Phys. Space

OS Install OS Patching App Install App Updates

Procurement Vendor Mgmt Capacity Plan. Financing

MonthsHours Days or Weeks

COLO

Page 15: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

+= +

Challenges

OS Install OS Patching App Install App Updates

Procurement Vendor Mgmt Capacity Plan. Financing

Hours Days or Weeks

ROOTSERVER

Page 16: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Install OS Patching App Install App Updates

Let’s talk about software

Page 17: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

POLL:which level of automation are you at?

Build Unit Tests Continuous Integration Acceptance Tests Continuous Deployment (Code) Continuous Deployment (Code + DB + Configuration) Infrastructure

Page 18: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Build Test

Page 19: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Build Test

Page 20: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

• One immutable unit• Regenerated after every change• Promoted from Environment to Environment

Classic Mistake: Build per Environment

Page 21: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

Page 22: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

Page 23: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

why aren’t we doing the samefor the layers this is running on ???

Page 24: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle
Page 25: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

Build Test

Page 26: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

Build Test

App

Page 27: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

Any difference is a potential source of errors

Page 28: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

Updates UpdatesUpdates

Sysadmin

Page 29: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

If I had asked my customers what they wanted they would have said a faster horse.

Henry Ford

Page 30: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

Updates UpdatesUpdates

Sysadmin

Page 31: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

Updates UpdatesUpdates

Automated Sysadmin

Page 32: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

fast forward to 2016 …

Page 33: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Every day, AWS adds enough server capacity to power the whole $7B enterprise Amazon.com was in 2004.Weekends included.

Page 34: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Shift to a world of abundance(no more resource scarcity)

Page 35: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

"Advanced Test Reactor" by Argonne National Laboratory -originally posted to Flickr as Advanced Test Reactor core, Idaho National LaboratoryUploaded using F2ComButton. Licensed under CC BY-SA 2.0 via Wikimedia Commons -http://commons.wikimedia.org/wiki/File:Advanced_Test_Reactor.jpg#mediaviewer/File:Advanced_Test_Reactor.jpg

"RIAN archive 341194 Kursk Nuclear Power Plant" by RIA Novosti archive, image #341194 / Sergey Pyatakov / CC-BY-SA 3.0. Licensed under CC BY-SA 3.0 via Wikimedia Commons -http://commons.wikimedia.org/wiki/File:RIAN_archive_341194_Kursk_Nuclear_Power_Plant.jpg#mediaviewer/File:RIAN_archive_341194_Kursk_Nuclear_Power_Plant.jpg

Control Plane Data Plane

Page 36: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Control Plane Data Plane

Page 37: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Automated Provisioning

Cost-driven Architectures

Page 38: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

it is time to rethink the faster horse

Page 39: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

App

OS Kernel

Libraries

Language

App Server

Build Test

Page 40: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

App

OS Kernel

Libraries

Language

App Server

Build Test

UndifferentiatedHeavy lifting

Page 41: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

App

OS Kernel

Libraries

Language

App Server

Build Test

Page 42: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

App

Machine Image

OS Kernel

Libraries

Language

App Server

Build TestMachine

Image

Page 43: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

OS Kernel

Libraries

Language

App Server

App

Machine Image

Machine Image

Machine Image

Page 44: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Machine Image

Machine Image

Machine Image

Updates

Page 45: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

but there is one big problem left …

Page 46: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Machine Image

Network Cable

Page 47: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Machine Image

Network CableMultiple

GB

Page 48: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Running servers in production should be like going backpacking. You take the bare minimum with you. Anything else is going to hurt.

A Wise Man

Page 49: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

what is really adding business value ???

Page 50: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Machine Image

Network Cable

Page 51: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Editors

Daemons OS Kernel

Libraries

Utilities

Drivers

App

App Server

Package Mgr

Compilers

SSH

Firewall

Compatibility

Man Pages

Language

Log Files

Users

Shells

Machine Image

Network Cable

Page 52: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

App

App Server

Language

Bootable App

Page 53: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

15MB

Page 54: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

MultipleGB

15MB

Page 55: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Network CableBootable

App

Page 56: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

who is this for ???

Page 57: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

OS Kernel

Libraries

Language

App Server

App

12-factor app

Page 58: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

demo

Page 59: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

What are the implications ???

Page 60: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Focus shift

Individual instances become disposable

Instance Service

Page 61: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Treat servers like cattle instead of pets

Page 62: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

for servers is dead!

Page 63: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

high uptime is a liability

The longer an instance is up,the harder it becomes to recreate exactly

(and it will fail eventually!)

Page 64: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

How to solve service discovery ?

Use a stableentry point

with aninternal registry

? ElasticLoad

Balancer

Instance

Instance

Instance

Page 65: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

What about security ?

When was the last time your toaster got hacked?

Page 66: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

What about security ?

Complexity is the Enemy of Security

Page 67: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

What about security ?

• Smallest possible attack surface

• Vastly reduced implications due to low uptime and transient nature of instances

• Very difficult to exploit other systemsbecause essential tooling is missing

Bootable App

Page 68: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

• Bake as much configuration as possible for all environments directly in the Bootable App

• Use environment detection and auto-configuration

what about configuration ???

Page 69: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Bootable App

Key Value

JDBC_URL jdbc:…

ENV prod

what about configuration ???

• Bake as much configuration as possible for all environments directly in the Bootable App

• Use environment detection and auto-configuration

• Pass remaining configuration at startup and expose it as environment variables

Page 70: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Instance

what about the database ???

• Keep all persistent state out of the instance, including the database

• Use one of the many good hosted solutions available like Amazon RDS or Google Cloud SQL

• Use a database migration tool to update the schema on application startup

Page 71: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

what about the logs ???LOG file

LOG file

LOG file

ssh me@myserver1tail -f server.log

ssh me@myserver2tail -f server.log

ssh me@myserver3tail -f server.log

Page 72: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

LOG file

LOG file

LOG file log server

where logs can be• aggregated• stored and backuped• indexed• searched

Page 73: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

what about sessions ???

Keep session in an encrypted and signed cookie

• avoids session timeouts• avoids server clustering & session replication• avoids sticky sessions & server affinity

Instance

Page 74: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

what about rolling out new versions ???

Page 75: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Availability Zone 2

Load Balancer

Logs

Availability Zone 1

AppV1

AppV1

Page 76: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Load Balancer

Logs

Availability Zone 1

AppV1

AppV1

Availability Zone 2

Page 77: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Load Balancer

Logs

Availability Zone 1

AppV1

AppV1

AppV2

AppV2

Availability Zone 2

Page 78: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Load Balancer

Logs

Availability Zone 1

Availability Zone 2

AppV1

AppV1

AppV2

AppV2

Page 79: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

what about containers ???(as in OS-level virtualization)

Page 80: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

understanding modern CPUs

Both Intel and AMD have hardware support for virtualization

• isolation• performance penalty

Page 81: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Image

Hardware

Hypervisor

Image

Hardware

OS+ContainerRuntime

ContainerVM

on prem

your responsibility

Page 82: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Image

Hardware

Hypervisor

Image

Hardware

OS+ContainerRuntime

ContainerVM

cloud

Hypervisor

Page 83: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

cloud

your responsibility

cloud responsibilityinstance

schedulingmachineimages

instances instancevolumes

instancenetworking

containerscheduling

containerimages

containers containervolumes

containernetworking

Page 84: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

1.5 months of t2.nano

Page 85: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

1 hour of t2.nano

Page 86: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

cloud

your responsibility

cloud responsibilityinstance

schedulingmachineimages

instances instancevolumes

instancenetworking

containerscheduling

containerimages

containers containervolumes

containernetworking

Only makes sense if you cannot afford

0.5p/hour granularity

Page 87: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

summary

Page 88: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

• One immutable unit• Regenerated after every change• Promoted from Environment to Environment

Classic Mistake: Build per Environment

Page 89: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Bootable App

• One immutable unit• Regenerated after every change• Promoted from Environment to Environment• Use Minimal Images• Focus on Cost in your architectureClassic Mistake: Build per Environment

Page 90: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

boxfuse.com

Page 91: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

Thanks

Page 92: Immutable Infrastructure - QCon · 12-factor app. demo. What are the implications ??? Focus shift Individual instances become disposable Instance Service. Treat servers like cattle

AXEL FONTAINE@axelfontaine

boxfuse.com

I'LL BE BACK