the twelve factor container

58
The Twelve-Factor Container 1 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Upload: pivotal

Post on 23-Jan-2018

790 views

Category:

Technology


0 download

TRANSCRIPT

The Twelve-Factor Container

1 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

2 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

The Twelve-Factor Container• Twitter @caseywest

• Email [email protected]

• Web caseywest.com

3 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

This isn't really a talk about containers

4 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

This is a talk about operational maturity

5 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

You must be this tall to ride this ride

6 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Who has used…• Containers?• Schedulers?• Cloud?

7 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Docker

Docker

Docker

Docker

Docker

Docker

Docker

Docker

8 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

The factors

9 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

1: One codebase tracked in revision control, many deploys

10 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternBuilding separate images for staging and production

11 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternTags for dev and prod

12 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeUse the environment and/or feature flags

13 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

2: Explicitly declare and isolate dependencies

14 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

2: Explicitly declare and isolate dependencies

15 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternlatest

16 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeDeclare version numbers of upstream dependencies

17 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeDepend on base images for default filesystem and runtimes

18 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

3: Store config in the environment

19 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternconfig.yml

20 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternproperties.xml

21 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternHard-coded feature flags

22 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeThis one is literally about environment variables

23 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeThis one is literally about environment variables ! ⬇24 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

4: Treat backing services as attached resources

25 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternNo local disk

26 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternNo local disk

27 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-pattern

No local disk

28 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeConnect to network-attached services using connection info from the environment29 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

5: Strictly separate build and run stages

30 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternInstall on deploy

31 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeBuild immutable images then run those images

32 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Painfully Obvious Best PracticesEat when hungrySleep when tiredBook Casey West for speaking gigs33 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeRespect the lifecycle: build, run, destroy

34 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

6: Execute the app as one or more stateless processes

35 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeSchedule LRPs by distributing them across a cluster of physical hardware36 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternNFS

37 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternNFSNeed I say more?

38 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

7: Export services via port binding

39 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best Practiceport = Env.fetch(:PORT)

40 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best Practicemy $port = $ENV{PORT};

41 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best Practiceprivate String getPort() { Map<String, String> env = System.getenv(); return env.get("PORT");}

42 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best Practicelet port = env::var("PORT").unwrap()

43 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

8: Scale out via the process model

44 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeHorizontally scale by adding instances

45 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

9: Maximize robustness with fast startup and graceful shutdown

46 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

10: Keep development, staging, and production as similar as possible

47 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeRun containers in development

48 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

11: Treat logs as event streams

49 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternRandom log files #yolo'd all over the file system

50 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternRandom log files #yolo'd all over the file system, bro

51 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeSTDOUTSTDOUTSTDOUTSTDOUT52 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

12: Run admin/management tasks as one-off processes

53 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Anti-patternCustom containers for tasks

54 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

Best PracticeReuse application images with specific entrypoints for tasks

55 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

You are now cloud-native

56 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

RepeatabilityReliabilityResiliency57 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til

@caseywestLet's be friends

!58 ! @caseywest #S1P #containers #operability #ops #12factor #realtalk #til