Abstractions – Pittsburgh – The Twelve-Factor Container + BONUS

1ed0b822068d34032bca7d2beeb2f846?s=47 Casey West
August 19, 2016

Abstractions – Pittsburgh – The Twelve-Factor Container + BONUS

My talk for Abstractions, with bonus material.

1ed0b822068d34032bca7d2beeb2f846?s=128

Casey West

August 19, 2016
Tweet

Transcript

  1. The Twelve-Factor Container 1 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  2. A word about consent… Please do: Take pictures, tweet, take

    notes. Please don't: Record or live stream without my explicit consent. 2 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  3. The Twelve-Factor Container • Twitter @caseywest • Email casey@geeknest.com •

    Web http://caseywest.com 3 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  4. Thanks, Pivotal 4 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  5. This isn't really a talk about containers 5 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  6. This is a talk about operational maturity 6 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  7. You must be this tall to ride this ride 7

    ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  8. Audience Participation • Containers? • Schedulers? • Cloud? 8 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  9. Docker Docker Docker Docker Docker Docker Docker Docker 9 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  10. The factors http://12factor.net 10 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  11. 1: One codebase tracked in revision control, many deploys 11

    ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  12. Anti-pattern Building separate images for staging and production 12 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  13. Anti-pattern Tags for dev and prod 13 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  14. Best Practice Use the environment and/or feature flags 14 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  15. 2: Explicitly declare and isolate dependencies 15 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  16. 2: Explicitly declare and isolate dependencies 16 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  17. Anti-pattern latest 17 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  18. Best Practice Declare version numbers of upstream dependencies 18 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  19. Best Practice Depend on base images for default filesystem and

    runtimes 19 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  20. 3: Store config in the environment 20 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  21. Anti-pattern config.yml 21 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  22. Anti-pattern properties.xml 22 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  23. Anti-pattern Hard-coded feature flags 23 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  24. Best Practice This one is literally about environment variables 24

    ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  25. Best Practice This one is literally about environment variables !

    ‑ 25 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  26. 4: Treat backing services as attached resources 26 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  27. Anti-pattern Local disk 27 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  28. Anti-pattern Local disk 28 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  29. Anti-pattern Local disk 29 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  30. Best Practice Connect to network- attached services using connection info

    from the environment 30 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  31. 5: Strictly separate build and run stages 31 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  32. Anti-pattern Install on deploy 32 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  33. Best Practice Build immutable images then run those images 33

    ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  34. Painfully Obvious Best Practices 1. Eat when hungry 2. Sleep

    when tired 3. Book Casey West for speaking gigs 34 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  35. Best Practice Respect the lifecycle: buid, run, destroy 35 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  36. 6: Execute the app as one or more stateless processes

    36 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  37. Best Practice Schedule LRPs by distributing them across a cluster

    of physical hardware 37 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  38. Anti-pattern NFS 38 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  39. Anti-pattern NFS Need I say more? 39 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  40. 7: Export services via port binding 40 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  41. Best Practice port = Env.fetch(:PORT) 41 ! @caseywest #abstractions #containers

    #realworld #sorrynotsorry
  42. Best Practice my $port = $ENV{PORT}; 42 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  43. Best Practice private String getPort() { Map<String, String> env =

    System.getenv(); return env.get("PORT"); } 43 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  44. Best Practice let port = env::var("PORT").unwrap() 44 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  45. 8: Scale out via the process model 45 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  46. Best Practice Horizontally scale by adding instances 46 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  47. 9: Maximize robustness with fast startup and graceful shutdown 47

    ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  48. 10: Keep development, staging, and production as similar as possible

    48 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  49. Best Practice Run containers in development 49 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  50. 11: Treat logs as event streams 50 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  51. Anti-pattern Random log files #yolo'd all over the file system

    51 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  52. Best Practice STDOUT STDOUT STDOUT STDOUT 52 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  53. 12: Run admin/ management tasks as one-off processes 53 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  54. Anti-pattern Custom containers for tasks 54 ! @caseywest #abstractions #containers

    #realworld #sorrynotsorry
  55. Best Practice Reuse application images with specific entrypoints for tasks

    55 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  56. More factors? • API first • Secrets management • Health

    metrics • Global distribution 56 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  57. You are now cloud-native 57 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  58. Repeatability Reliability Resiliency 58 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  59. Bonus Material 59 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  60. The five stages of cloud- native 1. Denial 2. Anger

    3. Bargaining 4. Depression 5. Acceptance 60 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  61. Have a seat on the couch 61 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  62. Whatever makes you comfortable 62 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  63. Now for some basic ground rules 63 ! @caseywest #abstractions

    #containers #realworld #sorrynotsorry
  64. Rules We will talk about your delivery pipeline 64 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  65. Rules We will talk about your architecture 65 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  66. Rules We will talk about your automation 66 ! @caseywest

    #abstractions #containers #realworld #sorrynotsorry
  67. ⏰ 67 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  68. "Deploying my apps to 'the cloud' is paintful. Why?" 68

    ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  69. Denial 69 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  70. Denial Containers are just like tiny virtual machines 70 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  71. Denial We don't need to automate continuous delivery 71 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  72. Anger 72 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  73. Anger Works on my machine 73 ! @caseywest #abstractions #containers

    #realworld #sorrynotsorry
  74. Anger Dev is just #YOLO-ing shit to production 74 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  75. Bargaining 75 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  76. Bargaining We crammed this monolith into a container and called

    it a microservice 76 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  77. Bargaining "Bi-Modal IT" 77 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  78. Bargaining What if we create "microservices" that all talk to

    the same data source? 78 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  79. Depression 79 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  80. Depression We made 200 microservices and forgot to set up

    jenkins 80 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  81. Depression We have an automated build pipeline but release twice

    a year 81 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  82. Acceptance 82 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  83. Acceptance All software sucks 83 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  84. Acceptance Respect CAP Theorem 84 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  85. Acceptance Respect Conway's Law 85 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  86. Acceptance Small batch size works for replatforming, too 86 !

    @caseywest #abstractions #containers #realworld #sorrynotsorry
  87. Acceptance Automate everything 87 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  88. ⏰'s up 88 ! @caseywest #abstractions #containers #realworld #sorrynotsorry

  89. What have we learned? 89 ! @caseywest #abstractions #containers #realworld

    #sorrynotsorry
  90. Operability is 1. Microservices Architecture 2. Devops Culture 3. Continuous

    Delivery Pick Three 90 ! @caseywest #abstractions #containers #realworld #sorrynotsorry
  91. @caseywest Let's be friends ! 91 ! @caseywest #abstractions #containers

    #realworld #sorrynotsorry